ReactOS  0.4.13-dev-982-g9853eab
ftrfork.h
Go to the documentation of this file.
1 /***************************************************************************/
2 /* */
3 /* ftrfork.h */
4 /* */
5 /* Embedded resource forks accessor (specification). */
6 /* */
7 /* Copyright 2004-2018 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 
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  {
48 
49  } FT_RFork_Ref;
50 
51 
52 #ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
53  typedef FT_Error
54  (*ft_raccess_guess_func)( FT_Library library,
56  char *base_file_name,
57  char **result_file_name,
58  FT_Long *result_offset );
59 
60  typedef enum FT_RFork_Rule_ {
61  FT_RFork_Rule_invalid = -2,
62  FT_RFork_Rule_uknown, /* -1 */
63  FT_RFork_Rule_apple_double,
64  FT_RFork_Rule_apple_single,
65  FT_RFork_Rule_darwin_ufs_export,
66  FT_RFork_Rule_darwin_newvfs,
67  FT_RFork_Rule_darwin_hfsplus,
68  FT_RFork_Rule_vfat,
69  FT_RFork_Rule_linux_cap,
70  FT_RFork_Rule_linux_double,
71  FT_RFork_Rule_linux_netatalk
72  } FT_RFork_Rule;
73 
74  /* For fast translation between rule index and rule type,
75  * the macros FT_RFORK_xxx should be kept consistent with
76  * the raccess_guess_funcs table
77  */
78  typedef struct ft_raccess_guess_rec_ {
79  ft_raccess_guess_func func;
80  FT_RFork_Rule type;
81  } ft_raccess_guess_rec;
82 
83 #ifndef FT_CONFIG_OPTION_PIC
84 
85  /* this array is a storage in non-PIC mode, so ; is needed in END */
86 #define CONST_FT_RFORK_RULE_ARRAY_BEGIN( name, type ) \
87  static const type name[] = {
88 #define CONST_FT_RFORK_RULE_ARRAY_ENTRY( func_suffix, type_suffix ) \
89  { raccess_guess_ ## func_suffix, \
90  FT_RFork_Rule_ ## type_suffix },
91 #define CONST_FT_RFORK_RULE_ARRAY_END };
92 
93 #else /* FT_CONFIG_OPTION_PIC */
94 
95  /* this array is a function in PIC mode, so no ; is needed in END */
96 #define CONST_FT_RFORK_RULE_ARRAY_BEGIN( name, type ) \
97  void \
98  FT_Init_Table_ ## name( type* storage ) \
99  { \
100  type* local = storage; \
101  \
102  \
103  int i = 0;
104 #define CONST_FT_RFORK_RULE_ARRAY_ENTRY( func_suffix, type_suffix ) \
105  local[i].func = raccess_guess_ ## func_suffix; \
106  local[i].type = FT_RFork_Rule_ ## type_suffix; \
107  i++;
108 #define CONST_FT_RFORK_RULE_ARRAY_END }
109 
110 #endif /* FT_CONFIG_OPTION_PIC */
111 
112 #endif /* FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK */
113 
114 
115  /*************************************************************************/
116  /* */
117  /* <Function> */
118  /* FT_Raccess_Guess */
119  /* */
120  /* <Description> */
121  /* Guess a file name and offset where the actual resource fork is */
122  /* stored. The macro FT_RACCESS_N_RULES holds the number of */
123  /* guessing rules; the guessed result for the Nth rule is */
124  /* represented as a triplet: a new file name (new_names[N]), a file */
125  /* offset (offsets[N]), and an error code (errors[N]). */
126  /* */
127  /* <Input> */
128  /* library :: */
129  /* A FreeType library instance. */
130  /* */
131  /* stream :: */
132  /* A file stream containing the resource fork. */
133  /* */
134  /* base_name :: */
135  /* The (base) file name of the resource fork used for some */
136  /* guessing rules. */
137  /* */
138  /* <Output> */
139  /* new_names :: */
140  /* An array of guessed file names in which the resource forks may */
141  /* exist. If `new_names[N]' is NULL, the guessed file name is */
142  /* equal to `base_name'. */
143  /* */
144  /* offsets :: */
145  /* An array of guessed file offsets. `offsets[N]' holds the file */
146  /* offset of the possible start of the resource fork in file */
147  /* `new_names[N]'. */
148  /* */
149  /* errors :: */
150  /* An array of FreeType error codes. `errors[N]' is the error */
151  /* code of Nth guessing rule function. If `errors[N]' is not */
152  /* FT_Err_Ok, `new_names[N]' and `offsets[N]' are meaningless. */
153  /* */
154  FT_BASE( void )
157  char* base_name,
158  char** new_names,
159  FT_Long* offsets,
160  FT_Error* errors );
161 
162 
163  /*************************************************************************/
164  /* */
165  /* <Function> */
166  /* FT_Raccess_Get_HeaderInfo */
167  /* */
168  /* <Description> */
169  /* Get the information from the header of resource fork. The */
170  /* information includes the file offset where the resource map */
171  /* starts, and the file offset where the resource data starts. */
172  /* `FT_Raccess_Get_DataOffsets' requires these two data. */
173  /* */
174  /* <Input> */
175  /* library :: */
176  /* A FreeType library instance. */
177  /* */
178  /* stream :: */
179  /* A file stream containing the resource fork. */
180  /* */
181  /* rfork_offset :: */
182  /* The file offset where the resource fork starts. */
183  /* */
184  /* <Output> */
185  /* map_offset :: */
186  /* The file offset where the resource map starts. */
187  /* */
188  /* rdata_pos :: */
189  /* The file offset where the resource data starts. */
190  /* */
191  /* <Return> */
192  /* FreeType error code. FT_Err_Ok means success. */
193  /* */
194  FT_BASE( FT_Error )
197  FT_Long rfork_offset,
198  FT_Long *map_offset,
199  FT_Long *rdata_pos );
200 
201 
202  /*************************************************************************/
203  /* */
204  /* <Function> */
205  /* FT_Raccess_Get_DataOffsets */
206  /* */
207  /* <Description> */
208  /* Get the data offsets for a tag in a resource fork. Offsets are */
209  /* stored in an array because, in some cases, resources in a resource */
210  /* fork have the same tag. */
211  /* */
212  /* <Input> */
213  /* library :: */
214  /* A FreeType library instance. */
215  /* */
216  /* stream :: */
217  /* A file stream containing the resource fork. */
218  /* */
219  /* map_offset :: */
220  /* The file offset where the resource map starts. */
221  /* */
222  /* rdata_pos :: */
223  /* The file offset where the resource data starts. */
224  /* */
225  /* tag :: */
226  /* The resource tag. */
227  /* */
228  /* sort_by_res_id :: */
229  /* A Boolean to sort the fragmented resource by their ids. */
230  /* The fragmented resources for `POST' resource should be sorted */
231  /* to restore Type1 font properly. For `sfnt' resources, sorting */
232  /* may induce a different order of the faces in comparison to that */
233  /* by QuickDraw API. */
234  /* */
235  /* <Output> */
236  /* offsets :: */
237  /* The stream offsets for the resource data specified by `tag'. */
238  /* This array is allocated by the function, so you have to call */
239  /* @ft_mem_free after use. */
240  /* */
241  /* count :: */
242  /* The length of offsets array. */
243  /* */
244  /* <Return> */
245  /* FreeType error code. FT_Err_Ok means success. */
246  /* */
247  /* <Note> */
248  /* Normally you should use `FT_Raccess_Get_HeaderInfo' to get the */
249  /* value for `map_offset' and `rdata_pos'. */
250  /* */
251  FT_BASE( FT_Error )
254  FT_Long map_offset,
255  FT_Long rdata_pos,
256  FT_Long tag,
257  FT_Bool sort_by_res_id,
258  FT_Long **offsets,
259  FT_Long *count );
260 
261 
263 
264 #endif /* FTRFORK_H_ */
265 
266 
267 /* END */
GLenum func
Definition: glext.h:6028
int FT_Error
Definition: fttypes.h:300
signed long FT_Long
Definition: fttypes.h:242
#define FT_END_HEADER
Definition: ftheader.h:54
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
Definition: ecma_167.h:138
FT_Library library
Definition: cffdrivr.c:654
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
#define FT_BEGIN_HEADER
Definition: ftheader.h:36
FT_Long offset
Definition: ftrfork.h:47
struct FT_RFork_Ref_ FT_RFork_Ref
FT_Raccess_Get_DataOffsets(FT_Library library, FT_Stream stream, FT_Long map_offset, FT_Long rdata_pos, FT_Long tag, FT_Bool sort_by_res_id, FT_Long **offsets, FT_Long *count)
Definition: ftrfork.c:185
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
signed short FT_Short
Definition: fttypes.h:198
#define FT_BASE(x)
Definition: ftconfig.h:408
FT_Raccess_Guess(FT_Library library, FT_Stream stream, char *base_name, char **new_names, FT_Long *offsets, FT_Error *errors)
Definition: ftrfork.c:917
FT_Short res_id
Definition: ftrfork.h:46
FT_Raccess_Get_HeaderInfo(FT_Library library, FT_Stream stream, FT_Long rfork_offset, FT_Long *map_offset, FT_Long *rdata_pos)
Definition: ftrfork.c:51