1 /***************************************************************************/ 2 /* */ 3 /* ftstream.h */ 4 /* */ 5 /* Stream handling (specification). */ 6 /* */ 7 /* Copyright 1996-2001, 2002 by */ 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 /* */ 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. */ 15 /* */ 16 /***************************************************************************/ 17 18 19 #ifndef __FTSTREAM_H__ 20 #define __FTSTREAM_H__ 21 22 23 #include <ft2build.h> 24 #include FT_SYSTEM_H 25 #include FT_INTERNAL_OBJECTS_H 26 27 28 FT_BEGIN_HEADER 29 30 31 /* format of an 8-bit frame_op value: */ 32 /* */ 33 /* bit 76543210 */ 34 /* xxxxxxes */ 35 /* */ 36 /* s is set to 1 if the value is signed. */ 37 /* e is set to 1 if the value is little-endian. */ 38 /* xxx is a command. */ 39 40 #define FT_FRAME_OP_SHIFT 2 41 #define FT_FRAME_OP_SIGNED 1 42 #define FT_FRAME_OP_LITTLE 2 43 #define FT_FRAME_OP_COMMAND( x ) ( x >> FT_FRAME_OP_SHIFT ) 44 45 #define FT_MAKE_FRAME_OP( command, little, sign ) \ 46 ( ( command << FT_FRAME_OP_SHIFT ) | ( little << 1 ) | sign ) 47 48 #define FT_FRAME_OP_END 0 49 #define FT_FRAME_OP_START 1 /* start a new frame */ 50 #define FT_FRAME_OP_BYTE 2 /* read 1-byte value */ 51 #define FT_FRAME_OP_SHORT 3 /* read 2-byte value */ 52 #define FT_FRAME_OP_LONG 4 /* read 4-byte value */ 53 #define FT_FRAME_OP_OFF3 5 /* read 3-byte value */ 54 #define FT_FRAME_OP_BYTES 6 /* read a bytes sequence */ 55 56 57 typedef enum FT_Frame_Op_ 58 { 59 ft_frame_end = 0, 60 ft_frame_start = FT_MAKE_FRAME_OP( FT_FRAME_OP_START, 0, 0 ), 61 62 ft_frame_byte = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTE, 0, 0 ), 63 ft_frame_schar = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTE, 0, 1 ), 64 65 ft_frame_ushort_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 0, 0 ), 66 ft_frame_short_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 0, 1 ), 67 ft_frame_ushort_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 1, 0 ), 68 ft_frame_short_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 1, 1 ), 69 70 ft_frame_ulong_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 0, 0 ), 71 ft_frame_long_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 0, 1 ), 72 ft_frame_ulong_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 1, 0 ), 73 ft_frame_long_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 1, 1 ), 74 75 ft_frame_uoff3_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 0, 0 ), 76 ft_frame_off3_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 0, 1 ), 77 ft_frame_uoff3_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 1, 0 ), 78 ft_frame_off3_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 1, 1 ), 79 80 ft_frame_bytes = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTES, 0, 0 ), 81 ft_frame_skip = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTES, 0, 1 ) 82 83 } FT_Frame_Op; 84 85 86 typedef struct FT_Frame_Field_ 87 { 88 FT_Byte value; 89 FT_Byte size; 90 FT_UShort offset; 91 92 } FT_Frame_Field; 93 94 95 /* Construct an FT_Frame_Field out of a structure type and a field name. */ 96 /* The structure type must be set in the FT_STRUCTURE macro before */ 97 /* calling the FT_FRAME_START() macro. */ 98 /* */ 99 #define FT_FIELD_SIZE( f ) \ 100 (FT_Byte)sizeof ( ((FT_STRUCTURE*)0)->f ) 101 102 #define FT_FIELD_SIZE_DELTA( f ) \ 103 (FT_Byte)sizeof ( ((FT_STRUCTURE*)0)->f[0] ) 104 105 #define FT_FIELD_OFFSET( f ) \ 106 (FT_UShort)( offsetof( FT_STRUCTURE, f ) ) 107 108 #define FT_FRAME_FIELD( frame_op, field ) \ 109 { \ 110 frame_op, \ 111 FT_FIELD_SIZE( field ), \ 112 FT_FIELD_OFFSET( field ) \ 113 } 114 115 #define FT_MAKE_EMPTY_FIELD( frame_op ) { frame_op, 0, 0 } 116 117 #define FT_FRAME_START( size ) { ft_frame_start, 0, size } 118 #define FT_FRAME_END { ft_frame_end, 0, 0 } 119 120 #define FT_FRAME_LONG( f ) FT_FRAME_FIELD( ft_frame_long_be, f ) 121 #define FT_FRAME_ULONG( f ) FT_FRAME_FIELD( ft_frame_ulong_be, f ) 122 #define FT_FRAME_SHORT( f ) FT_FRAME_FIELD( ft_frame_short_be, f ) 123 #define FT_FRAME_USHORT( f ) FT_FRAME_FIELD( ft_frame_ushort_be, f ) 124 #define FT_FRAME_OFF3( f ) FT_FRAME_FIELD( ft_frame_off3_be, f ) 125 #define FT_FRAME_UOFF3( f ) FT_FRAME_FIELD( ft_frame_uoff3_be, f ) 126 #define FT_FRAME_BYTE( f ) FT_FRAME_FIELD( ft_frame_byte, f ) 127 #define FT_FRAME_CHAR( f ) FT_FRAME_FIELD( ft_frame_schar, f ) 128 129 #define FT_FRAME_LONG_LE( f ) FT_FRAME_FIELD( ft_frame_long_le, f ) 130 #define FT_FRAME_ULONG_LE( f ) FT_FRAME_FIELD( ft_frame_ulong_le, f ) 131 #define FT_FRAME_SHORT_LE( f ) FT_FRAME_FIELD( ft_frame_short_le, f ) 132 #define FT_FRAME_USHORT_LE( f ) FT_FRAME_FIELD( ft_frame_ushort_le, f ) 133 #define FT_FRAME_OFF3_LE( f ) FT_FRAME_FIELD( ft_frame_off3_le, f ) 134 #define FT_FRAME_UOFF3_LE( f ) FT_FRAME_FIELD( ft_frame_uoff3_le, f ) 135 136 #define FT_FRAME_SKIP_LONG { ft_frame_long_be, 0, 0 } 137 #define FT_FRAME_SKIP_SHORT { ft_frame_short_be, 0, 0 } 138 #define FT_FRAME_SKIP_BYTE { ft_frame_byte, 0, 0 } 139 140 #define FT_FRAME_BYTES( field, count ) \ 141 { \ 142 ft_frame_bytes, \ 143 count, \ 144 FT_FIELD_OFFSET( field ) \ 145 } 146 147 #define FT_FRAME_SKIP_BYTES( count ) { ft_frame_skip, count, 0 } 148 149 150 /*************************************************************************/ 151 /* */ 152 /* Integer extraction macros -- the `buffer' parameter must ALWAYS be of */ 153 /* type `char*' or equivalent (1-byte elements). */ 154 /* */ 155 156 #define FT_BYTE_( p, i ) ( ((const FT_Byte*)(p))[(i)] ) 157 #define FT_INT8_( p, i ) ( ((const FT_Char*)(p))[(i)] ) 158 159 #define FT_INT16( x ) ( (FT_Int16)(x) ) 160 #define FT_UINT16( x ) ( (FT_UInt16)(x) ) 161 #define FT_INT32( x ) ( (FT_Int32)(x) ) 162 #define FT_UINT32( x ) ( (FT_UInt32)(x) ) 163 164 #define FT_BYTE_I16( p, i, s ) ( FT_INT16( FT_BYTE_( p, i ) ) << (s) ) 165 #define FT_BYTE_U16( p, i, s ) ( FT_UINT16( FT_BYTE_( p, i ) ) << (s) ) 166 #define FT_BYTE_I32( p, i, s ) ( FT_INT32( FT_BYTE_( p, i ) ) << (s) ) 167 #define FT_BYTE_U32( p, i, s ) ( FT_UINT32( FT_BYTE_( p, i ) ) << (s) ) 168 169 #define FT_INT8_I16( p, i, s ) ( FT_INT16( FT_INT8_( p, i ) ) << (s) ) 170 #define FT_INT8_U16( p, i, s ) ( FT_UINT16( FT_INT8_( p, i ) ) << (s) ) 171 #define FT_INT8_I32( p, i, s ) ( FT_INT32( FT_INT8_( p, i ) ) << (s) ) 172 #define FT_INT8_U32( p, i, s ) ( FT_UINT32( FT_INT8_( p, i ) ) << (s) ) 173 174 175 #define FT_PEEK_SHORT( p ) FT_INT16( FT_INT8_I16( p, 0, 8) | \ 176 FT_BYTE_I16( p, 1, 0) ) 177 178 #define FT_PEEK_USHORT( p ) FT_UINT16( FT_BYTE_U16( p, 0, 8 ) | \ 179 FT_BYTE_U16( p, 1, 0 ) ) 180 181 #define FT_PEEK_LONG( p ) FT_INT32( FT_INT8_I32( p, 0, 24 ) | \ 182 FT_BYTE_I32( p, 1, 16 ) | \ 183 FT_BYTE_I32( p, 2, 8 ) | \ 184 FT_BYTE_I32( p, 3, 0 ) ) 185 186 #define FT_PEEK_ULONG( p ) FT_UINT32( FT_BYTE_U32( p, 0, 24 ) | \ 187 FT_BYTE_U32( p, 1, 16 ) | \ 188 FT_BYTE_U32( p, 2, 8 ) | \ 189 FT_BYTE_U32( p, 3, 0 ) ) 190 191 #define FT_PEEK_OFF3( p ) FT_INT32( FT_INT8_I32( p, 0, 16 ) | \ 192 FT_BYTE_I32( p, 1, 8 ) | \ 193 FT_BYTE_I32( p, 2, 0 ) ) 194 195 #define FT_PEEK_UOFF3( p ) FT_UINT32( FT_BYTE_U32( p, 0, 16 ) | \ 196 FT_BYTE_U32( p, 1, 8 ) | \ 197 FT_BYTE_U32( p, 2, 0 ) ) 198 199 #define FT_PEEK_SHORT_LE( p ) FT_INT16( FT_INT8_I16( p, 1, 8 ) | \ 200 FT_BYTE_I16( p, 0, 0 ) ) 201 202 #define FT_PEEK_USHORT_LE( p ) FT_UINT16( FT_BYTE_U16( p, 1, 8 ) | \ 203 FT_BYTE_U16( p, 0, 0 ) ) 204 205 #define FT_PEEK_LONG_LE( p ) FT_INT32( FT_INT8_I32( p, 3, 24 ) | \ 206 FT_BYTE_I32( p, 2, 16 ) | \ 207 FT_BYTE_I32( p, 1, 8 ) | \ 208 FT_BYTE_I32( p, 0, 0 ) ) 209 210 #define FT_PEEK_ULONG_LE( p ) FT_UINT32( FT_BYTE_U32( p, 3, 24 ) | \ 211 FT_BYTE_U32( p, 2, 16 ) | \ 212 FT_BYTE_U32( p, 1, 8 ) | \ 213 FT_BYTE_U32( p, 0, 0 ) ) 214 215 #define FT_PEEK_OFF3_LE( p ) FT_INT32( FT_INT8_I32( p, 2, 16 ) | \ 216 FT_BYTE_I32( p, 1, 8 ) | \ 217 FT_BYTE_I32( p, 0, 0 ) ) 218 219 #define FT_PEEK_UOFF3_LE( p ) FT_UINT32( FT_BYTE_U32( p, 2, 16 ) | \ 220 FT_BYTE_U32( p, 1, 8 ) | \ 221 FT_BYTE_U32( p, 0, 0 ) ) 222 223 224 #define FT_NEXT_CHAR( buffer ) \ 225 ( (signed char)*buffer++ ) 226 227 #define FT_NEXT_BYTE( buffer ) \ 228 ( (unsigned char)*buffer++ ) 229 230 #define FT_NEXT_SHORT( buffer ) \ 231 ( (short)( buffer += 2, FT_PEEK_SHORT( buffer - 2 ) ) ) 232 233 #define FT_NEXT_USHORT( buffer ) \ 234 ( (unsigned short)( buffer += 2, FT_PEEK_USHORT( buffer - 2 ) ) ) 235 236 #define FT_NEXT_OFF3( buffer ) \ 237 ( (long)( buffer += 3, FT_PEEK_OFF3( buffer - 3 ) ) ) 238 239 #define FT_NEXT_UOFF3( buffer ) \ 240 ( (unsigned long)( buffer += 3, FT_PEEK_UOFF3( buffer - 3 ) ) ) 241 242 #define FT_NEXT_LONG( buffer ) \ 243 ( (long)( buffer += 4, FT_PEEK_LONG( buffer - 4 ) ) ) 244 245 #define FT_NEXT_ULONG( buffer ) \ 246 ( (unsigned long)( buffer += 4, FT_PEEK_ULONG( buffer - 4 ) ) ) 247 248 249 #define FT_NEXT_SHORT_LE( buffer ) \ 250 ( (short)( buffer += 2, FT_PEEK_SHORT_LE( buffer - 2 ) ) ) 251 252 #define FT_NEXT_USHORT_LE( buffer ) \ 253 ( (unsigned short)( buffer += 2, FT_PEEK_USHORT_LE( buffer - 2 ) ) ) 254 255 #define FT_NEXT_OFF3_LE( buffer ) \ 256 ( (long)( buffer += 3, FT_PEEK_OFF3_LE( buffer - 3 ) ) ) 257 258 #define FT_NEXT_UOFF3_LE( buffer ) \ 259 ( (unsigned long)( buffer += 3, FT_PEEK_UOFF3_LE( buffer - 3 ) ) ) 260 261 #define FT_NEXT_LONG_LE( buffer ) \ 262 ( (long)( buffer += 4, FT_PEEK_LONG_LE( buffer - 4 ) ) ) 263 264 #define FT_NEXT_ULONG_LE( buffer ) \ 265 ( (unsigned long)( buffer += 4, FT_PEEK_ULONG_LE( buffer - 4 ) ) ) 266 267 268 /*************************************************************************/ 269 /* */ 270 /* Each GET_xxxx() macro uses an implicit `stream' variable. */ 271 /* */ 272 #define FT_GET_MACRO( func, type ) ( (type)func( stream ) ) 273 274 #define FT_GET_CHAR() FT_GET_MACRO( FT_Stream_GetChar, FT_Char ) 275 #define FT_GET_BYTE() FT_GET_MACRO( FT_Stream_GetChar, FT_Byte ) 276 #define FT_GET_SHORT() FT_GET_MACRO( FT_Stream_GetShort, FT_Short ) 277 #define FT_GET_USHORT() FT_GET_MACRO( FT_Stream_GetShort, FT_UShort ) 278 #define FT_GET_OFF3() FT_GET_MACRO( FT_Stream_GetOffset, FT_Long ) 279 #define FT_GET_UOFF3() FT_GET_MACRO( FT_Stream_GetOffset, FT_ULong ) 280 #define FT_GET_LONG() FT_GET_MACRO( FT_Stream_GetLong, FT_Long ) 281 #define FT_GET_ULONG() FT_GET_MACRO( FT_Stream_GetLong, FT_ULong ) 282 #define FT_GET_TAG4() FT_GET_MACRO( FT_Stream_GetLong, FT_ULong ) 283 284 #define FT_GET_SHORT_LE() FT_GET_MACRO( FT_Stream_GetShortLE, FT_Short ) 285 #define FT_GET_USHORT_LE() FT_GET_MACRO( FT_Stream_GetShortLE, FT_UShort ) 286 #define FT_GET_LONG_LE() FT_GET_MACRO( FT_Stream_GetLongLE, FT_Long ) 287 #define FT_GET_ULONG_LE() FT_GET_MACRO( FT_Stream_GetLongLE, FT_ULong ) 288 289 #define FT_READ_MACRO( func, type, var ) \ 290 ( var = (type)func( stream, &error ), \ 291 error != FT_Err_Ok ) 292 293 #define FT_READ_BYTE( var ) FT_READ_MACRO( FT_Stream_ReadChar, FT_Byte, var ) 294 #define FT_READ_CHAR( var ) FT_READ_MACRO( FT_Stream_ReadChar, FT_Char, var ) 295 #define FT_READ_SHORT( var ) FT_READ_MACRO( FT_Stream_ReadShort, FT_Short, var ) 296 #define FT_READ_USHORT( var ) FT_READ_MACRO( FT_Stream_ReadShort, FT_UShort, var ) 297 #define FT_READ_OFF3( var ) FT_READ_MACRO( FT_Stream_ReadOffset, FT_Long, var ) 298 #define FT_READ_UOFF3( var ) FT_READ_MACRO( FT_Stream_ReadOffset, FT_ULong, var ) 299 #define FT_READ_LONG( var ) FT_READ_MACRO( FT_Stream_ReadLong, FT_Long, var ) 300 #define FT_READ_ULONG( var ) FT_READ_MACRO( FT_Stream_ReadLong, FT_ULong, var ) 301 302 #define FT_READ_SHORT_LE( var ) FT_READ_MACRO( FT_Stream_ReadShortLE, FT_Short, var ) 303 #define FT_READ_USHORT_LE( var ) FT_READ_MACRO( FT_Stream_ReadShortLE, FT_UShort, var ) 304 #define FT_READ_LONG_LE( var ) FT_READ_MACRO( FT_Stream_ReadLongLE, FT_Long, var ) 305 #define FT_READ_ULONG_LE( var ) FT_READ_MACRO( FT_Stream_ReadLongLE, FT_ULong, var ) 306 307 308 #ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM 309 310 /* initialize a stream for reading a regular system stream */ 311 FT_EXPORT( FT_Error ) 312 FT_Stream_Open( FT_Stream stream, 313 const char* filepathname ); 314 315 #endif /* FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */ 316 317 318 /* initialize a stream for reading in-memory data */ 319 FT_BASE( void ) 320 FT_Stream_OpenMemory( FT_Stream stream, 321 const FT_Byte* base, 322 FT_ULong size ); 323 324 /* close a stream (does not destroy the stream structure) */ 325 FT_BASE( void ) 326 FT_Stream_Close( FT_Stream stream ); 327 328 329 /* seek within a stream. position is relative to start of stream */ 330 FT_BASE( FT_Error ) 331 FT_Stream_Seek( FT_Stream stream, 332 FT_ULong pos ); 333 334 /* skip bytes in a stream */ 335 FT_BASE( FT_Error ) 336 FT_Stream_Skip( FT_Stream stream, 337 FT_Long distance ); 338 339 /* return current stream position */ 340 FT_BASE( FT_Long ) 341 FT_Stream_Pos( FT_Stream stream ); 342 343 /* read bytes from a stream into a user-allocated buffer, returns an */ 344 /* error if not all bytes could be read. */ 345 FT_BASE( FT_Error ) 346 FT_Stream_Read( FT_Stream stream, 347 FT_Byte* buffer, 348 FT_ULong count ); 349 350 /* read bytes from a stream at a given position */ 351 FT_BASE( FT_Error ) 352 FT_Stream_ReadAt( FT_Stream stream, 353 FT_ULong pos, 354 FT_Byte* buffer, 355 FT_ULong count ); 356 357 /* Enter a frame of `count' consecutive bytes in a stream. Returns an */ 358 /* error if the frame could not be read/accessed. The caller can use */ 359 /* the FT_Stream_Get_XXX functions to retrieve frame data without */ 360 /* error checks. */ 361 /* */ 362 /* You must _always_ call FT_Stream_ExitFrame() once you have entered */ 363 /* a stream frame! */ 364 /* */ 365 FT_BASE( FT_Error ) 366 FT_Stream_EnterFrame( FT_Stream stream, 367 FT_ULong count ); 368 369 /* exit a stream frame */ 370 FT_BASE( void ) 371 FT_Stream_ExitFrame( FT_Stream stream ); 372 373 /* Extract a stream frame. If the stream is disk-based, a heap block */ 374 /* is allocated and the frame bytes are read into it. If the stream */ 375 /* is memory-based, this function simply set a pointer to the data. */ 376 /* */ 377 /* Useful to optimize access to memory-based streams transparently. */ 378 /* */ 379 /* All extracted frames must be `freed` with a call to the function */ 380 /* FT_Stream_ReleaseFrame(). */ 381 /* */ 382 FT_BASE( FT_Error ) 383 FT_Stream_ExtractFrame( FT_Stream stream, 384 FT_ULong count, 385 FT_Byte** pbytes ); 386 387 /* release an extract frame (see FT_Stream_ExtractFrame) */ 388 FT_BASE( void ) 389 FT_Stream_ReleaseFrame( FT_Stream stream, 390 FT_Byte** pbytes ); 391 392 /* read a byte from an entered frame */ 393 FT_BASE( FT_Char ) 394 FT_Stream_GetChar( FT_Stream stream ); 395 396 /* read a 16-bit big-endian integer from an entered frame */ 397 FT_BASE( FT_Short ) 398 FT_Stream_GetShort( FT_Stream stream ); 399 400 /* read a 24-bit big-endian integer from an entered frame */ 401 FT_BASE( FT_Long ) 402 FT_Stream_GetOffset( FT_Stream stream ); 403 404 /* read a 32-bit big-endian integer from an entered frame */ 405 FT_BASE( FT_Long ) 406 FT_Stream_GetLong( FT_Stream stream ); 407 408 /* read a 16-bit little-endian integer from an entered frame */ 409 FT_BASE( FT_Short ) 410 FT_Stream_GetShortLE( FT_Stream stream ); 411 412 /* read a 32-bit little-endian integer from an entered frame */ 413 FT_BASE( FT_Long ) 414 FT_Stream_GetLongLE( FT_Stream stream ); 415 416 417 /* read a byte from a stream */ 418 FT_BASE( FT_Char ) 419 FT_Stream_ReadChar( FT_Stream stream, 420 FT_Error* error ); 421 422 /* read a 16-bit big-endian integer from a stream */ 423 FT_BASE( FT_Short ) 424 FT_Stream_ReadShort( FT_Stream stream, 425 FT_Error* error ); 426 427 /* read a 24-bit big-endian integer from a stream */ 428 FT_BASE( FT_Long ) 429 FT_Stream_ReadOffset( FT_Stream stream, 430 FT_Error* error ); 431 432 /* read a 32-bit big-endian integer from a stream */ 433 FT_BASE( FT_Long ) 434 FT_Stream_ReadLong( FT_Stream stream, 435 FT_Error* error ); 436 437 /* read a 16-bit little-endian integer from a stream */ 438 FT_BASE( FT_Short ) 439 FT_Stream_ReadShortLE( FT_Stream stream, 440 FT_Error* error ); 441 442 /* read a 32-bit little-endian integer from a stream */ 443 FT_BASE( FT_Long ) 444 FT_Stream_ReadLongLE( FT_Stream stream, 445 FT_Error* error ); 446 447 /* Read a structure from a stream. The structure must be described */ 448 /* by an array of FT_Frame_Field records. */ 449 FT_BASE( FT_Error ) 450 FT_Stream_ReadFields( FT_Stream stream, 451 const FT_Frame_Field* fields, 452 void* structure ); 453 454 455 #define FT_STREAM_POS() \ 456 FT_Stream_Pos( stream ) 457 458 #define FT_STREAM_SEEK( position ) \ 459 FT_SET_ERROR( FT_Stream_Seek( stream, position ) ) 460 461 #define FT_STREAM_SKIP( distance ) \ 462 FT_SET_ERROR( FT_Stream_Skip( stream, distance ) ) 463 464 #define FT_STREAM_READ( buffer, count ) \ 465 FT_SET_ERROR( FT_Stream_Read( stream, \ 466 (FT_Byte*)buffer, \ 467 count ) ) 468 469 #define FT_STREAM_READ_AT( position, buffer, count ) \ 470 FT_SET_ERROR( FT_Stream_ReadAt( stream, \ 471 position, \ 472 (FT_Byte*)buffer, \ 473 count ) ) 474 475 #define FT_STREAM_READ_FIELDS( fields, object ) \ 476 FT_SET_ERROR( FT_Stream_ReadFields( stream, fields, object ) ) 477 478 479 #define FT_FRAME_ENTER( size ) \ 480 FT_SET_ERROR( FT_Stream_EnterFrame( stream, size ) ) 481 482 #define FT_FRAME_EXIT() \ 483 FT_Stream_ExitFrame( stream ) 484 485 #define FT_FRAME_EXTRACT( size, bytes ) \ 486 FT_SET_ERROR( FT_Stream_ExtractFrame( stream, size, \ 487 (FT_Byte**)&(bytes) ) ) 488 489 #define FT_FRAME_RELEASE( bytes ) \ 490 FT_Stream_ReleaseFrame( stream, (FT_Byte**)&(bytes) ) 491 492 493 FT_END_HEADER 494 495 #endif /* __FTSTREAM_H__ */ 496 497 498 /* END */ 499