rev |
line source |
nuclear@0
|
1 /***************************************************************************/
|
nuclear@0
|
2 /* */
|
nuclear@0
|
3 /* ftsystem.h */
|
nuclear@0
|
4 /* */
|
nuclear@0
|
5 /* FreeType low-level system interface definition (specification). */
|
nuclear@0
|
6 /* */
|
nuclear@0
|
7 /* Copyright 1996-2001, 2002, 2005, 2010 by */
|
nuclear@0
|
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
nuclear@0
|
9 /* */
|
nuclear@0
|
10 /* This file is part of the FreeType project, and may only be used, */
|
nuclear@0
|
11 /* modified, and distributed under the terms of the FreeType project */
|
nuclear@0
|
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
nuclear@0
|
13 /* this file you indicate that you have read the license and */
|
nuclear@0
|
14 /* understand and accept it fully. */
|
nuclear@0
|
15 /* */
|
nuclear@0
|
16 /***************************************************************************/
|
nuclear@0
|
17
|
nuclear@0
|
18
|
nuclear@0
|
19 #ifndef __FTSYSTEM_H__
|
nuclear@0
|
20 #define __FTSYSTEM_H__
|
nuclear@0
|
21
|
nuclear@0
|
22
|
nuclear@0
|
23 #include <ft2build.h>
|
nuclear@0
|
24
|
nuclear@0
|
25
|
nuclear@0
|
26 FT_BEGIN_HEADER
|
nuclear@0
|
27
|
nuclear@0
|
28
|
nuclear@0
|
29 /*************************************************************************/
|
nuclear@0
|
30 /* */
|
nuclear@0
|
31 /* <Section> */
|
nuclear@0
|
32 /* system_interface */
|
nuclear@0
|
33 /* */
|
nuclear@0
|
34 /* <Title> */
|
nuclear@0
|
35 /* System Interface */
|
nuclear@0
|
36 /* */
|
nuclear@0
|
37 /* <Abstract> */
|
nuclear@0
|
38 /* How FreeType manages memory and i/o. */
|
nuclear@0
|
39 /* */
|
nuclear@0
|
40 /* <Description> */
|
nuclear@0
|
41 /* This section contains various definitions related to memory */
|
nuclear@0
|
42 /* management and i/o access. You need to understand this */
|
nuclear@0
|
43 /* information if you want to use a custom memory manager or you own */
|
nuclear@0
|
44 /* i/o streams. */
|
nuclear@0
|
45 /* */
|
nuclear@0
|
46 /*************************************************************************/
|
nuclear@0
|
47
|
nuclear@0
|
48
|
nuclear@0
|
49 /*************************************************************************/
|
nuclear@0
|
50 /* */
|
nuclear@0
|
51 /* M E M O R Y M A N A G E M E N T */
|
nuclear@0
|
52 /* */
|
nuclear@0
|
53 /*************************************************************************/
|
nuclear@0
|
54
|
nuclear@0
|
55
|
nuclear@0
|
56 /*************************************************************************
|
nuclear@0
|
57 *
|
nuclear@0
|
58 * @type:
|
nuclear@0
|
59 * FT_Memory
|
nuclear@0
|
60 *
|
nuclear@0
|
61 * @description:
|
nuclear@0
|
62 * A handle to a given memory manager object, defined with an
|
nuclear@0
|
63 * @FT_MemoryRec structure.
|
nuclear@0
|
64 *
|
nuclear@0
|
65 */
|
nuclear@0
|
66 typedef struct FT_MemoryRec_* FT_Memory;
|
nuclear@0
|
67
|
nuclear@0
|
68
|
nuclear@0
|
69 /*************************************************************************
|
nuclear@0
|
70 *
|
nuclear@0
|
71 * @functype:
|
nuclear@0
|
72 * FT_Alloc_Func
|
nuclear@0
|
73 *
|
nuclear@0
|
74 * @description:
|
nuclear@0
|
75 * A function used to allocate `size' bytes from `memory'.
|
nuclear@0
|
76 *
|
nuclear@0
|
77 * @input:
|
nuclear@0
|
78 * memory ::
|
nuclear@0
|
79 * A handle to the source memory manager.
|
nuclear@0
|
80 *
|
nuclear@0
|
81 * size ::
|
nuclear@0
|
82 * The size in bytes to allocate.
|
nuclear@0
|
83 *
|
nuclear@0
|
84 * @return:
|
nuclear@0
|
85 * Address of new memory block. 0~in case of failure.
|
nuclear@0
|
86 *
|
nuclear@0
|
87 */
|
nuclear@0
|
88 typedef void*
|
nuclear@0
|
89 (*FT_Alloc_Func)( FT_Memory memory,
|
nuclear@0
|
90 long size );
|
nuclear@0
|
91
|
nuclear@0
|
92
|
nuclear@0
|
93 /*************************************************************************
|
nuclear@0
|
94 *
|
nuclear@0
|
95 * @functype:
|
nuclear@0
|
96 * FT_Free_Func
|
nuclear@0
|
97 *
|
nuclear@0
|
98 * @description:
|
nuclear@0
|
99 * A function used to release a given block of memory.
|
nuclear@0
|
100 *
|
nuclear@0
|
101 * @input:
|
nuclear@0
|
102 * memory ::
|
nuclear@0
|
103 * A handle to the source memory manager.
|
nuclear@0
|
104 *
|
nuclear@0
|
105 * block ::
|
nuclear@0
|
106 * The address of the target memory block.
|
nuclear@0
|
107 *
|
nuclear@0
|
108 */
|
nuclear@0
|
109 typedef void
|
nuclear@0
|
110 (*FT_Free_Func)( FT_Memory memory,
|
nuclear@0
|
111 void* block );
|
nuclear@0
|
112
|
nuclear@0
|
113
|
nuclear@0
|
114 /*************************************************************************
|
nuclear@0
|
115 *
|
nuclear@0
|
116 * @functype:
|
nuclear@0
|
117 * FT_Realloc_Func
|
nuclear@0
|
118 *
|
nuclear@0
|
119 * @description:
|
nuclear@0
|
120 * A function used to re-allocate a given block of memory.
|
nuclear@0
|
121 *
|
nuclear@0
|
122 * @input:
|
nuclear@0
|
123 * memory ::
|
nuclear@0
|
124 * A handle to the source memory manager.
|
nuclear@0
|
125 *
|
nuclear@0
|
126 * cur_size ::
|
nuclear@0
|
127 * The block's current size in bytes.
|
nuclear@0
|
128 *
|
nuclear@0
|
129 * new_size ::
|
nuclear@0
|
130 * The block's requested new size.
|
nuclear@0
|
131 *
|
nuclear@0
|
132 * block ::
|
nuclear@0
|
133 * The block's current address.
|
nuclear@0
|
134 *
|
nuclear@0
|
135 * @return:
|
nuclear@0
|
136 * New block address. 0~in case of memory shortage.
|
nuclear@0
|
137 *
|
nuclear@0
|
138 * @note:
|
nuclear@0
|
139 * In case of error, the old block must still be available.
|
nuclear@0
|
140 *
|
nuclear@0
|
141 */
|
nuclear@0
|
142 typedef void*
|
nuclear@0
|
143 (*FT_Realloc_Func)( FT_Memory memory,
|
nuclear@0
|
144 long cur_size,
|
nuclear@0
|
145 long new_size,
|
nuclear@0
|
146 void* block );
|
nuclear@0
|
147
|
nuclear@0
|
148
|
nuclear@0
|
149 /*************************************************************************
|
nuclear@0
|
150 *
|
nuclear@0
|
151 * @struct:
|
nuclear@0
|
152 * FT_MemoryRec
|
nuclear@0
|
153 *
|
nuclear@0
|
154 * @description:
|
nuclear@0
|
155 * A structure used to describe a given memory manager to FreeType~2.
|
nuclear@0
|
156 *
|
nuclear@0
|
157 * @fields:
|
nuclear@0
|
158 * user ::
|
nuclear@0
|
159 * A generic typeless pointer for user data.
|
nuclear@0
|
160 *
|
nuclear@0
|
161 * alloc ::
|
nuclear@0
|
162 * A pointer type to an allocation function.
|
nuclear@0
|
163 *
|
nuclear@0
|
164 * free ::
|
nuclear@0
|
165 * A pointer type to an memory freeing function.
|
nuclear@0
|
166 *
|
nuclear@0
|
167 * realloc ::
|
nuclear@0
|
168 * A pointer type to a reallocation function.
|
nuclear@0
|
169 *
|
nuclear@0
|
170 */
|
nuclear@0
|
171 struct FT_MemoryRec_
|
nuclear@0
|
172 {
|
nuclear@0
|
173 void* user;
|
nuclear@0
|
174 FT_Alloc_Func alloc;
|
nuclear@0
|
175 FT_Free_Func free;
|
nuclear@0
|
176 FT_Realloc_Func realloc;
|
nuclear@0
|
177 };
|
nuclear@0
|
178
|
nuclear@0
|
179
|
nuclear@0
|
180 /*************************************************************************/
|
nuclear@0
|
181 /* */
|
nuclear@0
|
182 /* I / O M A N A G E M E N T */
|
nuclear@0
|
183 /* */
|
nuclear@0
|
184 /*************************************************************************/
|
nuclear@0
|
185
|
nuclear@0
|
186
|
nuclear@0
|
187 /*************************************************************************
|
nuclear@0
|
188 *
|
nuclear@0
|
189 * @type:
|
nuclear@0
|
190 * FT_Stream
|
nuclear@0
|
191 *
|
nuclear@0
|
192 * @description:
|
nuclear@0
|
193 * A handle to an input stream.
|
nuclear@0
|
194 *
|
nuclear@0
|
195 */
|
nuclear@0
|
196 typedef struct FT_StreamRec_* FT_Stream;
|
nuclear@0
|
197
|
nuclear@0
|
198
|
nuclear@0
|
199 /*************************************************************************
|
nuclear@0
|
200 *
|
nuclear@0
|
201 * @struct:
|
nuclear@0
|
202 * FT_StreamDesc
|
nuclear@0
|
203 *
|
nuclear@0
|
204 * @description:
|
nuclear@0
|
205 * A union type used to store either a long or a pointer. This is used
|
nuclear@0
|
206 * to store a file descriptor or a `FILE*' in an input stream.
|
nuclear@0
|
207 *
|
nuclear@0
|
208 */
|
nuclear@0
|
209 typedef union FT_StreamDesc_
|
nuclear@0
|
210 {
|
nuclear@0
|
211 long value;
|
nuclear@0
|
212 void* pointer;
|
nuclear@0
|
213
|
nuclear@0
|
214 } FT_StreamDesc;
|
nuclear@0
|
215
|
nuclear@0
|
216
|
nuclear@0
|
217 /*************************************************************************
|
nuclear@0
|
218 *
|
nuclear@0
|
219 * @functype:
|
nuclear@0
|
220 * FT_Stream_IoFunc
|
nuclear@0
|
221 *
|
nuclear@0
|
222 * @description:
|
nuclear@0
|
223 * A function used to seek and read data from a given input stream.
|
nuclear@0
|
224 *
|
nuclear@0
|
225 * @input:
|
nuclear@0
|
226 * stream ::
|
nuclear@0
|
227 * A handle to the source stream.
|
nuclear@0
|
228 *
|
nuclear@0
|
229 * offset ::
|
nuclear@0
|
230 * The offset of read in stream (always from start).
|
nuclear@0
|
231 *
|
nuclear@0
|
232 * buffer ::
|
nuclear@0
|
233 * The address of the read buffer.
|
nuclear@0
|
234 *
|
nuclear@0
|
235 * count ::
|
nuclear@0
|
236 * The number of bytes to read from the stream.
|
nuclear@0
|
237 *
|
nuclear@0
|
238 * @return:
|
nuclear@0
|
239 * The number of bytes effectively read by the stream.
|
nuclear@0
|
240 *
|
nuclear@0
|
241 * @note:
|
nuclear@0
|
242 * This function might be called to perform a seek or skip operation
|
nuclear@0
|
243 * with a `count' of~0. A non-zero return value then indicates an
|
nuclear@0
|
244 * error.
|
nuclear@0
|
245 *
|
nuclear@0
|
246 */
|
nuclear@0
|
247 typedef unsigned long
|
nuclear@0
|
248 (*FT_Stream_IoFunc)( FT_Stream stream,
|
nuclear@0
|
249 unsigned long offset,
|
nuclear@0
|
250 unsigned char* buffer,
|
nuclear@0
|
251 unsigned long count );
|
nuclear@0
|
252
|
nuclear@0
|
253
|
nuclear@0
|
254 /*************************************************************************
|
nuclear@0
|
255 *
|
nuclear@0
|
256 * @functype:
|
nuclear@0
|
257 * FT_Stream_CloseFunc
|
nuclear@0
|
258 *
|
nuclear@0
|
259 * @description:
|
nuclear@0
|
260 * A function used to close a given input stream.
|
nuclear@0
|
261 *
|
nuclear@0
|
262 * @input:
|
nuclear@0
|
263 * stream ::
|
nuclear@0
|
264 * A handle to the target stream.
|
nuclear@0
|
265 *
|
nuclear@0
|
266 */
|
nuclear@0
|
267 typedef void
|
nuclear@0
|
268 (*FT_Stream_CloseFunc)( FT_Stream stream );
|
nuclear@0
|
269
|
nuclear@0
|
270
|
nuclear@0
|
271 /*************************************************************************
|
nuclear@0
|
272 *
|
nuclear@0
|
273 * @struct:
|
nuclear@0
|
274 * FT_StreamRec
|
nuclear@0
|
275 *
|
nuclear@0
|
276 * @description:
|
nuclear@0
|
277 * A structure used to describe an input stream.
|
nuclear@0
|
278 *
|
nuclear@0
|
279 * @input:
|
nuclear@0
|
280 * base ::
|
nuclear@0
|
281 * For memory-based streams, this is the address of the first stream
|
nuclear@0
|
282 * byte in memory. This field should always be set to NULL for
|
nuclear@0
|
283 * disk-based streams.
|
nuclear@0
|
284 *
|
nuclear@0
|
285 * size ::
|
nuclear@0
|
286 * The stream size in bytes.
|
nuclear@0
|
287 *
|
nuclear@0
|
288 * pos ::
|
nuclear@0
|
289 * The current position within the stream.
|
nuclear@0
|
290 *
|
nuclear@0
|
291 * descriptor ::
|
nuclear@0
|
292 * This field is a union that can hold an integer or a pointer. It is
|
nuclear@0
|
293 * used by stream implementations to store file descriptors or `FILE*'
|
nuclear@0
|
294 * pointers.
|
nuclear@0
|
295 *
|
nuclear@0
|
296 * pathname ::
|
nuclear@0
|
297 * This field is completely ignored by FreeType. However, it is often
|
nuclear@0
|
298 * useful during debugging to use it to store the stream's filename
|
nuclear@0
|
299 * (where available).
|
nuclear@0
|
300 *
|
nuclear@0
|
301 * read ::
|
nuclear@0
|
302 * The stream's input function.
|
nuclear@0
|
303 *
|
nuclear@0
|
304 * close ::
|
nuclear@0
|
305 * The stream's close function.
|
nuclear@0
|
306 *
|
nuclear@0
|
307 * memory ::
|
nuclear@0
|
308 * The memory manager to use to preload frames. This is set
|
nuclear@0
|
309 * internally by FreeType and shouldn't be touched by stream
|
nuclear@0
|
310 * implementations.
|
nuclear@0
|
311 *
|
nuclear@0
|
312 * cursor ::
|
nuclear@0
|
313 * This field is set and used internally by FreeType when parsing
|
nuclear@0
|
314 * frames.
|
nuclear@0
|
315 *
|
nuclear@0
|
316 * limit ::
|
nuclear@0
|
317 * This field is set and used internally by FreeType when parsing
|
nuclear@0
|
318 * frames.
|
nuclear@0
|
319 *
|
nuclear@0
|
320 */
|
nuclear@0
|
321 typedef struct FT_StreamRec_
|
nuclear@0
|
322 {
|
nuclear@0
|
323 unsigned char* base;
|
nuclear@0
|
324 unsigned long size;
|
nuclear@0
|
325 unsigned long pos;
|
nuclear@0
|
326
|
nuclear@0
|
327 FT_StreamDesc descriptor;
|
nuclear@0
|
328 FT_StreamDesc pathname;
|
nuclear@0
|
329 FT_Stream_IoFunc read;
|
nuclear@0
|
330 FT_Stream_CloseFunc close;
|
nuclear@0
|
331
|
nuclear@0
|
332 FT_Memory memory;
|
nuclear@0
|
333 unsigned char* cursor;
|
nuclear@0
|
334 unsigned char* limit;
|
nuclear@0
|
335
|
nuclear@0
|
336 } FT_StreamRec;
|
nuclear@0
|
337
|
nuclear@0
|
338
|
nuclear@0
|
339 /* */
|
nuclear@0
|
340
|
nuclear@0
|
341
|
nuclear@0
|
342 FT_END_HEADER
|
nuclear@0
|
343
|
nuclear@0
|
344 #endif /* __FTSYSTEM_H__ */
|
nuclear@0
|
345
|
nuclear@0
|
346
|
nuclear@0
|
347 /* END */
|