misc/libfreetype/src/base/ftrfork.c
author koda
Mon, 25 Apr 2011 01:46:54 +0200
changeset 5172 88f2e05288ba
permissions -rw-r--r--
aaand let's add freetype as well while we are at it other smaller changes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5172
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     1
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     2
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     3
/*  ftrfork.c                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     4
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     5
/*    Embedded resource forks accessor (body).                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
/*  Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010 by                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*  Masatake YAMATO and Redhat K.K.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
/*  FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
/*  derived from ftobjs.c.                                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    12
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    13
/*  This file is part of the FreeType project, and may only be used,       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    14
/*  modified, and distributed under the terms of the FreeType project      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
/*  this file you indicate that you have read the license and              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
/*  understand and accept it fully.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
/* Development of the code in this file is support of                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
/* Information-technology Promotion Agency, Japan.                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
#include <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
#include FT_INTERNAL_DEBUG_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
#include FT_INTERNAL_STREAM_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
#include FT_INTERNAL_RFORK_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
#undef  FT_COMPONENT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
#define FT_COMPONENT  trace_raccess
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
  /****                                                                 ****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
  /****                                                                 ****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
  /****               Resource fork directory access                    ****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
  /****                                                                 ****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
  /****                                                                 ****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
  FT_BASE_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
  FT_Raccess_Get_HeaderInfo( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
                             FT_Stream   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
                             FT_Long     rfork_offset,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
                             FT_Long    *map_offset,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
                             FT_Long    *rdata_pos )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
    FT_Error       error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
    unsigned char  head[16], head2[16];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
    FT_Long        map_pos, rdata_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
    int            allzeros, allmatch, i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
    FT_Long        type_list;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
    FT_UNUSED( library );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
    error = FT_Stream_Seek( stream, rfork_offset );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
    error = FT_Stream_Read( stream, (FT_Byte *)head, 16 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
    *rdata_pos = rfork_offset + ( ( head[0] << 24 ) |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
                                  ( head[1] << 16 ) |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
                                  ( head[2] <<  8 ) |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
                                    head[3]         );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
    map_pos    = rfork_offset + ( ( head[4] << 24 ) |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
                                  ( head[5] << 16 ) |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
                                  ( head[6] <<  8 ) |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
                                    head[7]         );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
    rdata_len = ( head[ 8] << 24 ) |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
                ( head[ 9] << 16 ) |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
                ( head[10] <<  8 ) |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
                  head[11];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
    /* map_len = head[12] .. head[15] */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
    if ( *rdata_pos + rdata_len != map_pos || map_pos == rfork_offset )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
      return FT_Err_Unknown_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
    error = FT_Stream_Seek( stream, map_pos );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
    head2[15] = (FT_Byte)( head[15] + 1 );       /* make it be different */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
    error = FT_Stream_Read( stream, (FT_Byte*)head2, 16 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
    allzeros = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
    allmatch = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
    for ( i = 0; i < 16; ++i )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
      if ( head2[i] != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
        allzeros = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
      if ( head2[i] != head[i] )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
        allmatch = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
    if ( !allzeros && !allmatch )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
      return FT_Err_Unknown_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
    /* If we have reached this point then it is probably a mac resource */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
    /* file.  Now, does it contain any interesting resources?           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
    /* Skip handle to next resource map, the file resource number, and  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
    /* attributes.                                                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
    (void)FT_STREAM_SKIP( 4        /* skip handle to next resource map */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
                          + 2      /* skip file resource number */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
                          + 2 );   /* skip attributes */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
    if ( FT_READ_USHORT( type_list ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
    if ( type_list == -1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
      return FT_Err_Unknown_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
    error = FT_Stream_Seek( stream, map_pos + type_list );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
    *map_offset = map_pos + type_list;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
    return FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
  static int
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
  ft_raccess_sort_ref_by_id( FT_RFork_Ref*  a,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
                             FT_RFork_Ref*  b )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
    if ( a->res_id < b->res_id )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
      return -1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
    else if ( a->res_id > b->res_id )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
      return 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
      return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
  FT_BASE_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
  FT_Raccess_Get_DataOffsets( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
                              FT_Stream   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
                              FT_Long     map_offset,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
                              FT_Long     rdata_pos,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
                              FT_Long     tag,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
                              FT_Long   **offsets,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
                              FT_Long    *count )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
    FT_Error      error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
    int           i, j, cnt, subcnt;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
    FT_Long       tag_internal, rpos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
    FT_Memory     memory = library->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
    FT_Long       temp;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
    FT_Long       *offsets_internal;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
    FT_RFork_Ref  *ref;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
    error = FT_Stream_Seek( stream, map_offset );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
    if ( FT_READ_USHORT( cnt ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
    cnt++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
    for ( i = 0; i < cnt; ++i )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
      if ( FT_READ_LONG( tag_internal ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
           FT_READ_USHORT( subcnt )     ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
           FT_READ_USHORT( rpos )       )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
        return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
      FT_TRACE2(( "Resource tags: %c%c%c%c\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
                  (char)( 0xff & ( tag_internal >> 24 ) ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
                  (char)( 0xff & ( tag_internal >> 16 ) ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
                  (char)( 0xff & ( tag_internal >>  8 ) ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
                  (char)( 0xff & ( tag_internal >>  0 ) ) ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
      if ( tag_internal == tag )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
        *count = subcnt + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
        rpos  += map_offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
        error = FT_Stream_Seek( stream, rpos );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
        if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
          return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
        if ( FT_NEW_ARRAY( ref, *count ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
          return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
        for ( j = 0; j < *count; ++j )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
          if ( FT_READ_USHORT( ref[j].res_id ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
            goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
          if ( FT_STREAM_SKIP( 2 ) ) /* resource name */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
            goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
          if ( FT_READ_LONG( temp ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
            goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
          if ( FT_STREAM_SKIP( 4 ) ) /* mbz */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   208
            goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
          ref[j].offset = temp & 0xFFFFFFL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
        ft_qsort( ref, *count, sizeof ( FT_RFork_Ref ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
                  ( int(*)(const void*, const void*) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
                  ft_raccess_sort_ref_by_id );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
        if ( FT_NEW_ARRAY( offsets_internal, *count ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
          goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
        /* XXX: duplicated reference ID,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
         *      gap between reference IDs are acceptable?
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
         *      further investigation on Apple implementation is needed.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
        for ( j = 0; j < *count; ++j )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
          offsets_internal[j] = rdata_pos + ref[j].offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
        *offsets = offsets_internal;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
        error    = FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
      Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
        FT_FREE( ref );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
        return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
    return FT_Err_Cannot_Open_Resource;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
  /****                                                                 ****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
  /****                                                                 ****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
  /****                     Guessing functions                          ****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
  /****                                                                 ****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
  /****            When you add a new guessing function,                ****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
  /****           update FT_RACCESS_N_RULES in ftrfork.h.               ****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
  /****                                                                 ****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
  typedef FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
  (*raccess_guess_func)( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
                         FT_Stream   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
                         char       *base_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
                         char      **result_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
                         FT_Long    *result_offset );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
  raccess_guess_apple_double( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
                              FT_Stream   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
                              char       *base_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
                              char      **result_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
                              FT_Long    *result_offset );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
  raccess_guess_apple_single( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
                              FT_Stream   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
                              char       *base_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
                              char      **result_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
                              FT_Long    *result_offset );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
  raccess_guess_darwin_ufs_export( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
                                   FT_Stream   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
                                   char       *base_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
                                   char      **result_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
                                   FT_Long    *result_offset );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
  raccess_guess_darwin_newvfs( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
                               FT_Stream   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
                               char       *base_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
                               char      **result_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
                               FT_Long    *result_offset );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
  raccess_guess_darwin_hfsplus( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
                                FT_Stream   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
                                char       *base_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
                                char      **result_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
                                FT_Long    *result_offset );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
  raccess_guess_vfat( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   301
                      FT_Stream   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   302
                      char       *base_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   303
                      char      **result_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
                      FT_Long    *result_offset );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
  raccess_guess_linux_cap( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
                           FT_Stream   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
                           char       *base_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
                           char      **result_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   311
                           FT_Long    *result_offset );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   312
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
  raccess_guess_linux_double( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
                              FT_Stream   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
                              char       *base_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
                              char      **result_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
                              FT_Long    *result_offset );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
  raccess_guess_linux_netatalk( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
                                FT_Stream   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
                                char       *base_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
                                char      **result_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
                                FT_Long    *result_offset );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
  /****                                                                 ****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
  /****                       Helper functions                          ****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
  /****                                                                 ****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   333
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
  raccess_guess_apple_generic( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
                               FT_Stream   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   337
                               char       *base_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   338
                               FT_Int32    magic,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   339
                               FT_Long    *result_offset );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
  raccess_guess_linux_double_from_file_name( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
                                             char *      file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
                                             FT_Long    *result_offset );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
  static char *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
  raccess_make_file_name( FT_Memory    memory,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
                          const char  *original_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
                          const char  *insertion );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
  typedef enum  FT_RFork_Rule_ {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
    FT_RFork_Rule_invalid = -2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
    FT_RFork_Rule_uknown, /* -1 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
    FT_RFork_Rule_apple_double,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
    FT_RFork_Rule_apple_single,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   357
    FT_RFork_Rule_darwin_ufs_export,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
    FT_RFork_Rule_darwin_newvfs,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
    FT_RFork_Rule_darwin_hfsplus,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
    FT_RFork_Rule_vfat,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
    FT_RFork_Rule_linux_cap,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
    FT_RFork_Rule_linux_double,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
    FT_RFork_Rule_linux_netatalk
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
  } FT_RFork_Rule;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
  /* For fast translation between rule index and rule type,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
   * the macros FT_RFORK_xxx should be kept consistent with
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
   * the raccess_guess_funcs table
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   370
  typedef struct raccess_guess_rec_ {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
    raccess_guess_func  func;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
    FT_RFork_Rule       type;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
  } raccess_guess_rec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   375
  static raccess_guess_rec  raccess_guess_table[FT_RACCESS_N_RULES] =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
    { raccess_guess_apple_double,	FT_RFork_Rule_apple_double, },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
    { raccess_guess_apple_single,	FT_RFork_Rule_apple_single, },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
    { raccess_guess_darwin_ufs_export,	FT_RFork_Rule_darwin_ufs_export, },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
    { raccess_guess_darwin_newvfs,	FT_RFork_Rule_darwin_newvfs, },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
    { raccess_guess_darwin_hfsplus,	FT_RFork_Rule_darwin_hfsplus, },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
    { raccess_guess_vfat,		FT_RFork_Rule_vfat, },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
    { raccess_guess_linux_cap,		FT_RFork_Rule_linux_cap, },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
    { raccess_guess_linux_double,	FT_RFork_Rule_linux_double, },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
    { raccess_guess_linux_netatalk,	FT_RFork_Rule_linux_netatalk, },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   388
  FT_BASE_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   389
  FT_Raccess_Guess( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   390
                    FT_Stream   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
                    char*       base_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   392
                    char      **new_names,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   393
                    FT_Long    *offsets,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   394
                    FT_Error   *errors )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   395
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   396
    FT_Long  i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   399
    for ( i = 0; i < FT_RACCESS_N_RULES; i++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   400
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
      new_names[i] = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
      if ( NULL != stream )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   403
        errors[i] = FT_Stream_Seek( stream, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   404
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   405
        errors[i] = FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   406
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
      if ( errors[i] )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
        continue ;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   410
      errors[i] = (raccess_guess_table[i].func)( library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   411
                                                 stream, base_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
                                                 &(new_names[i]),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   413
                                                 &(offsets[i]) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   414
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   415
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
    return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   420
  static FT_RFork_Rule
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   421
  raccess_get_rule_type_from_rule_index( FT_UInt  rule_index )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   422
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   423
    if ( rule_index >= FT_RACCESS_N_RULES )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   424
      return FT_RFork_Rule_invalid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   425
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   426
    return raccess_guess_table[rule_index].type;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   427
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   428
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   429
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   430
  FT_LOCAL_DEF( FT_Bool )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   431
  raccess_rule_by_darwin_vfs( FT_UInt  rule_index )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   432
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   433
    switch( raccess_get_rule_type_from_rule_index( rule_index ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   434
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   435
      case FT_RFork_Rule_darwin_newvfs:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   436
      case FT_RFork_Rule_darwin_hfsplus:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   437
        return TRUE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   439
      default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   440
        return FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   441
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   442
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   443
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   444
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   445
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
  raccess_guess_apple_double( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
                              FT_Stream   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   448
                              char       *base_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   449
                              char      **result_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   450
                              FT_Long    *result_offset )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   451
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   452
    FT_Int32  magic = ( 0x00 << 24 ) |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   453
                      ( 0x05 << 16 ) |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   454
                      ( 0x16 <<  8 ) |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   455
                        0x07;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   456
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   457
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   458
    *result_file_name = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   459
    if ( NULL == stream )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   460
      return FT_Err_Cannot_Open_Stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   461
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   462
    return raccess_guess_apple_generic( library, stream, base_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   463
                                        magic, result_offset );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   464
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   465
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   466
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   467
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   468
  raccess_guess_apple_single( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   469
                              FT_Stream   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   470
                              char       *base_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   471
                              char      **result_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   472
                              FT_Long    *result_offset )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   473
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   474
    FT_Int32  magic = ( 0x00 << 24 ) |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   475
                      ( 0x05 << 16 ) |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   476
                      ( 0x16 <<  8 ) |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   477
                        0x00;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   478
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   479
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   480
    *result_file_name = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   481
    if ( NULL == stream )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   482
      return FT_Err_Cannot_Open_Stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   483
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   484
    return raccess_guess_apple_generic( library, stream, base_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   485
                                        magic, result_offset );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   486
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   487
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   488
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   489
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   490
  raccess_guess_darwin_ufs_export( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   491
                                   FT_Stream   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   492
                                   char       *base_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   493
                                   char      **result_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   494
                                   FT_Long    *result_offset )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   495
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   496
    char*      newpath;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   497
    FT_Error   error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   498
    FT_Memory  memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   499
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   500
    FT_UNUSED( stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   501
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   502
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   503
    memory  = library->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   504
    newpath = raccess_make_file_name( memory, base_file_name, "._" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   505
    if ( !newpath )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   506
      return FT_Err_Out_Of_Memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   507
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   508
    error = raccess_guess_linux_double_from_file_name( library, newpath,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   509
                                                       result_offset );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   510
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   511
      *result_file_name = newpath;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   512
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   513
      FT_FREE( newpath );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   514
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   515
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   516
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   517
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   518
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   519
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   520
  raccess_guess_darwin_hfsplus( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   521
                                FT_Stream   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   522
                                char       *base_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   523
                                char      **result_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   524
                                FT_Long    *result_offset )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   525
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   526
    /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   527
      Only meaningful on systems with hfs+ drivers (or Macs).
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   528
     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   529
    FT_Error   error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   530
    char*      newpath;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   531
    FT_Memory  memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   532
    FT_Long    base_file_len = ft_strlen( base_file_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   533
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   534
    FT_UNUSED( stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   535
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   536
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   537
    memory = library->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   538
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   539
    if ( base_file_len + 6 > FT_INT_MAX )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   540
      return FT_Err_Array_Too_Large;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   541
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   542
    if ( FT_ALLOC( newpath, base_file_len + 6 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   543
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   544
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   545
    FT_MEM_COPY( newpath, base_file_name, base_file_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   546
    FT_MEM_COPY( newpath + base_file_len, "/rsrc", 6 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   547
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   548
    *result_file_name = newpath;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   549
    *result_offset    = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   550
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   551
    return FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   552
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   553
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   554
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   555
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   556
  raccess_guess_darwin_newvfs( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   557
                               FT_Stream   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   558
                               char       *base_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   559
                               char      **result_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   560
                               FT_Long    *result_offset )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   561
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   562
    /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   563
      Only meaningful on systems with Mac OS X (> 10.1).
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   564
     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   565
    FT_Error   error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   566
    char*      newpath;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   567
    FT_Memory  memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   568
    FT_Long    base_file_len = ft_strlen( base_file_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   569
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   570
    FT_UNUSED( stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   571
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   572
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   573
    memory = library->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   574
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   575
    if ( base_file_len + 18 > FT_INT_MAX )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   576
      return FT_Err_Array_Too_Large;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   577
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   578
    if ( FT_ALLOC( newpath, base_file_len + 18 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   579
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   580
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   581
    FT_MEM_COPY( newpath, base_file_name, base_file_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   582
    FT_MEM_COPY( newpath + base_file_len, "/..namedfork/rsrc", 18 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   583
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   584
    *result_file_name = newpath;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   585
    *result_offset    = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   586
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   587
    return FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   588
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   589
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   590
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   591
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   592
  raccess_guess_vfat( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   593
                      FT_Stream   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   594
                      char       *base_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   595
                      char      **result_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   596
                      FT_Long    *result_offset )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   597
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   598
    char*      newpath;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   599
    FT_Memory  memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   600
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   601
    FT_UNUSED( stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   602
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   603
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   604
    memory = library->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   605
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   606
    newpath = raccess_make_file_name( memory, base_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   607
                                      "resource.frk/" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   608
    if ( !newpath )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   609
      return FT_Err_Out_Of_Memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   610
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   611
    *result_file_name = newpath;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   612
    *result_offset    = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   613
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   614
    return FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   615
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   616
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   617
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   618
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   619
  raccess_guess_linux_cap( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   620
                           FT_Stream   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   621
                           char       *base_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   622
                           char      **result_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   623
                           FT_Long    *result_offset )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   624
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   625
    char*      newpath;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   626
    FT_Memory  memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   627
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   628
    FT_UNUSED( stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   629
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   630
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   631
    memory = library->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   632
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   633
    newpath = raccess_make_file_name( memory, base_file_name, ".resource/" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   634
    if ( !newpath )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   635
      return FT_Err_Out_Of_Memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   636
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   637
    *result_file_name = newpath;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   638
    *result_offset    = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   639
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   640
    return FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   641
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   642
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   643
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   644
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   645
  raccess_guess_linux_double( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   646
                              FT_Stream   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   647
                              char       *base_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   648
                              char      **result_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   649
                              FT_Long    *result_offset )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   650
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   651
    char*      newpath;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   652
    FT_Error   error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   653
    FT_Memory  memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   654
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   655
    FT_UNUSED( stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   656
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   657
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   658
    memory = library->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   659
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   660
    newpath = raccess_make_file_name( memory, base_file_name, "%" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   661
    if ( !newpath )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   662
      return FT_Err_Out_Of_Memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   663
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   664
    error = raccess_guess_linux_double_from_file_name( library, newpath,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   665
                                                       result_offset );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   666
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   667
      *result_file_name = newpath;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   668
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   669
      FT_FREE( newpath );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   670
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   671
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   672
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   673
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   674
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   675
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   676
  raccess_guess_linux_netatalk( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   677
                                FT_Stream   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   678
                                char       *base_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   679
                                char      **result_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   680
                                FT_Long    *result_offset )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   681
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   682
    char*      newpath;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   683
    FT_Error   error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   684
    FT_Memory  memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   685
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   686
    FT_UNUSED( stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   687
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   688
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   689
    memory = library->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   690
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   691
    newpath = raccess_make_file_name( memory, base_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   692
                                      ".AppleDouble/" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   693
    if ( !newpath )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   694
      return FT_Err_Out_Of_Memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   695
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   696
    error = raccess_guess_linux_double_from_file_name( library, newpath,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   697
                                                       result_offset );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   698
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   699
      *result_file_name = newpath;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   700
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   701
      FT_FREE( newpath );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   702
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   703
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   704
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   705
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   706
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   707
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   708
  raccess_guess_apple_generic( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   709
                               FT_Stream   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   710
                               char       *base_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   711
                               FT_Int32    magic,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   712
                               FT_Long    *result_offset )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   713
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   714
    FT_Int32   magic_from_stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   715
    FT_Error   error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   716
    FT_Int32   version_number = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   717
    FT_UShort  n_of_entries;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   718
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   719
    int        i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   720
    FT_UInt32  entry_id, entry_offset, entry_length = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   721
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   722
    const FT_UInt32  resource_fork_entry_id = 0x2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   723
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   724
    FT_UNUSED( library );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   725
    FT_UNUSED( base_file_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   726
    FT_UNUSED( version_number );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   727
    FT_UNUSED( entry_length   );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   728
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   729
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   730
    if ( FT_READ_LONG( magic_from_stream ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   731
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   732
    if ( magic_from_stream != magic )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   733
      return FT_Err_Unknown_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   734
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   735
    if ( FT_READ_LONG( version_number ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   736
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   737
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   738
    /* filler */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   739
    error = FT_Stream_Skip( stream, 16 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   740
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   741
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   742
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   743
    if ( FT_READ_USHORT( n_of_entries ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   744
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   745
    if ( n_of_entries == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   746
      return FT_Err_Unknown_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   747
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   748
    for ( i = 0; i < n_of_entries; i++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   749
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   750
      if ( FT_READ_LONG( entry_id ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   751
        return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   752
      if ( entry_id == resource_fork_entry_id )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   753
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   754
        if ( FT_READ_LONG( entry_offset ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   755
             FT_READ_LONG( entry_length ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   756
          continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   757
        *result_offset = entry_offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   758
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   759
        return FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   760
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   761
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   762
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   763
        error = FT_Stream_Skip( stream, 4 + 4 );    /* offset + length */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   764
        if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   765
          return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   766
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   767
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   768
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   769
    return FT_Err_Unknown_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   770
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   771
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   772
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   773
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   774
  raccess_guess_linux_double_from_file_name( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   775
                                             char       *file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   776
                                             FT_Long    *result_offset )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   777
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   778
    FT_Open_Args  args2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   779
    FT_Stream     stream2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   780
    char *        nouse = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   781
    FT_Error      error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   782
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   783
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   784
    args2.flags    = FT_OPEN_PATHNAME;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   785
    args2.pathname = file_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   786
    error = FT_Stream_New( library, &args2, &stream2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   787
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   788
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   789
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   790
    error = raccess_guess_apple_double( library, stream2, file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   791
                                        &nouse, result_offset );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   792
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   793
    FT_Stream_Free( stream2, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   794
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   795
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   796
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   797
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   798
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   799
  static char*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   800
  raccess_make_file_name( FT_Memory    memory,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   801
                          const char  *original_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   802
                          const char  *insertion )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   803
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   804
    char*        new_name = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   805
    const char*  tmp;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   806
    const char*  slash;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   807
    size_t       new_length;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   808
    FT_Error     error = FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   809
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   810
    FT_UNUSED( error );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   811
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   812
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   813
    new_length = ft_strlen( original_name ) + ft_strlen( insertion );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   814
    if ( FT_ALLOC( new_name, new_length + 1 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   815
      return NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   816
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   817
    tmp = ft_strrchr( original_name, '/' );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   818
    if ( tmp )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   819
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   820
      ft_strncpy( new_name, original_name, tmp - original_name + 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   821
      new_name[tmp - original_name + 1] = '\0';
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   822
      slash = tmp + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   823
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   824
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   825
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   826
      slash       = original_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   827
      new_name[0] = '\0';
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   828
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   829
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   830
    ft_strcat( new_name, insertion );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   831
    ft_strcat( new_name, slash );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   832
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   833
    return new_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   834
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   835
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   836
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   837
#else   /* !FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   838
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   839
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   840
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   841
  /*                  Dummy function; just sets errors                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   842
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   843
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   844
  FT_BASE_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   845
  FT_Raccess_Guess( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   846
                    FT_Stream   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   847
                    char       *base_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   848
                    char      **new_names,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   849
                    FT_Long    *offsets,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   850
                    FT_Error   *errors )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   851
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   852
    int  i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   853
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   854
    FT_UNUSED( library );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   855
    FT_UNUSED( stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   856
    FT_UNUSED( base_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   857
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   858
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   859
    for ( i = 0; i < FT_RACCESS_N_RULES; i++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   860
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   861
      new_names[i] = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   862
      offsets[i]   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   863
      errors[i]    = FT_Err_Unimplemented_Feature;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   864
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   865
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   866
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   867
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   868
#endif  /* !FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   869
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   870
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   871
/* END */