1 /***************************************************************************/
2 /*                                                                         */
3 /*  ftrfork.h                                                              */
4 /*                                                                         */
5 /*    Embedded resource forks accessor (specification).                    */
6 /*                                                                         */
7 /*  Copyright 2004, 2006, 2007 by                                          */
8 /*  Masatake YAMATO and Redhat K.K.                                        */
9 /*                                                                         */
10 /*  This file is part of the FreeType project, and may only be used,       */
11 /*  modified, and distributed under the terms of the FreeType project      */
12 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
13 /*  this file you indicate that you have read the license and              */
14 /*  understand and accept it fully.                                        */
15 /*                                                                         */
16 /***************************************************************************/
17 
18 /***************************************************************************/
19 /* Development of the code in this file is support of                      */
20 /* Information-technology Promotion Agency, Japan.                         */
21 /***************************************************************************/
22 
23 
24 #ifndef __FTRFORK_H__
25 #define __FTRFORK_H__
26 
27 
28 #include <ft2build.h>
29 #include FT_INTERNAL_OBJECTS_H
30 
31 
32 FT_BEGIN_HEADER
33 
34 
35   /* Number of guessing rules supported in `FT_Raccess_Guess'.            */
36   /* Don't forget to increment the number if you add a new guessing rule. */
37 #define FT_RACCESS_N_RULES  9
38 
39 
40   /* A structure to describe a reference in a resource by its resource ID */
41   /* and internal offset.  The `POST' resource expects to be concatenated */
42   /* by the order of resource IDs instead of its appearance in the file.  */
43 
44   typedef struct  FT_RFork_Ref_
45   {
46     FT_UShort  res_id;
47     FT_ULong   offset;
48 
49   } FT_RFork_Ref;
50 
51 
52   /*************************************************************************/
53   /*                                                                       */
54   /* <Function>                                                            */
55   /*    FT_Raccess_Guess                                                   */
56   /*                                                                       */
57   /* <Description>                                                         */
58   /*    Guess a file name and offset where the actual resource fork is     */
59   /*    stored.  The macro FT_RACCESS_N_RULES holds the number of          */
60   /*    guessing rules;  the guessed result for the Nth rule is            */
61   /*    represented as a triplet: a new file name (new_names[N]), a file   */
62   /*    offset (offsets[N]), and an error code (errors[N]).                */
63   /*                                                                       */
64   /* <Input>                                                               */
65   /*    library ::                                                         */
66   /*      A FreeType library instance.                                     */
67   /*                                                                       */
68   /*    stream ::                                                          */
69   /*      A file stream containing the resource fork.                      */
70   /*                                                                       */
71   /*    base_name ::                                                       */
72   /*      The (base) file name of the resource fork used for some          */
73   /*      guessing rules.                                                  */
74   /*                                                                       */
75   /* <Output>                                                              */
76   /*    new_names ::                                                       */
77   /*      An array of guessed file names in which the resource forks may   */
78   /*      exist.  If `new_names[N]' is NULL, the guessed file name is      */
79   /*      equal to `base_name'.                                            */
80   /*                                                                       */
81   /*    offsets ::                                                         */
82   /*      An array of guessed file offsets.  `offsets[N]' holds the file   */
83   /*      offset of the possible start of the resource fork in file        */
84   /*      `new_names[N]'.                                                  */
85   /*                                                                       */
86   /*    errors ::                                                          */
87   /*      An array of FreeType error codes.  `errors[N]' is the error      */
88   /*      code of Nth guessing rule function.  If `errors[N]' is not       */
89   /*      FT_Err_Ok, `new_names[N]' and `offsets[N]' are meaningless.      */
90   /*                                                                       */
91   FT_BASE( void )
92   FT_Raccess_Guess( FT_Library  library,
93                     FT_Stream   stream,
94                     char*       base_name,
95                     char**      new_names,
96                     FT_Long*    offsets,
97                     FT_Error*   errors );
98 
99 
100   /*************************************************************************/
101   /*                                                                       */
102   /* <Function>                                                            */
103   /*    FT_Raccess_Get_HeaderInfo                                          */
104   /*                                                                       */
105   /* <Description>                                                         */
106   /*    Get the information from the header of resource fork.  The         */
107   /*    information includes the file offset where the resource map        */
108   /*    starts, and the file offset where the resource data starts.        */
109   /*    `FT_Raccess_Get_DataOffsets' requires these two data.              */
110   /*                                                                       */
111   /* <Input>                                                               */
112   /*    library ::                                                         */
113   /*      A FreeType library instance.                                     */
114   /*                                                                       */
115   /*    stream ::                                                          */
116   /*      A file stream containing the resource fork.                      */
117   /*                                                                       */
118   /*    rfork_offset ::                                                    */
119   /*      The file offset where the resource fork starts.                  */
120   /*                                                                       */
121   /* <Output>                                                              */
122   /*    map_offset ::                                                      */
123   /*      The file offset where the resource map starts.                   */
124   /*                                                                       */
125   /*    rdata_pos ::                                                       */
126   /*      The file offset where the resource data starts.                  */
127   /*                                                                       */
128   /* <Return>                                                              */
129   /*    FreeType error code.  FT_Err_Ok means success.                     */
130   /*                                                                       */
131   FT_BASE( FT_Error )
132   FT_Raccess_Get_HeaderInfo( FT_Library  library,
133                              FT_Stream   stream,
134                              FT_Long     rfork_offset,
135                              FT_Long    *map_offset,
136                              FT_Long    *rdata_pos );
137 
138 
139   /*************************************************************************/
140   /*                                                                       */
141   /* <Function>                                                            */
142   /*    FT_Raccess_Get_DataOffsets                                         */
143   /*                                                                       */
144   /* <Description>                                                         */
145   /*    Get the data offsets for a tag in a resource fork.  Offsets are    */
146   /*    stored in an array because, in some cases, resources in a resource */
147   /*    fork have the same tag.                                            */
148   /*                                                                       */
149   /* <Input>                                                               */
150   /*    library ::                                                         */
151   /*      A FreeType library instance.                                     */
152   /*                                                                       */
153   /*    stream ::                                                          */
154   /*      A file stream containing the resource fork.                      */
155   /*                                                                       */
156   /*    map_offset ::                                                      */
157   /*      The file offset where the resource map starts.                   */
158   /*                                                                       */
159   /*    rdata_pos ::                                                       */
160   /*      The file offset where the resource data starts.                  */
161   /*                                                                       */
162   /*    tag ::                                                             */
163   /*      The resource tag.                                                */
164   /*                                                                       */
165   /* <Output>                                                              */
166   /*    offsets ::                                                         */
167   /*      The stream offsets for the resource data specified by `tag'.     */
168   /*      This array is allocated by the function, so you have to call     */
169   /*      @ft_mem_free after use.                                          */
170   /*                                                                       */
171   /*    count ::                                                           */
172   /*      The length of offsets array.                                     */
173   /*                                                                       */
174   /* <Return>                                                              */
175   /*    FreeType error code.  FT_Err_Ok means success.                     */
176   /*                                                                       */
177   /* <Note>                                                                */
178   /*    Normally you should use `FT_Raccess_Get_HeaderInfo' to get the     */
179   /*    value for `map_offset' and `rdata_pos'.                            */
180   /*                                                                       */
181   FT_BASE( FT_Error )
182   FT_Raccess_Get_DataOffsets( FT_Library  library,
183                               FT_Stream   stream,
184                               FT_Long     map_offset,
185                               FT_Long     rdata_pos,
186                               FT_Long     tag,
187                               FT_Long   **offsets,
188                               FT_Long    *count );
189 
190 
191 FT_END_HEADER
192 
193 #endif /* __FTRFORK_H__ */
194 
195 
196 /* END */
197