vrshoot
diff libs/ft2static/freetype/internal/ftstream.h @ 0:b2f14e535253
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 01 Feb 2014 19:58:19 +0200 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/libs/ft2static/freetype/internal/ftstream.h Sat Feb 01 19:58:19 2014 +0200 1.3 @@ -0,0 +1,539 @@ 1.4 +/***************************************************************************/ 1.5 +/* */ 1.6 +/* ftstream.h */ 1.7 +/* */ 1.8 +/* Stream handling (specification). */ 1.9 +/* */ 1.10 +/* Copyright 1996-2001, 2002, 2004, 2005, 2006 by */ 1.11 +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ 1.12 +/* */ 1.13 +/* This file is part of the FreeType project, and may only be used, */ 1.14 +/* modified, and distributed under the terms of the FreeType project */ 1.15 +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 1.16 +/* this file you indicate that you have read the license and */ 1.17 +/* understand and accept it fully. */ 1.18 +/* */ 1.19 +/***************************************************************************/ 1.20 + 1.21 + 1.22 +#ifndef __FTSTREAM_H__ 1.23 +#define __FTSTREAM_H__ 1.24 + 1.25 + 1.26 +#include <ft2build.h> 1.27 +#include FT_SYSTEM_H 1.28 +#include FT_INTERNAL_OBJECTS_H 1.29 + 1.30 + 1.31 +FT_BEGIN_HEADER 1.32 + 1.33 + 1.34 + /* format of an 8-bit frame_op value: */ 1.35 + /* */ 1.36 + /* bit 76543210 */ 1.37 + /* xxxxxxes */ 1.38 + /* */ 1.39 + /* s is set to 1 if the value is signed. */ 1.40 + /* e is set to 1 if the value is little-endian. */ 1.41 + /* xxx is a command. */ 1.42 + 1.43 +#define FT_FRAME_OP_SHIFT 2 1.44 +#define FT_FRAME_OP_SIGNED 1 1.45 +#define FT_FRAME_OP_LITTLE 2 1.46 +#define FT_FRAME_OP_COMMAND( x ) ( x >> FT_FRAME_OP_SHIFT ) 1.47 + 1.48 +#define FT_MAKE_FRAME_OP( command, little, sign ) \ 1.49 + ( ( command << FT_FRAME_OP_SHIFT ) | ( little << 1 ) | sign ) 1.50 + 1.51 +#define FT_FRAME_OP_END 0 1.52 +#define FT_FRAME_OP_START 1 /* start a new frame */ 1.53 +#define FT_FRAME_OP_BYTE 2 /* read 1-byte value */ 1.54 +#define FT_FRAME_OP_SHORT 3 /* read 2-byte value */ 1.55 +#define FT_FRAME_OP_LONG 4 /* read 4-byte value */ 1.56 +#define FT_FRAME_OP_OFF3 5 /* read 3-byte value */ 1.57 +#define FT_FRAME_OP_BYTES 6 /* read a bytes sequence */ 1.58 + 1.59 + 1.60 + typedef enum FT_Frame_Op_ 1.61 + { 1.62 + ft_frame_end = 0, 1.63 + ft_frame_start = FT_MAKE_FRAME_OP( FT_FRAME_OP_START, 0, 0 ), 1.64 + 1.65 + ft_frame_byte = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTE, 0, 0 ), 1.66 + ft_frame_schar = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTE, 0, 1 ), 1.67 + 1.68 + ft_frame_ushort_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 0, 0 ), 1.69 + ft_frame_short_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 0, 1 ), 1.70 + ft_frame_ushort_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 1, 0 ), 1.71 + ft_frame_short_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 1, 1 ), 1.72 + 1.73 + ft_frame_ulong_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 0, 0 ), 1.74 + ft_frame_long_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 0, 1 ), 1.75 + ft_frame_ulong_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 1, 0 ), 1.76 + ft_frame_long_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 1, 1 ), 1.77 + 1.78 + ft_frame_uoff3_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 0, 0 ), 1.79 + ft_frame_off3_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 0, 1 ), 1.80 + ft_frame_uoff3_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 1, 0 ), 1.81 + ft_frame_off3_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 1, 1 ), 1.82 + 1.83 + ft_frame_bytes = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTES, 0, 0 ), 1.84 + ft_frame_skip = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTES, 0, 1 ) 1.85 + 1.86 + } FT_Frame_Op; 1.87 + 1.88 + 1.89 + typedef struct FT_Frame_Field_ 1.90 + { 1.91 + FT_Byte value; 1.92 + FT_Byte size; 1.93 + FT_UShort offset; 1.94 + 1.95 + } FT_Frame_Field; 1.96 + 1.97 + 1.98 + /* Construct an FT_Frame_Field out of a structure type and a field name. */ 1.99 + /* The structure type must be set in the FT_STRUCTURE macro before */ 1.100 + /* calling the FT_FRAME_START() macro. */ 1.101 + /* */ 1.102 +#define FT_FIELD_SIZE( f ) \ 1.103 + (FT_Byte)sizeof ( ((FT_STRUCTURE*)0)->f ) 1.104 + 1.105 +#define FT_FIELD_SIZE_DELTA( f ) \ 1.106 + (FT_Byte)sizeof ( ((FT_STRUCTURE*)0)->f[0] ) 1.107 + 1.108 +#define FT_FIELD_OFFSET( f ) \ 1.109 + (FT_UShort)( offsetof( FT_STRUCTURE, f ) ) 1.110 + 1.111 +#define FT_FRAME_FIELD( frame_op, field ) \ 1.112 + { \ 1.113 + frame_op, \ 1.114 + FT_FIELD_SIZE( field ), \ 1.115 + FT_FIELD_OFFSET( field ) \ 1.116 + } 1.117 + 1.118 +#define FT_MAKE_EMPTY_FIELD( frame_op ) { frame_op, 0, 0 } 1.119 + 1.120 +#define FT_FRAME_START( size ) { ft_frame_start, 0, size } 1.121 +#define FT_FRAME_END { ft_frame_end, 0, 0 } 1.122 + 1.123 +#define FT_FRAME_LONG( f ) FT_FRAME_FIELD( ft_frame_long_be, f ) 1.124 +#define FT_FRAME_ULONG( f ) FT_FRAME_FIELD( ft_frame_ulong_be, f ) 1.125 +#define FT_FRAME_SHORT( f ) FT_FRAME_FIELD( ft_frame_short_be, f ) 1.126 +#define FT_FRAME_USHORT( f ) FT_FRAME_FIELD( ft_frame_ushort_be, f ) 1.127 +#define FT_FRAME_OFF3( f ) FT_FRAME_FIELD( ft_frame_off3_be, f ) 1.128 +#define FT_FRAME_UOFF3( f ) FT_FRAME_FIELD( ft_frame_uoff3_be, f ) 1.129 +#define FT_FRAME_BYTE( f ) FT_FRAME_FIELD( ft_frame_byte, f ) 1.130 +#define FT_FRAME_CHAR( f ) FT_FRAME_FIELD( ft_frame_schar, f ) 1.131 + 1.132 +#define FT_FRAME_LONG_LE( f ) FT_FRAME_FIELD( ft_frame_long_le, f ) 1.133 +#define FT_FRAME_ULONG_LE( f ) FT_FRAME_FIELD( ft_frame_ulong_le, f ) 1.134 +#define FT_FRAME_SHORT_LE( f ) FT_FRAME_FIELD( ft_frame_short_le, f ) 1.135 +#define FT_FRAME_USHORT_LE( f ) FT_FRAME_FIELD( ft_frame_ushort_le, f ) 1.136 +#define FT_FRAME_OFF3_LE( f ) FT_FRAME_FIELD( ft_frame_off3_le, f ) 1.137 +#define FT_FRAME_UOFF3_LE( f ) FT_FRAME_FIELD( ft_frame_uoff3_le, f ) 1.138 + 1.139 +#define FT_FRAME_SKIP_LONG { ft_frame_long_be, 0, 0 } 1.140 +#define FT_FRAME_SKIP_SHORT { ft_frame_short_be, 0, 0 } 1.141 +#define FT_FRAME_SKIP_BYTE { ft_frame_byte, 0, 0 } 1.142 + 1.143 +#define FT_FRAME_BYTES( field, count ) \ 1.144 + { \ 1.145 + ft_frame_bytes, \ 1.146 + count, \ 1.147 + FT_FIELD_OFFSET( field ) \ 1.148 + } 1.149 + 1.150 +#define FT_FRAME_SKIP_BYTES( count ) { ft_frame_skip, count, 0 } 1.151 + 1.152 + 1.153 + /*************************************************************************/ 1.154 + /* */ 1.155 + /* Integer extraction macros -- the `buffer' parameter must ALWAYS be of */ 1.156 + /* type `char*' or equivalent (1-byte elements). */ 1.157 + /* */ 1.158 + 1.159 +#define FT_BYTE_( p, i ) ( ((const FT_Byte*)(p))[(i)] ) 1.160 +#define FT_INT8_( p, i ) ( ((const FT_Char*)(p))[(i)] ) 1.161 + 1.162 +#define FT_INT16( x ) ( (FT_Int16)(x) ) 1.163 +#define FT_UINT16( x ) ( (FT_UInt16)(x) ) 1.164 +#define FT_INT32( x ) ( (FT_Int32)(x) ) 1.165 +#define FT_UINT32( x ) ( (FT_UInt32)(x) ) 1.166 + 1.167 +#define FT_BYTE_I16( p, i, s ) ( FT_INT16( FT_BYTE_( p, i ) ) << (s) ) 1.168 +#define FT_BYTE_U16( p, i, s ) ( FT_UINT16( FT_BYTE_( p, i ) ) << (s) ) 1.169 +#define FT_BYTE_I32( p, i, s ) ( FT_INT32( FT_BYTE_( p, i ) ) << (s) ) 1.170 +#define FT_BYTE_U32( p, i, s ) ( FT_UINT32( FT_BYTE_( p, i ) ) << (s) ) 1.171 + 1.172 +#define FT_INT8_I16( p, i, s ) ( FT_INT16( FT_INT8_( p, i ) ) << (s) ) 1.173 +#define FT_INT8_U16( p, i, s ) ( FT_UINT16( FT_INT8_( p, i ) ) << (s) ) 1.174 +#define FT_INT8_I32( p, i, s ) ( FT_INT32( FT_INT8_( p, i ) ) << (s) ) 1.175 +#define FT_INT8_U32( p, i, s ) ( FT_UINT32( FT_INT8_( p, i ) ) << (s) ) 1.176 + 1.177 + 1.178 +#define FT_PEEK_SHORT( p ) FT_INT16( FT_INT8_I16( p, 0, 8) | \ 1.179 + FT_BYTE_I16( p, 1, 0) ) 1.180 + 1.181 +#define FT_PEEK_USHORT( p ) FT_UINT16( FT_BYTE_U16( p, 0, 8 ) | \ 1.182 + FT_BYTE_U16( p, 1, 0 ) ) 1.183 + 1.184 +#define FT_PEEK_LONG( p ) FT_INT32( FT_INT8_I32( p, 0, 24 ) | \ 1.185 + FT_BYTE_I32( p, 1, 16 ) | \ 1.186 + FT_BYTE_I32( p, 2, 8 ) | \ 1.187 + FT_BYTE_I32( p, 3, 0 ) ) 1.188 + 1.189 +#define FT_PEEK_ULONG( p ) FT_UINT32( FT_BYTE_U32( p, 0, 24 ) | \ 1.190 + FT_BYTE_U32( p, 1, 16 ) | \ 1.191 + FT_BYTE_U32( p, 2, 8 ) | \ 1.192 + FT_BYTE_U32( p, 3, 0 ) ) 1.193 + 1.194 +#define FT_PEEK_OFF3( p ) FT_INT32( FT_INT8_I32( p, 0, 16 ) | \ 1.195 + FT_BYTE_I32( p, 1, 8 ) | \ 1.196 + FT_BYTE_I32( p, 2, 0 ) ) 1.197 + 1.198 +#define FT_PEEK_UOFF3( p ) FT_UINT32( FT_BYTE_U32( p, 0, 16 ) | \ 1.199 + FT_BYTE_U32( p, 1, 8 ) | \ 1.200 + FT_BYTE_U32( p, 2, 0 ) ) 1.201 + 1.202 +#define FT_PEEK_SHORT_LE( p ) FT_INT16( FT_INT8_I16( p, 1, 8 ) | \ 1.203 + FT_BYTE_I16( p, 0, 0 ) ) 1.204 + 1.205 +#define FT_PEEK_USHORT_LE( p ) FT_UINT16( FT_BYTE_U16( p, 1, 8 ) | \ 1.206 + FT_BYTE_U16( p, 0, 0 ) ) 1.207 + 1.208 +#define FT_PEEK_LONG_LE( p ) FT_INT32( FT_INT8_I32( p, 3, 24 ) | \ 1.209 + FT_BYTE_I32( p, 2, 16 ) | \ 1.210 + FT_BYTE_I32( p, 1, 8 ) | \ 1.211 + FT_BYTE_I32( p, 0, 0 ) ) 1.212 + 1.213 +#define FT_PEEK_ULONG_LE( p ) FT_UINT32( FT_BYTE_U32( p, 3, 24 ) | \ 1.214 + FT_BYTE_U32( p, 2, 16 ) | \ 1.215 + FT_BYTE_U32( p, 1, 8 ) | \ 1.216 + FT_BYTE_U32( p, 0, 0 ) ) 1.217 + 1.218 +#define FT_PEEK_OFF3_LE( p ) FT_INT32( FT_INT8_I32( p, 2, 16 ) | \ 1.219 + FT_BYTE_I32( p, 1, 8 ) | \ 1.220 + FT_BYTE_I32( p, 0, 0 ) ) 1.221 + 1.222 +#define FT_PEEK_UOFF3_LE( p ) FT_UINT32( FT_BYTE_U32( p, 2, 16 ) | \ 1.223 + FT_BYTE_U32( p, 1, 8 ) | \ 1.224 + FT_BYTE_U32( p, 0, 0 ) ) 1.225 + 1.226 + 1.227 +#define FT_NEXT_CHAR( buffer ) \ 1.228 + ( (signed char)*buffer++ ) 1.229 + 1.230 +#define FT_NEXT_BYTE( buffer ) \ 1.231 + ( (unsigned char)*buffer++ ) 1.232 + 1.233 +#define FT_NEXT_SHORT( buffer ) \ 1.234 + ( (short)( buffer += 2, FT_PEEK_SHORT( buffer - 2 ) ) ) 1.235 + 1.236 +#define FT_NEXT_USHORT( buffer ) \ 1.237 + ( (unsigned short)( buffer += 2, FT_PEEK_USHORT( buffer - 2 ) ) ) 1.238 + 1.239 +#define FT_NEXT_OFF3( buffer ) \ 1.240 + ( (long)( buffer += 3, FT_PEEK_OFF3( buffer - 3 ) ) ) 1.241 + 1.242 +#define FT_NEXT_UOFF3( buffer ) \ 1.243 + ( (unsigned long)( buffer += 3, FT_PEEK_UOFF3( buffer - 3 ) ) ) 1.244 + 1.245 +#define FT_NEXT_LONG( buffer ) \ 1.246 + ( (long)( buffer += 4, FT_PEEK_LONG( buffer - 4 ) ) ) 1.247 + 1.248 +#define FT_NEXT_ULONG( buffer ) \ 1.249 + ( (unsigned long)( buffer += 4, FT_PEEK_ULONG( buffer - 4 ) ) ) 1.250 + 1.251 + 1.252 +#define FT_NEXT_SHORT_LE( buffer ) \ 1.253 + ( (short)( buffer += 2, FT_PEEK_SHORT_LE( buffer - 2 ) ) ) 1.254 + 1.255 +#define FT_NEXT_USHORT_LE( buffer ) \ 1.256 + ( (unsigned short)( buffer += 2, FT_PEEK_USHORT_LE( buffer - 2 ) ) ) 1.257 + 1.258 +#define FT_NEXT_OFF3_LE( buffer ) \ 1.259 + ( (long)( buffer += 3, FT_PEEK_OFF3_LE( buffer - 3 ) ) ) 1.260 + 1.261 +#define FT_NEXT_UOFF3_LE( buffer ) \ 1.262 + ( (unsigned long)( buffer += 3, FT_PEEK_UOFF3_LE( buffer - 3 ) ) ) 1.263 + 1.264 +#define FT_NEXT_LONG_LE( buffer ) \ 1.265 + ( (long)( buffer += 4, FT_PEEK_LONG_LE( buffer - 4 ) ) ) 1.266 + 1.267 +#define FT_NEXT_ULONG_LE( buffer ) \ 1.268 + ( (unsigned long)( buffer += 4, FT_PEEK_ULONG_LE( buffer - 4 ) ) ) 1.269 + 1.270 + 1.271 + /*************************************************************************/ 1.272 + /* */ 1.273 + /* Each GET_xxxx() macro uses an implicit `stream' variable. */ 1.274 + /* */ 1.275 +#if 0 1.276 +#define FT_GET_MACRO( type ) FT_NEXT_ ## type ( stream->cursor ) 1.277 + 1.278 +#define FT_GET_CHAR() FT_GET_MACRO( CHAR ) 1.279 +#define FT_GET_BYTE() FT_GET_MACRO( BYTE ) 1.280 +#define FT_GET_SHORT() FT_GET_MACRO( SHORT ) 1.281 +#define FT_GET_USHORT() FT_GET_MACRO( USHORT ) 1.282 +#define FT_GET_OFF3() FT_GET_MACRO( OFF3 ) 1.283 +#define FT_GET_UOFF3() FT_GET_MACRO( UOFF3 ) 1.284 +#define FT_GET_LONG() FT_GET_MACRO( LONG ) 1.285 +#define FT_GET_ULONG() FT_GET_MACRO( ULONG ) 1.286 +#define FT_GET_TAG4() FT_GET_MACRO( ULONG ) 1.287 + 1.288 +#define FT_GET_SHORT_LE() FT_GET_MACRO( SHORT_LE ) 1.289 +#define FT_GET_USHORT_LE() FT_GET_MACRO( USHORT_LE ) 1.290 +#define FT_GET_LONG_LE() FT_GET_MACRO( LONG_LE ) 1.291 +#define FT_GET_ULONG_LE() FT_GET_MACRO( ULONG_LE ) 1.292 + 1.293 +#else 1.294 +#define FT_GET_MACRO( func, type ) ( (type)func( stream ) ) 1.295 + 1.296 +#define FT_GET_CHAR() FT_GET_MACRO( FT_Stream_GetChar, FT_Char ) 1.297 +#define FT_GET_BYTE() FT_GET_MACRO( FT_Stream_GetChar, FT_Byte ) 1.298 +#define FT_GET_SHORT() FT_GET_MACRO( FT_Stream_GetShort, FT_Short ) 1.299 +#define FT_GET_USHORT() FT_GET_MACRO( FT_Stream_GetShort, FT_UShort ) 1.300 +#define FT_GET_OFF3() FT_GET_MACRO( FT_Stream_GetOffset, FT_Long ) 1.301 +#define FT_GET_UOFF3() FT_GET_MACRO( FT_Stream_GetOffset, FT_ULong ) 1.302 +#define FT_GET_LONG() FT_GET_MACRO( FT_Stream_GetLong, FT_Long ) 1.303 +#define FT_GET_ULONG() FT_GET_MACRO( FT_Stream_GetLong, FT_ULong ) 1.304 +#define FT_GET_TAG4() FT_GET_MACRO( FT_Stream_GetLong, FT_ULong ) 1.305 + 1.306 +#define FT_GET_SHORT_LE() FT_GET_MACRO( FT_Stream_GetShortLE, FT_Short ) 1.307 +#define FT_GET_USHORT_LE() FT_GET_MACRO( FT_Stream_GetShortLE, FT_UShort ) 1.308 +#define FT_GET_LONG_LE() FT_GET_MACRO( FT_Stream_GetLongLE, FT_Long ) 1.309 +#define FT_GET_ULONG_LE() FT_GET_MACRO( FT_Stream_GetLongLE, FT_ULong ) 1.310 +#endif 1.311 + 1.312 +#define FT_READ_MACRO( func, type, var ) \ 1.313 + ( var = (type)func( stream, &error ), \ 1.314 + error != FT_Err_Ok ) 1.315 + 1.316 +#define FT_READ_BYTE( var ) FT_READ_MACRO( FT_Stream_ReadChar, FT_Byte, var ) 1.317 +#define FT_READ_CHAR( var ) FT_READ_MACRO( FT_Stream_ReadChar, FT_Char, var ) 1.318 +#define FT_READ_SHORT( var ) FT_READ_MACRO( FT_Stream_ReadShort, FT_Short, var ) 1.319 +#define FT_READ_USHORT( var ) FT_READ_MACRO( FT_Stream_ReadShort, FT_UShort, var ) 1.320 +#define FT_READ_OFF3( var ) FT_READ_MACRO( FT_Stream_ReadOffset, FT_Long, var ) 1.321 +#define FT_READ_UOFF3( var ) FT_READ_MACRO( FT_Stream_ReadOffset, FT_ULong, var ) 1.322 +#define FT_READ_LONG( var ) FT_READ_MACRO( FT_Stream_ReadLong, FT_Long, var ) 1.323 +#define FT_READ_ULONG( var ) FT_READ_MACRO( FT_Stream_ReadLong, FT_ULong, var ) 1.324 + 1.325 +#define FT_READ_SHORT_LE( var ) FT_READ_MACRO( FT_Stream_ReadShortLE, FT_Short, var ) 1.326 +#define FT_READ_USHORT_LE( var ) FT_READ_MACRO( FT_Stream_ReadShortLE, FT_UShort, var ) 1.327 +#define FT_READ_LONG_LE( var ) FT_READ_MACRO( FT_Stream_ReadLongLE, FT_Long, var ) 1.328 +#define FT_READ_ULONG_LE( var ) FT_READ_MACRO( FT_Stream_ReadLongLE, FT_ULong, var ) 1.329 + 1.330 + 1.331 +#ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM 1.332 + 1.333 + /* initialize a stream for reading a regular system stream */ 1.334 + FT_BASE( FT_Error ) 1.335 + FT_Stream_Open( FT_Stream stream, 1.336 + const char* filepathname ); 1.337 + 1.338 +#endif /* FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */ 1.339 + 1.340 + 1.341 + /* create a new (input) stream from an FT_Open_Args structure */ 1.342 + FT_BASE( FT_Error ) 1.343 + FT_Stream_New( FT_Library library, 1.344 + const FT_Open_Args* args, 1.345 + FT_Stream *astream ); 1.346 + 1.347 + /* free a stream */ 1.348 + FT_BASE( void ) 1.349 + FT_Stream_Free( FT_Stream stream, 1.350 + FT_Int external ); 1.351 + 1.352 + /* initialize a stream for reading in-memory data */ 1.353 + FT_BASE( void ) 1.354 + FT_Stream_OpenMemory( FT_Stream stream, 1.355 + const FT_Byte* base, 1.356 + FT_ULong size ); 1.357 + 1.358 + /* close a stream (does not destroy the stream structure) */ 1.359 + FT_BASE( void ) 1.360 + FT_Stream_Close( FT_Stream stream ); 1.361 + 1.362 + 1.363 + /* seek within a stream. position is relative to start of stream */ 1.364 + FT_BASE( FT_Error ) 1.365 + FT_Stream_Seek( FT_Stream stream, 1.366 + FT_ULong pos ); 1.367 + 1.368 + /* skip bytes in a stream */ 1.369 + FT_BASE( FT_Error ) 1.370 + FT_Stream_Skip( FT_Stream stream, 1.371 + FT_Long distance ); 1.372 + 1.373 + /* return current stream position */ 1.374 + FT_BASE( FT_Long ) 1.375 + FT_Stream_Pos( FT_Stream stream ); 1.376 + 1.377 + /* read bytes from a stream into a user-allocated buffer, returns an */ 1.378 + /* error if not all bytes could be read. */ 1.379 + FT_BASE( FT_Error ) 1.380 + FT_Stream_Read( FT_Stream stream, 1.381 + FT_Byte* buffer, 1.382 + FT_ULong count ); 1.383 + 1.384 + /* read bytes from a stream at a given position */ 1.385 + FT_BASE( FT_Error ) 1.386 + FT_Stream_ReadAt( FT_Stream stream, 1.387 + FT_ULong pos, 1.388 + FT_Byte* buffer, 1.389 + FT_ULong count ); 1.390 + 1.391 + /* try to read bytes at the end of a stream; return number of bytes */ 1.392 + /* really available */ 1.393 + FT_BASE( FT_ULong ) 1.394 + FT_Stream_TryRead( FT_Stream stream, 1.395 + FT_Byte* buffer, 1.396 + FT_ULong count ); 1.397 + 1.398 + /* Enter a frame of `count' consecutive bytes in a stream. Returns an */ 1.399 + /* error if the frame could not be read/accessed. The caller can use */ 1.400 + /* the FT_Stream_Get_XXX functions to retrieve frame data without */ 1.401 + /* error checks. */ 1.402 + /* */ 1.403 + /* You must _always_ call FT_Stream_ExitFrame() once you have entered */ 1.404 + /* a stream frame! */ 1.405 + /* */ 1.406 + FT_BASE( FT_Error ) 1.407 + FT_Stream_EnterFrame( FT_Stream stream, 1.408 + FT_ULong count ); 1.409 + 1.410 + /* exit a stream frame */ 1.411 + FT_BASE( void ) 1.412 + FT_Stream_ExitFrame( FT_Stream stream ); 1.413 + 1.414 + /* Extract a stream frame. If the stream is disk-based, a heap block */ 1.415 + /* is allocated and the frame bytes are read into it. If the stream */ 1.416 + /* is memory-based, this function simply set a pointer to the data. */ 1.417 + /* */ 1.418 + /* Useful to optimize access to memory-based streams transparently. */ 1.419 + /* */ 1.420 + /* All extracted frames must be `freed' with a call to the function */ 1.421 + /* FT_Stream_ReleaseFrame(). */ 1.422 + /* */ 1.423 + FT_BASE( FT_Error ) 1.424 + FT_Stream_ExtractFrame( FT_Stream stream, 1.425 + FT_ULong count, 1.426 + FT_Byte** pbytes ); 1.427 + 1.428 + /* release an extract frame (see FT_Stream_ExtractFrame) */ 1.429 + FT_BASE( void ) 1.430 + FT_Stream_ReleaseFrame( FT_Stream stream, 1.431 + FT_Byte** pbytes ); 1.432 + 1.433 + /* read a byte from an entered frame */ 1.434 + FT_BASE( FT_Char ) 1.435 + FT_Stream_GetChar( FT_Stream stream ); 1.436 + 1.437 + /* read a 16-bit big-endian integer from an entered frame */ 1.438 + FT_BASE( FT_Short ) 1.439 + FT_Stream_GetShort( FT_Stream stream ); 1.440 + 1.441 + /* read a 24-bit big-endian integer from an entered frame */ 1.442 + FT_BASE( FT_Long ) 1.443 + FT_Stream_GetOffset( FT_Stream stream ); 1.444 + 1.445 + /* read a 32-bit big-endian integer from an entered frame */ 1.446 + FT_BASE( FT_Long ) 1.447 + FT_Stream_GetLong( FT_Stream stream ); 1.448 + 1.449 + /* read a 16-bit little-endian integer from an entered frame */ 1.450 + FT_BASE( FT_Short ) 1.451 + FT_Stream_GetShortLE( FT_Stream stream ); 1.452 + 1.453 + /* read a 32-bit little-endian integer from an entered frame */ 1.454 + FT_BASE( FT_Long ) 1.455 + FT_Stream_GetLongLE( FT_Stream stream ); 1.456 + 1.457 + 1.458 + /* read a byte from a stream */ 1.459 + FT_BASE( FT_Char ) 1.460 + FT_Stream_ReadChar( FT_Stream stream, 1.461 + FT_Error* error ); 1.462 + 1.463 + /* read a 16-bit big-endian integer from a stream */ 1.464 + FT_BASE( FT_Short ) 1.465 + FT_Stream_ReadShort( FT_Stream stream, 1.466 + FT_Error* error ); 1.467 + 1.468 + /* read a 24-bit big-endian integer from a stream */ 1.469 + FT_BASE( FT_Long ) 1.470 + FT_Stream_ReadOffset( FT_Stream stream, 1.471 + FT_Error* error ); 1.472 + 1.473 + /* read a 32-bit big-endian integer from a stream */ 1.474 + FT_BASE( FT_Long ) 1.475 + FT_Stream_ReadLong( FT_Stream stream, 1.476 + FT_Error* error ); 1.477 + 1.478 + /* read a 16-bit little-endian integer from a stream */ 1.479 + FT_BASE( FT_Short ) 1.480 + FT_Stream_ReadShortLE( FT_Stream stream, 1.481 + FT_Error* error ); 1.482 + 1.483 + /* read a 32-bit little-endian integer from a stream */ 1.484 + FT_BASE( FT_Long ) 1.485 + FT_Stream_ReadLongLE( FT_Stream stream, 1.486 + FT_Error* error ); 1.487 + 1.488 + /* Read a structure from a stream. The structure must be described */ 1.489 + /* by an array of FT_Frame_Field records. */ 1.490 + FT_BASE( FT_Error ) 1.491 + FT_Stream_ReadFields( FT_Stream stream, 1.492 + const FT_Frame_Field* fields, 1.493 + void* structure ); 1.494 + 1.495 + 1.496 +#define FT_STREAM_POS() \ 1.497 + FT_Stream_Pos( stream ) 1.498 + 1.499 +#define FT_STREAM_SEEK( position ) \ 1.500 + FT_SET_ERROR( FT_Stream_Seek( stream, position ) ) 1.501 + 1.502 +#define FT_STREAM_SKIP( distance ) \ 1.503 + FT_SET_ERROR( FT_Stream_Skip( stream, distance ) ) 1.504 + 1.505 +#define FT_STREAM_READ( buffer, count ) \ 1.506 + FT_SET_ERROR( FT_Stream_Read( stream, \ 1.507 + (FT_Byte*)buffer, \ 1.508 + count ) ) 1.509 + 1.510 +#define FT_STREAM_READ_AT( position, buffer, count ) \ 1.511 + FT_SET_ERROR( FT_Stream_ReadAt( stream, \ 1.512 + position, \ 1.513 + (FT_Byte*)buffer, \ 1.514 + count ) ) 1.515 + 1.516 +#define FT_STREAM_READ_FIELDS( fields, object ) \ 1.517 + FT_SET_ERROR( FT_Stream_ReadFields( stream, fields, object ) ) 1.518 + 1.519 + 1.520 +#define FT_FRAME_ENTER( size ) \ 1.521 + FT_SET_ERROR( \ 1.522 + FT_DEBUG_INNER( FT_Stream_EnterFrame( stream, size ) ) ) 1.523 + 1.524 +#define FT_FRAME_EXIT() \ 1.525 + FT_DEBUG_INNER( FT_Stream_ExitFrame( stream ) ) 1.526 + 1.527 +#define FT_FRAME_EXTRACT( size, bytes ) \ 1.528 + FT_SET_ERROR( \ 1.529 + FT_DEBUG_INNER( FT_Stream_ExtractFrame( stream, size, \ 1.530 + (FT_Byte**)&(bytes) ) ) ) 1.531 + 1.532 +#define FT_FRAME_RELEASE( bytes ) \ 1.533 + FT_DEBUG_INNER( FT_Stream_ReleaseFrame( stream, \ 1.534 + (FT_Byte**)&(bytes) ) ) 1.535 + 1.536 + 1.537 +FT_END_HEADER 1.538 + 1.539 +#endif /* __FTSTREAM_H__ */ 1.540 + 1.541 + 1.542 +/* END */