1 /***************************************************************************/
5 /* FreeType low-level system interface definition (specification). */
7 /* Copyright 1996-2001 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 /***************************************************************************/
19 #ifndef __FTSYSTEM_H__
20 #define __FTSYSTEM_H__
28 /*************************************************************************/
31 /* system_interface */
34 /* System Interface */
37 /* How FreeType manages memory and i/o. */
40 /* This section contains various definitions related to memory */
41 /* management and i/o access. You need to understand this */
42 /* information if you want to use a custom memory manager or you own */
43 /* input i/o streams. */
45 /*************************************************************************/
48 /*************************************************************************/
50 /* M E M O R Y M A N A G E M E N T */
52 /*************************************************************************/
55 /*************************************************************************/
61 /* A handle to a given memory manager object, defined with a */
62 /* @FT_MemoryRec structure. */
64 typedef struct FT_MemoryRec_* FT_Memory;
67 /*************************************************************************/
73 /* A function used to allocate `size' bytes from `memory'. */
76 /* memory :: A handle to the source memory manager. */
78 /* size :: The size in bytes to allocate. */
81 /* Address of new memory block. 0 in case of failure. */
84 (*FT_Alloc_Func)( FT_Memory memory,
88 /*************************************************************************/
94 /* A function used to release a given block of memory. */
97 /* memory :: A handle to the source memory manager. */
99 /* block :: The address of the target memory block. */
102 (*FT_Free_Func)( FT_Memory memory,
106 /*************************************************************************/
109 /* FT_Realloc_Func */
112 /* a function used to re-allocate a given block of memory. */
115 /* memory :: A handle to the source memory manager. */
117 /* cur_size :: The block's current size in bytes. */
119 /* new_size :: The block's requested new size. */
121 /* block :: The block's current address. */
124 /* New block address. 0 in case of memory shortage. */
127 /* In case of error, the old block must still be available. */
130 (*FT_Realloc_Func)( FT_Memory memory,
136 /*************************************************************************/
142 /* A structure used to describe a given memory manager to FreeType 2. */
145 /* user :: A generic typeless pointer for user data. */
147 /* alloc :: A pointer type to an allocation function. */
149 /* free :: A pointer type to an memory freeing function. */
151 /* realloc :: A pointer type to a reallocation function. */
158 FT_Realloc_Func realloc;
162 /*************************************************************************/
164 /* I / O M A N A G E M E N T */
166 /*************************************************************************/
169 /*************************************************************************/
175 /* A handle to an input stream. */
177 typedef struct FT_StreamRec_* FT_Stream;
180 /*************************************************************************/
186 /* A union type used to store either a long or a pointer. This is */
187 /* used to store a file descriptor or a FILE* in an input stream. */
189 typedef union FT_StreamDesc_
197 /*************************************************************************/
203 /* A function used to seek and read data from a given input stream. */
206 /* stream :: A handle to the source stream. */
208 /* offset :: The offset of read in stream (always from start). */
210 /* buffer :: The address of the read buffer. */
212 /* count :: The number of bytes to read from the stream. */
215 /* The number of bytes effectively read by the stream. */
218 /* This function might be called to perform a seek or skip operation */
219 /* with a `count' of 0. */
221 typedef unsigned long
222 (*FT_Stream_IO)( FT_Stream stream,
223 unsigned long offset,
224 unsigned char* buffer,
225 unsigned long count );
228 /*************************************************************************/
231 /* FT_Stream_Close */
234 /* A function used to close a given input stream. */
237 /* stream :: A handle to the target stream. */
240 (*FT_Stream_Close)( FT_Stream stream );
243 /*************************************************************************/
249 /* A structure used to describe an input stream. */
252 /* base :: For memory-based streams, this is the address of the */
253 /* first stream byte in memory. This field should */
254 /* always be set to NULL for disk-based streams. */
256 /* size :: The stream size in bytes. */
258 /* pos :: The current position within the stream. */
260 /* descriptor :: This field is a union that can hold an integer or a */
261 /* pointer. It is used by stream implementations to */
262 /* store file descriptors or FILE* pointers. */
264 /* pathname :: This field is completely ignored by FreeType. */
265 /* However, it is often useful during debugging to use */
266 /* it to store the stream's filename (where available). */
268 /* read :: The stream's input function. */
270 /* close :: The stream;s close function. */
272 /* memory :: The memory manager to use to preload frames. This is */
273 /* set internally by FreeType and shouldn't be touched */
274 /* by stream implementations. */
276 /* cursor :: This field is set and used internally by FreeType */
277 /* when parsing frames. */
279 /* limit :: This field is set and used internally by FreeType */
280 /* when parsing frames. */
288 FT_StreamDesc descriptor;
289 FT_StreamDesc pathname;
291 FT_Stream_Close close;
294 unsigned char* cursor;
295 unsigned char* limit;
304 #endif /* __FTSYSTEM_H__ */