1 /***************************************************************************/
5 /* FreeType low-level system interface definition (specification). */
7 /* Copyright 1996-2018 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
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. */
16 /***************************************************************************/
29 /*************************************************************************/
32 /* system_interface */
35 /* System Interface */
38 /* How FreeType manages memory and i/o. */
41 /* This section contains various definitions related to memory */
42 /* management and i/o access. You need to understand this */
43 /* information if you want to use a custom memory manager or you own */
46 /*************************************************************************/
49 /*************************************************************************/
51 /* M E M O R Y M A N A G E M E N T */
53 /*************************************************************************/
56 /*************************************************************************
62 * A handle to a given memory manager object, defined with an
63 * @FT_MemoryRec structure.
66 typedef struct FT_MemoryRec_
* FT_Memory
;
69 /*************************************************************************
75 * A function used to allocate `size' bytes from `memory'.
79 * A handle to the source memory manager.
82 * The size in bytes to allocate.
85 * Address of new memory block. 0~in case of failure.
89 (*FT_Alloc_Func
)( FT_Memory memory
,
93 /*************************************************************************
99 * A function used to release a given block of memory.
103 * A handle to the source memory manager.
106 * The address of the target memory block.
110 (*FT_Free_Func
)( FT_Memory memory
,
114 /*************************************************************************
120 * A function used to re-allocate a given block of memory.
124 * A handle to the source memory manager.
127 * The block's current size in bytes.
130 * The block's requested new size.
133 * The block's current address.
136 * New block address. 0~in case of memory shortage.
139 * In case of error, the old block must still be available.
143 (*FT_Realloc_Func
)( FT_Memory memory
,
149 /*************************************************************************
155 * A structure used to describe a given memory manager to FreeType~2.
159 * A generic typeless pointer for user data.
162 * A pointer type to an allocation function.
165 * A pointer type to an memory freeing function.
168 * A pointer type to a reallocation function.
176 FT_Realloc_Func realloc
;
180 /*************************************************************************/
182 /* I / O M A N A G E M E N T */
184 /*************************************************************************/
187 /*************************************************************************
193 * A handle to an input stream.
196 * See @FT_StreamRec for the publicly accessible fields of a given
200 typedef struct FT_StreamRec_
* FT_Stream
;
203 /*************************************************************************
209 * A union type used to store either a long or a pointer. This is used
210 * to store a file descriptor or a `FILE*' in an input stream.
213 typedef union FT_StreamDesc_
221 /*************************************************************************
227 * A function used to seek and read data from a given input stream.
231 * A handle to the source stream.
234 * The offset of read in stream (always from start).
237 * The address of the read buffer.
240 * The number of bytes to read from the stream.
243 * The number of bytes effectively read by the stream.
246 * This function might be called to perform a seek or skip operation
247 * with a `count' of~0. A non-zero return value then indicates an
251 typedef unsigned long
252 (*FT_Stream_IoFunc
)( FT_Stream stream
,
253 unsigned long offset
,
254 unsigned char* buffer
,
255 unsigned long count
);
258 /*************************************************************************
261 * FT_Stream_CloseFunc
264 * A function used to close a given input stream.
268 * A handle to the target stream.
272 (*FT_Stream_CloseFunc
)( FT_Stream stream
);
275 /*************************************************************************
281 * A structure used to describe an input stream.
285 * For memory-based streams, this is the address of the first stream
286 * byte in memory. This field should always be set to NULL for
287 * disk-based streams.
290 * The stream size in bytes.
292 * In case of compressed streams where the size is unknown before
293 * actually doing the decompression, the value is set to 0x7FFFFFFF.
294 * (Note that this size value can occur for normal streams also; it is
298 * The current position within the stream.
301 * This field is a union that can hold an integer or a pointer. It is
302 * used by stream implementations to store file descriptors or `FILE*'
306 * This field is completely ignored by FreeType. However, it is often
307 * useful during debugging to use it to store the stream's filename
311 * The stream's input function.
314 * The stream's close function.
317 * The memory manager to use to preload frames. This is set
318 * internally by FreeType and shouldn't be touched by stream
322 * This field is set and used internally by FreeType when parsing
326 * This field is set and used internally by FreeType when parsing
330 typedef struct FT_StreamRec_
336 FT_StreamDesc descriptor
;
337 FT_StreamDesc pathname
;
338 FT_Stream_IoFunc read
;
339 FT_Stream_CloseFunc close
;
342 unsigned char* cursor
;
343 unsigned char* limit
;
352 #endif /* FTSYSTEM_H_ */