nuclear@0: /***************************************************************************/ nuclear@0: /* */ nuclear@0: /* ftsystem.h */ nuclear@0: /* */ nuclear@0: /* FreeType low-level system interface definition (specification). */ nuclear@0: /* */ nuclear@0: /* Copyright 1996-2001, 2002, 2005, 2010 by */ nuclear@0: /* David Turner, Robert Wilhelm, and Werner Lemberg. */ nuclear@0: /* */ nuclear@0: /* This file is part of the FreeType project, and may only be used, */ nuclear@0: /* modified, and distributed under the terms of the FreeType project */ nuclear@0: /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ nuclear@0: /* this file you indicate that you have read the license and */ nuclear@0: /* understand and accept it fully. */ nuclear@0: /* */ nuclear@0: /***************************************************************************/ nuclear@0: nuclear@0: nuclear@0: #ifndef __FTSYSTEM_H__ nuclear@0: #define __FTSYSTEM_H__ nuclear@0: nuclear@0: nuclear@0: #include nuclear@0: nuclear@0: nuclear@0: FT_BEGIN_HEADER nuclear@0: nuclear@0: nuclear@0: /*************************************************************************/ nuclear@0: /* */ nuclear@0: /*
*/ nuclear@0: /* system_interface */ nuclear@0: /* */ nuclear@0: /* */ nuclear@0: /* System Interface */ nuclear@0: /* */ nuclear@0: /* <Abstract> */ nuclear@0: /* How FreeType manages memory and i/o. */ nuclear@0: /* */ nuclear@0: /* <Description> */ nuclear@0: /* This section contains various definitions related to memory */ nuclear@0: /* management and i/o access. You need to understand this */ nuclear@0: /* information if you want to use a custom memory manager or you own */ nuclear@0: /* i/o streams. */ nuclear@0: /* */ nuclear@0: /*************************************************************************/ nuclear@0: nuclear@0: nuclear@0: /*************************************************************************/ nuclear@0: /* */ nuclear@0: /* M E M O R Y M A N A G E M E N T */ nuclear@0: /* */ nuclear@0: /*************************************************************************/ nuclear@0: nuclear@0: nuclear@0: /************************************************************************* nuclear@0: * nuclear@0: * @type: nuclear@0: * FT_Memory nuclear@0: * nuclear@0: * @description: nuclear@0: * A handle to a given memory manager object, defined with an nuclear@0: * @FT_MemoryRec structure. nuclear@0: * nuclear@0: */ nuclear@0: typedef struct FT_MemoryRec_* FT_Memory; nuclear@0: nuclear@0: nuclear@0: /************************************************************************* nuclear@0: * nuclear@0: * @functype: nuclear@0: * FT_Alloc_Func nuclear@0: * nuclear@0: * @description: nuclear@0: * A function used to allocate `size' bytes from `memory'. nuclear@0: * nuclear@0: * @input: nuclear@0: * memory :: nuclear@0: * A handle to the source memory manager. nuclear@0: * nuclear@0: * size :: nuclear@0: * The size in bytes to allocate. nuclear@0: * nuclear@0: * @return: nuclear@0: * Address of new memory block. 0~in case of failure. nuclear@0: * nuclear@0: */ nuclear@0: typedef void* nuclear@0: (*FT_Alloc_Func)( FT_Memory memory, nuclear@0: long size ); nuclear@0: nuclear@0: nuclear@0: /************************************************************************* nuclear@0: * nuclear@0: * @functype: nuclear@0: * FT_Free_Func nuclear@0: * nuclear@0: * @description: nuclear@0: * A function used to release a given block of memory. nuclear@0: * nuclear@0: * @input: nuclear@0: * memory :: nuclear@0: * A handle to the source memory manager. nuclear@0: * nuclear@0: * block :: nuclear@0: * The address of the target memory block. nuclear@0: * nuclear@0: */ nuclear@0: typedef void nuclear@0: (*FT_Free_Func)( FT_Memory memory, nuclear@0: void* block ); nuclear@0: nuclear@0: nuclear@0: /************************************************************************* nuclear@0: * nuclear@0: * @functype: nuclear@0: * FT_Realloc_Func nuclear@0: * nuclear@0: * @description: nuclear@0: * A function used to re-allocate a given block of memory. nuclear@0: * nuclear@0: * @input: nuclear@0: * memory :: nuclear@0: * A handle to the source memory manager. nuclear@0: * nuclear@0: * cur_size :: nuclear@0: * The block's current size in bytes. nuclear@0: * nuclear@0: * new_size :: nuclear@0: * The block's requested new size. nuclear@0: * nuclear@0: * block :: nuclear@0: * The block's current address. nuclear@0: * nuclear@0: * @return: nuclear@0: * New block address. 0~in case of memory shortage. nuclear@0: * nuclear@0: * @note: nuclear@0: * In case of error, the old block must still be available. nuclear@0: * nuclear@0: */ nuclear@0: typedef void* nuclear@0: (*FT_Realloc_Func)( FT_Memory memory, nuclear@0: long cur_size, nuclear@0: long new_size, nuclear@0: void* block ); nuclear@0: nuclear@0: nuclear@0: /************************************************************************* nuclear@0: * nuclear@0: * @struct: nuclear@0: * FT_MemoryRec nuclear@0: * nuclear@0: * @description: nuclear@0: * A structure used to describe a given memory manager to FreeType~2. nuclear@0: * nuclear@0: * @fields: nuclear@0: * user :: nuclear@0: * A generic typeless pointer for user data. nuclear@0: * nuclear@0: * alloc :: nuclear@0: * A pointer type to an allocation function. nuclear@0: * nuclear@0: * free :: nuclear@0: * A pointer type to an memory freeing function. nuclear@0: * nuclear@0: * realloc :: nuclear@0: * A pointer type to a reallocation function. nuclear@0: * nuclear@0: */ nuclear@0: struct FT_MemoryRec_ nuclear@0: { nuclear@0: void* user; nuclear@0: FT_Alloc_Func alloc; nuclear@0: FT_Free_Func free; nuclear@0: FT_Realloc_Func realloc; nuclear@0: }; nuclear@0: nuclear@0: nuclear@0: /*************************************************************************/ nuclear@0: /* */ nuclear@0: /* I / O M A N A G E M E N T */ nuclear@0: /* */ nuclear@0: /*************************************************************************/ nuclear@0: nuclear@0: nuclear@0: /************************************************************************* nuclear@0: * nuclear@0: * @type: nuclear@0: * FT_Stream nuclear@0: * nuclear@0: * @description: nuclear@0: * A handle to an input stream. nuclear@0: * nuclear@0: */ nuclear@0: typedef struct FT_StreamRec_* FT_Stream; nuclear@0: nuclear@0: nuclear@0: /************************************************************************* nuclear@0: * nuclear@0: * @struct: nuclear@0: * FT_StreamDesc nuclear@0: * nuclear@0: * @description: nuclear@0: * A union type used to store either a long or a pointer. This is used nuclear@0: * to store a file descriptor or a `FILE*' in an input stream. nuclear@0: * nuclear@0: */ nuclear@0: typedef union FT_StreamDesc_ nuclear@0: { nuclear@0: long value; nuclear@0: void* pointer; nuclear@0: nuclear@0: } FT_StreamDesc; nuclear@0: nuclear@0: nuclear@0: /************************************************************************* nuclear@0: * nuclear@0: * @functype: nuclear@0: * FT_Stream_IoFunc nuclear@0: * nuclear@0: * @description: nuclear@0: * A function used to seek and read data from a given input stream. nuclear@0: * nuclear@0: * @input: nuclear@0: * stream :: nuclear@0: * A handle to the source stream. nuclear@0: * nuclear@0: * offset :: nuclear@0: * The offset of read in stream (always from start). nuclear@0: * nuclear@0: * buffer :: nuclear@0: * The address of the read buffer. nuclear@0: * nuclear@0: * count :: nuclear@0: * The number of bytes to read from the stream. nuclear@0: * nuclear@0: * @return: nuclear@0: * The number of bytes effectively read by the stream. nuclear@0: * nuclear@0: * @note: nuclear@0: * This function might be called to perform a seek or skip operation nuclear@0: * with a `count' of~0. A non-zero return value then indicates an nuclear@0: * error. nuclear@0: * nuclear@0: */ nuclear@0: typedef unsigned long nuclear@0: (*FT_Stream_IoFunc)( FT_Stream stream, nuclear@0: unsigned long offset, nuclear@0: unsigned char* buffer, nuclear@0: unsigned long count ); nuclear@0: nuclear@0: nuclear@0: /************************************************************************* nuclear@0: * nuclear@0: * @functype: nuclear@0: * FT_Stream_CloseFunc nuclear@0: * nuclear@0: * @description: nuclear@0: * A function used to close a given input stream. nuclear@0: * nuclear@0: * @input: nuclear@0: * stream :: nuclear@0: * A handle to the target stream. nuclear@0: * nuclear@0: */ nuclear@0: typedef void nuclear@0: (*FT_Stream_CloseFunc)( FT_Stream stream ); nuclear@0: nuclear@0: nuclear@0: /************************************************************************* nuclear@0: * nuclear@0: * @struct: nuclear@0: * FT_StreamRec nuclear@0: * nuclear@0: * @description: nuclear@0: * A structure used to describe an input stream. nuclear@0: * nuclear@0: * @input: nuclear@0: * base :: nuclear@0: * For memory-based streams, this is the address of the first stream nuclear@0: * byte in memory. This field should always be set to NULL for nuclear@0: * disk-based streams. nuclear@0: * nuclear@0: * size :: nuclear@0: * The stream size in bytes. nuclear@0: * nuclear@0: * pos :: nuclear@0: * The current position within the stream. nuclear@0: * nuclear@0: * descriptor :: nuclear@0: * This field is a union that can hold an integer or a pointer. It is nuclear@0: * used by stream implementations to store file descriptors or `FILE*' nuclear@0: * pointers. nuclear@0: * nuclear@0: * pathname :: nuclear@0: * This field is completely ignored by FreeType. However, it is often nuclear@0: * useful during debugging to use it to store the stream's filename nuclear@0: * (where available). nuclear@0: * nuclear@0: * read :: nuclear@0: * The stream's input function. nuclear@0: * nuclear@0: * close :: nuclear@0: * The stream's close function. nuclear@0: * nuclear@0: * memory :: nuclear@0: * The memory manager to use to preload frames. This is set nuclear@0: * internally by FreeType and shouldn't be touched by stream nuclear@0: * implementations. nuclear@0: * nuclear@0: * cursor :: nuclear@0: * This field is set and used internally by FreeType when parsing nuclear@0: * frames. nuclear@0: * nuclear@0: * limit :: nuclear@0: * This field is set and used internally by FreeType when parsing nuclear@0: * frames. nuclear@0: * nuclear@0: */ nuclear@0: typedef struct FT_StreamRec_ nuclear@0: { nuclear@0: unsigned char* base; nuclear@0: unsigned long size; nuclear@0: unsigned long pos; nuclear@0: nuclear@0: FT_StreamDesc descriptor; nuclear@0: FT_StreamDesc pathname; nuclear@0: FT_Stream_IoFunc read; nuclear@0: FT_Stream_CloseFunc close; nuclear@0: nuclear@0: FT_Memory memory; nuclear@0: unsigned char* cursor; nuclear@0: unsigned char* limit; nuclear@0: nuclear@0: } FT_StreamRec; nuclear@0: nuclear@0: nuclear@0: /* */ nuclear@0: nuclear@0: nuclear@0: FT_END_HEADER nuclear@0: nuclear@0: #endif /* __FTSYSTEM_H__ */ nuclear@0: nuclear@0: nuclear@0: /* END */