1049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/***************************************************************************/ 2049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* */ 3049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* ftstream.h */ 4049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* */ 5049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* Stream handling (specification). */ 6049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* */ 7aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner/* Copyright 1996-2002, 2004-2006, 2011 by */ 8049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* */ 10049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* This file is part of the FreeType project, and may only be used, */ 11049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* modified, and distributed under the terms of the FreeType project */ 12049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* this file you indicate that you have read the license and */ 14049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* understand and accept it fully. */ 15049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* */ 16049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/***************************************************************************/ 17049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 18049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 19049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#ifndef __FTSTREAM_H__ 20049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define __FTSTREAM_H__ 21049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 22049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 23049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#include <ft2build.h> 24049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#include FT_SYSTEM_H 25049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#include FT_INTERNAL_OBJECTS_H 26049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 27049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 28049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source ProjectFT_BEGIN_HEADER 29049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 30049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 31049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* format of an 8-bit frame_op value: */ 32049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* */ 33049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* bit 76543210 */ 34049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* xxxxxxes */ 35049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* */ 36049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* s is set to 1 if the value is signed. */ 37049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* e is set to 1 if the value is little-endian. */ 38049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* xxx is a command. */ 39049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 40049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_OP_SHIFT 2 41049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_OP_SIGNED 1 42049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_OP_LITTLE 2 43049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_OP_COMMAND( x ) ( x >> FT_FRAME_OP_SHIFT ) 44049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 45049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_MAKE_FRAME_OP( command, little, sign ) \ 46049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ( ( command << FT_FRAME_OP_SHIFT ) | ( little << 1 ) | sign ) 47049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 48049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_OP_END 0 49049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_OP_START 1 /* start a new frame */ 50049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_OP_BYTE 2 /* read 1-byte value */ 51049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_OP_SHORT 3 /* read 2-byte value */ 52049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_OP_LONG 4 /* read 4-byte value */ 53049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_OP_OFF3 5 /* read 3-byte value */ 54049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_OP_BYTES 6 /* read a bytes sequence */ 55049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 56049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 57049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project typedef enum FT_Frame_Op_ 58049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project { 59049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ft_frame_end = 0, 60049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ft_frame_start = FT_MAKE_FRAME_OP( FT_FRAME_OP_START, 0, 0 ), 61049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 62049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ft_frame_byte = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTE, 0, 0 ), 63049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ft_frame_schar = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTE, 0, 1 ), 64049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 65049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ft_frame_ushort_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 0, 0 ), 66049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ft_frame_short_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 0, 1 ), 67049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ft_frame_ushort_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 1, 0 ), 68049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ft_frame_short_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 1, 1 ), 69049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 70049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ft_frame_ulong_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 0, 0 ), 71049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ft_frame_long_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 0, 1 ), 72049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ft_frame_ulong_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 1, 0 ), 73049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ft_frame_long_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 1, 1 ), 74049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 75049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ft_frame_uoff3_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 0, 0 ), 76049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ft_frame_off3_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 0, 1 ), 77049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ft_frame_uoff3_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 1, 0 ), 78049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ft_frame_off3_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 1, 1 ), 79049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 80049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ft_frame_bytes = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTES, 0, 0 ), 81049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ft_frame_skip = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTES, 0, 1 ) 82049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 83049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project } FT_Frame_Op; 84049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 85049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 86049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project typedef struct FT_Frame_Field_ 87049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project { 88049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Byte value; 89049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Byte size; 90049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_UShort offset; 91049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 92049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project } FT_Frame_Field; 93049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 94049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 95049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* Construct an FT_Frame_Field out of a structure type and a field name. */ 96049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* The structure type must be set in the FT_STRUCTURE macro before */ 97049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* calling the FT_FRAME_START() macro. */ 98049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* */ 99049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FIELD_SIZE( f ) \ 100049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project (FT_Byte)sizeof ( ((FT_STRUCTURE*)0)->f ) 101049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 102049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FIELD_SIZE_DELTA( f ) \ 103049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project (FT_Byte)sizeof ( ((FT_STRUCTURE*)0)->f[0] ) 104049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 105049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FIELD_OFFSET( f ) \ 106049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project (FT_UShort)( offsetof( FT_STRUCTURE, f ) ) 107049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 108049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_FIELD( frame_op, field ) \ 109049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project { \ 110049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project frame_op, \ 111049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_FIELD_SIZE( field ), \ 112049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_FIELD_OFFSET( field ) \ 113049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project } 114049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 115049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_MAKE_EMPTY_FIELD( frame_op ) { frame_op, 0, 0 } 116049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 117049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_START( size ) { ft_frame_start, 0, size } 118049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_END { ft_frame_end, 0, 0 } 119049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 120049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_LONG( f ) FT_FRAME_FIELD( ft_frame_long_be, f ) 121049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_ULONG( f ) FT_FRAME_FIELD( ft_frame_ulong_be, f ) 122049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_SHORT( f ) FT_FRAME_FIELD( ft_frame_short_be, f ) 123049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_USHORT( f ) FT_FRAME_FIELD( ft_frame_ushort_be, f ) 124049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_OFF3( f ) FT_FRAME_FIELD( ft_frame_off3_be, f ) 125049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_UOFF3( f ) FT_FRAME_FIELD( ft_frame_uoff3_be, f ) 126049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_BYTE( f ) FT_FRAME_FIELD( ft_frame_byte, f ) 127049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_CHAR( f ) FT_FRAME_FIELD( ft_frame_schar, f ) 128049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 129049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_LONG_LE( f ) FT_FRAME_FIELD( ft_frame_long_le, f ) 130049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_ULONG_LE( f ) FT_FRAME_FIELD( ft_frame_ulong_le, f ) 131049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_SHORT_LE( f ) FT_FRAME_FIELD( ft_frame_short_le, f ) 132049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_USHORT_LE( f ) FT_FRAME_FIELD( ft_frame_ushort_le, f ) 133049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_OFF3_LE( f ) FT_FRAME_FIELD( ft_frame_off3_le, f ) 134049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_UOFF3_LE( f ) FT_FRAME_FIELD( ft_frame_uoff3_le, f ) 135049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 136049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_SKIP_LONG { ft_frame_long_be, 0, 0 } 137049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_SKIP_SHORT { ft_frame_short_be, 0, 0 } 138049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_SKIP_BYTE { ft_frame_byte, 0, 0 } 139049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 140049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_BYTES( field, count ) \ 141049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project { \ 142049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ft_frame_bytes, \ 143049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project count, \ 144049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_FIELD_OFFSET( field ) \ 145049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project } 146049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 147049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_SKIP_BYTES( count ) { ft_frame_skip, count, 0 } 148049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 149049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 150049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /*************************************************************************/ 151049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* */ 152049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* Integer extraction macros -- the `buffer' parameter must ALWAYS be of */ 153049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* type `char*' or equivalent (1-byte elements). */ 154049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* */ 155049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 156049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_BYTE_( p, i ) ( ((const FT_Byte*)(p))[(i)] ) 157049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_INT8_( p, i ) ( ((const FT_Char*)(p))[(i)] ) 158049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 159049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_INT16( x ) ( (FT_Int16)(x) ) 160049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_UINT16( x ) ( (FT_UInt16)(x) ) 161049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_INT32( x ) ( (FT_Int32)(x) ) 162049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_UINT32( x ) ( (FT_UInt32)(x) ) 163049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 164049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_BYTE_I16( p, i, s ) ( FT_INT16( FT_BYTE_( p, i ) ) << (s) ) 165049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_BYTE_U16( p, i, s ) ( FT_UINT16( FT_BYTE_( p, i ) ) << (s) ) 166049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_BYTE_I32( p, i, s ) ( FT_INT32( FT_BYTE_( p, i ) ) << (s) ) 167049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_BYTE_U32( p, i, s ) ( FT_UINT32( FT_BYTE_( p, i ) ) << (s) ) 168049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 169049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_INT8_I16( p, i, s ) ( FT_INT16( FT_INT8_( p, i ) ) << (s) ) 170049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_INT8_U16( p, i, s ) ( FT_UINT16( FT_INT8_( p, i ) ) << (s) ) 171049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_INT8_I32( p, i, s ) ( FT_INT32( FT_INT8_( p, i ) ) << (s) ) 172049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_INT8_U32( p, i, s ) ( FT_UINT32( FT_INT8_( p, i ) ) << (s) ) 173049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 174049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 175049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_PEEK_SHORT( p ) FT_INT16( FT_INT8_I16( p, 0, 8) | \ 176049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BYTE_I16( p, 1, 0) ) 177049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 178049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_PEEK_USHORT( p ) FT_UINT16( FT_BYTE_U16( p, 0, 8 ) | \ 179049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BYTE_U16( p, 1, 0 ) ) 180049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 181049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_PEEK_LONG( p ) FT_INT32( FT_INT8_I32( p, 0, 24 ) | \ 182049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BYTE_I32( p, 1, 16 ) | \ 183049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BYTE_I32( p, 2, 8 ) | \ 184049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BYTE_I32( p, 3, 0 ) ) 185049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 186049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_PEEK_ULONG( p ) FT_UINT32( FT_BYTE_U32( p, 0, 24 ) | \ 187049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BYTE_U32( p, 1, 16 ) | \ 188049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BYTE_U32( p, 2, 8 ) | \ 189049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BYTE_U32( p, 3, 0 ) ) 190049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 191049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_PEEK_OFF3( p ) FT_INT32( FT_INT8_I32( p, 0, 16 ) | \ 192049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BYTE_I32( p, 1, 8 ) | \ 193049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BYTE_I32( p, 2, 0 ) ) 194049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 195049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_PEEK_UOFF3( p ) FT_UINT32( FT_BYTE_U32( p, 0, 16 ) | \ 196049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BYTE_U32( p, 1, 8 ) | \ 197049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BYTE_U32( p, 2, 0 ) ) 198049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 199049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_PEEK_SHORT_LE( p ) FT_INT16( FT_INT8_I16( p, 1, 8 ) | \ 200049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BYTE_I16( p, 0, 0 ) ) 201049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 202049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_PEEK_USHORT_LE( p ) FT_UINT16( FT_BYTE_U16( p, 1, 8 ) | \ 203049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BYTE_U16( p, 0, 0 ) ) 204049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 205049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_PEEK_LONG_LE( p ) FT_INT32( FT_INT8_I32( p, 3, 24 ) | \ 206049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BYTE_I32( p, 2, 16 ) | \ 207049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BYTE_I32( p, 1, 8 ) | \ 208049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BYTE_I32( p, 0, 0 ) ) 209049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 210049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_PEEK_ULONG_LE( p ) FT_UINT32( FT_BYTE_U32( p, 3, 24 ) | \ 211049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BYTE_U32( p, 2, 16 ) | \ 212049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BYTE_U32( p, 1, 8 ) | \ 213049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BYTE_U32( p, 0, 0 ) ) 214049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 215049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_PEEK_OFF3_LE( p ) FT_INT32( FT_INT8_I32( p, 2, 16 ) | \ 216049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BYTE_I32( p, 1, 8 ) | \ 217049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BYTE_I32( p, 0, 0 ) ) 218049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 219049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_PEEK_UOFF3_LE( p ) FT_UINT32( FT_BYTE_U32( p, 2, 16 ) | \ 220049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BYTE_U32( p, 1, 8 ) | \ 221049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BYTE_U32( p, 0, 0 ) ) 222049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 223049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 224049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_NEXT_CHAR( buffer ) \ 225049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ( (signed char)*buffer++ ) 226049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 227049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_NEXT_BYTE( buffer ) \ 228049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ( (unsigned char)*buffer++ ) 229049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 230049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_NEXT_SHORT( buffer ) \ 231049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ( (short)( buffer += 2, FT_PEEK_SHORT( buffer - 2 ) ) ) 232049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 233049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_NEXT_USHORT( buffer ) \ 234049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ( (unsigned short)( buffer += 2, FT_PEEK_USHORT( buffer - 2 ) ) ) 235049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 236049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_NEXT_OFF3( buffer ) \ 237049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ( (long)( buffer += 3, FT_PEEK_OFF3( buffer - 3 ) ) ) 238049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 239049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_NEXT_UOFF3( buffer ) \ 240049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ( (unsigned long)( buffer += 3, FT_PEEK_UOFF3( buffer - 3 ) ) ) 241049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 242049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_NEXT_LONG( buffer ) \ 243049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ( (long)( buffer += 4, FT_PEEK_LONG( buffer - 4 ) ) ) 244049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 245049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_NEXT_ULONG( buffer ) \ 246049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ( (unsigned long)( buffer += 4, FT_PEEK_ULONG( buffer - 4 ) ) ) 247049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 248049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 249049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_NEXT_SHORT_LE( buffer ) \ 250049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ( (short)( buffer += 2, FT_PEEK_SHORT_LE( buffer - 2 ) ) ) 251049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 252049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_NEXT_USHORT_LE( buffer ) \ 253049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ( (unsigned short)( buffer += 2, FT_PEEK_USHORT_LE( buffer - 2 ) ) ) 254049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 255049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_NEXT_OFF3_LE( buffer ) \ 256049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ( (long)( buffer += 3, FT_PEEK_OFF3_LE( buffer - 3 ) ) ) 257049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 258049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_NEXT_UOFF3_LE( buffer ) \ 259049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ( (unsigned long)( buffer += 3, FT_PEEK_UOFF3_LE( buffer - 3 ) ) ) 260049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 261049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_NEXT_LONG_LE( buffer ) \ 262049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ( (long)( buffer += 4, FT_PEEK_LONG_LE( buffer - 4 ) ) ) 263049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 264049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_NEXT_ULONG_LE( buffer ) \ 265049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ( (unsigned long)( buffer += 4, FT_PEEK_ULONG_LE( buffer - 4 ) ) ) 266049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 267049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 268049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /*************************************************************************/ 269049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* */ 270049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* Each GET_xxxx() macro uses an implicit `stream' variable. */ 271049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* */ 272049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#if 0 273049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_GET_MACRO( type ) FT_NEXT_ ## type ( stream->cursor ) 274049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 275049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_GET_CHAR() FT_GET_MACRO( CHAR ) 276049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_GET_BYTE() FT_GET_MACRO( BYTE ) 277049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_GET_SHORT() FT_GET_MACRO( SHORT ) 278049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_GET_USHORT() FT_GET_MACRO( USHORT ) 279049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_GET_OFF3() FT_GET_MACRO( OFF3 ) 280049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_GET_UOFF3() FT_GET_MACRO( UOFF3 ) 281049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_GET_LONG() FT_GET_MACRO( LONG ) 282049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_GET_ULONG() FT_GET_MACRO( ULONG ) 283049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_GET_TAG4() FT_GET_MACRO( ULONG ) 284049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 285049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_GET_SHORT_LE() FT_GET_MACRO( SHORT_LE ) 286049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_GET_USHORT_LE() FT_GET_MACRO( USHORT_LE ) 287049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_GET_LONG_LE() FT_GET_MACRO( LONG_LE ) 288049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_GET_ULONG_LE() FT_GET_MACRO( ULONG_LE ) 289049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 290049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#else 291049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_GET_MACRO( func, type ) ( (type)func( stream ) ) 292049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 293049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_GET_CHAR() FT_GET_MACRO( FT_Stream_GetChar, FT_Char ) 294049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_GET_BYTE() FT_GET_MACRO( FT_Stream_GetChar, FT_Byte ) 295aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner#define FT_GET_SHORT() FT_GET_MACRO( FT_Stream_GetUShort, FT_Short ) 296aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner#define FT_GET_USHORT() FT_GET_MACRO( FT_Stream_GetUShort, FT_UShort ) 297aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner#define FT_GET_OFF3() FT_GET_MACRO( FT_Stream_GetUOffset, FT_Long ) 298aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner#define FT_GET_UOFF3() FT_GET_MACRO( FT_Stream_GetUOffset, FT_ULong ) 299aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner#define FT_GET_LONG() FT_GET_MACRO( FT_Stream_GetULong, FT_Long ) 300aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner#define FT_GET_ULONG() FT_GET_MACRO( FT_Stream_GetULong, FT_ULong ) 301aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner#define FT_GET_TAG4() FT_GET_MACRO( FT_Stream_GetULong, FT_ULong ) 302aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner 303aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner#define FT_GET_SHORT_LE() FT_GET_MACRO( FT_Stream_GetUShortLE, FT_Short ) 304aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner#define FT_GET_USHORT_LE() FT_GET_MACRO( FT_Stream_GetUShortLE, FT_UShort ) 305aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner#define FT_GET_LONG_LE() FT_GET_MACRO( FT_Stream_GetULongLE, FT_Long ) 306aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner#define FT_GET_ULONG_LE() FT_GET_MACRO( FT_Stream_GetULongLE, FT_ULong ) 307049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#endif 308049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 309049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_READ_MACRO( func, type, var ) \ 310049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ( var = (type)func( stream, &error ), \ 311049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project error != FT_Err_Ok ) 312049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 313049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_READ_BYTE( var ) FT_READ_MACRO( FT_Stream_ReadChar, FT_Byte, var ) 314049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_READ_CHAR( var ) FT_READ_MACRO( FT_Stream_ReadChar, FT_Char, var ) 315aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner#define FT_READ_SHORT( var ) FT_READ_MACRO( FT_Stream_ReadUShort, FT_Short, var ) 316aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner#define FT_READ_USHORT( var ) FT_READ_MACRO( FT_Stream_ReadUShort, FT_UShort, var ) 317aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner#define FT_READ_OFF3( var ) FT_READ_MACRO( FT_Stream_ReadUOffset, FT_Long, var ) 318aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner#define FT_READ_UOFF3( var ) FT_READ_MACRO( FT_Stream_ReadUOffset, FT_ULong, var ) 319aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner#define FT_READ_LONG( var ) FT_READ_MACRO( FT_Stream_ReadULong, FT_Long, var ) 320aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner#define FT_READ_ULONG( var ) FT_READ_MACRO( FT_Stream_ReadULong, FT_ULong, var ) 321049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 322aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner#define FT_READ_SHORT_LE( var ) FT_READ_MACRO( FT_Stream_ReadUShortLE, FT_Short, var ) 323aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner#define FT_READ_USHORT_LE( var ) FT_READ_MACRO( FT_Stream_ReadUShortLE, FT_UShort, var ) 324aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner#define FT_READ_LONG_LE( var ) FT_READ_MACRO( FT_Stream_ReadULongLE, FT_Long, var ) 325aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner#define FT_READ_ULONG_LE( var ) FT_READ_MACRO( FT_Stream_ReadULongLE, FT_ULong, var ) 326049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 327049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 328049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM 329049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 330049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* initialize a stream for reading a regular system stream */ 331049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BASE( FT_Error ) 332049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Stream_Open( FT_Stream stream, 333049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project const char* filepathname ); 334049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 335049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#endif /* FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */ 336049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 337049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 338049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* create a new (input) stream from an FT_Open_Args structure */ 339049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BASE( FT_Error ) 340049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Stream_New( FT_Library library, 341049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project const FT_Open_Args* args, 342049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Stream *astream ); 343049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 344049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* free a stream */ 345049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BASE( void ) 346049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Stream_Free( FT_Stream stream, 347049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Int external ); 348049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 349049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* initialize a stream for reading in-memory data */ 350049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BASE( void ) 351049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Stream_OpenMemory( FT_Stream stream, 352049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project const FT_Byte* base, 353049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_ULong size ); 354049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 355049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* close a stream (does not destroy the stream structure) */ 356049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BASE( void ) 357049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Stream_Close( FT_Stream stream ); 358049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 359049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 360049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* seek within a stream. position is relative to start of stream */ 361049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BASE( FT_Error ) 362049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Stream_Seek( FT_Stream stream, 363049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_ULong pos ); 364049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 365049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* skip bytes in a stream */ 366049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BASE( FT_Error ) 367049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Stream_Skip( FT_Stream stream, 368049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Long distance ); 369049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 370049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* return current stream position */ 371049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BASE( FT_Long ) 372049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Stream_Pos( FT_Stream stream ); 373049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 374049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* read bytes from a stream into a user-allocated buffer, returns an */ 375049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* error if not all bytes could be read. */ 376049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BASE( FT_Error ) 377049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Stream_Read( FT_Stream stream, 378049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Byte* buffer, 379049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_ULong count ); 380049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 381049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* read bytes from a stream at a given position */ 382049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BASE( FT_Error ) 383049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Stream_ReadAt( FT_Stream stream, 384049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_ULong pos, 385049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Byte* buffer, 386049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_ULong count ); 387049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 388049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* try to read bytes at the end of a stream; return number of bytes */ 389049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* really available */ 390049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BASE( FT_ULong ) 391049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Stream_TryRead( FT_Stream stream, 392049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Byte* buffer, 393049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_ULong count ); 394049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 395049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* Enter a frame of `count' consecutive bytes in a stream. Returns an */ 396049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* error if the frame could not be read/accessed. The caller can use */ 397049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* the FT_Stream_Get_XXX functions to retrieve frame data without */ 398049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* error checks. */ 399049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* */ 400049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* You must _always_ call FT_Stream_ExitFrame() once you have entered */ 401049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* a stream frame! */ 402049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* */ 403049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BASE( FT_Error ) 404049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Stream_EnterFrame( FT_Stream stream, 405049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_ULong count ); 406049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 407049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* exit a stream frame */ 408049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BASE( void ) 409049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Stream_ExitFrame( FT_Stream stream ); 410049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 411049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* Extract a stream frame. If the stream is disk-based, a heap block */ 412049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* is allocated and the frame bytes are read into it. If the stream */ 413049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* is memory-based, this function simply set a pointer to the data. */ 414049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* */ 415049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* Useful to optimize access to memory-based streams transparently. */ 416049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* */ 417049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* All extracted frames must be `freed' with a call to the function */ 418049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* FT_Stream_ReleaseFrame(). */ 419049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* */ 420049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BASE( FT_Error ) 421049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Stream_ExtractFrame( FT_Stream stream, 422049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_ULong count, 423049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Byte** pbytes ); 424049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 425049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* release an extract frame (see FT_Stream_ExtractFrame) */ 426049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BASE( void ) 427049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Stream_ReleaseFrame( FT_Stream stream, 428049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Byte** pbytes ); 429049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 430049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* read a byte from an entered frame */ 431049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BASE( FT_Char ) 432049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Stream_GetChar( FT_Stream stream ); 433049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 434aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner /* read a 16-bit big-endian unsigned integer from an entered frame */ 435aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner FT_BASE( FT_UShort ) 436aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner FT_Stream_GetUShort( FT_Stream stream ); 437049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 438aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner /* read a 24-bit big-endian unsigned integer from an entered frame */ 439aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner FT_BASE( FT_ULong ) 440aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner FT_Stream_GetUOffset( FT_Stream stream ); 441049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 442aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner /* read a 32-bit big-endian unsigned integer from an entered frame */ 443aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner FT_BASE( FT_ULong ) 444aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner FT_Stream_GetULong( FT_Stream stream ); 445049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 446aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner /* read a 16-bit little-endian unsigned integer from an entered frame */ 447aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner FT_BASE( FT_UShort ) 448aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner FT_Stream_GetUShortLE( FT_Stream stream ); 449049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 450aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner /* read a 32-bit little-endian unsigned integer from an entered frame */ 451aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner FT_BASE( FT_ULong ) 452aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner FT_Stream_GetULongLE( FT_Stream stream ); 453049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 454049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 455049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* read a byte from a stream */ 456049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BASE( FT_Char ) 457049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Stream_ReadChar( FT_Stream stream, 458049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Error* error ); 459049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 460aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner /* read a 16-bit big-endian unsigned integer from a stream */ 461aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner FT_BASE( FT_UShort ) 462aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner FT_Stream_ReadUShort( FT_Stream stream, 463bff90fb5ec88ad7fdfb6d1d2f5a5719c20a2c5dcOlivier Bailly FT_Error* error ); 464049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 465aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner /* read a 24-bit big-endian unsigned integer from a stream */ 466aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner FT_BASE( FT_ULong ) 467aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner FT_Stream_ReadUOffset( FT_Stream stream, 468bff90fb5ec88ad7fdfb6d1d2f5a5719c20a2c5dcOlivier Bailly FT_Error* error ); 469049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 470049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* read a 32-bit big-endian integer from a stream */ 471aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner FT_BASE( FT_ULong ) 472aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner FT_Stream_ReadULong( FT_Stream stream, 473bff90fb5ec88ad7fdfb6d1d2f5a5719c20a2c5dcOlivier Bailly FT_Error* error ); 474049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 475aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner /* read a 16-bit little-endian unsigned integer from a stream */ 476aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner FT_BASE( FT_UShort ) 477aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner FT_Stream_ReadUShortLE( FT_Stream stream, 478bff90fb5ec88ad7fdfb6d1d2f5a5719c20a2c5dcOlivier Bailly FT_Error* error ); 479049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 480aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner /* read a 32-bit little-endian unsigned integer from a stream */ 481aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner FT_BASE( FT_ULong ) 482aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner FT_Stream_ReadULongLE( FT_Stream stream, 483bff90fb5ec88ad7fdfb6d1d2f5a5719c20a2c5dcOlivier Bailly FT_Error* error ); 484049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 485049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* Read a structure from a stream. The structure must be described */ 486049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* by an array of FT_Frame_Field records. */ 487049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BASE( FT_Error ) 488049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Stream_ReadFields( FT_Stream stream, 489049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project const FT_Frame_Field* fields, 490049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project void* structure ); 491049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 492049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 493049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_STREAM_POS() \ 494049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Stream_Pos( stream ) 495049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 496049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_STREAM_SEEK( position ) \ 497049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_SET_ERROR( FT_Stream_Seek( stream, position ) ) 498049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 499049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_STREAM_SKIP( distance ) \ 500049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_SET_ERROR( FT_Stream_Skip( stream, distance ) ) 501049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 502049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_STREAM_READ( buffer, count ) \ 503049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_SET_ERROR( FT_Stream_Read( stream, \ 504049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project (FT_Byte*)buffer, \ 505049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project count ) ) 506049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 507049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_STREAM_READ_AT( position, buffer, count ) \ 508049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_SET_ERROR( FT_Stream_ReadAt( stream, \ 509049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project position, \ 510049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project (FT_Byte*)buffer, \ 511049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project count ) ) 512049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 513049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_STREAM_READ_FIELDS( fields, object ) \ 514049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_SET_ERROR( FT_Stream_ReadFields( stream, fields, object ) ) 515049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 516049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 517049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_ENTER( size ) \ 518049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_SET_ERROR( \ 519049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_DEBUG_INNER( FT_Stream_EnterFrame( stream, size ) ) ) 520049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 521049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_EXIT() \ 522049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_DEBUG_INNER( FT_Stream_ExitFrame( stream ) ) 523049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 524049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_EXTRACT( size, bytes ) \ 525049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_SET_ERROR( \ 526049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_DEBUG_INNER( FT_Stream_ExtractFrame( stream, size, \ 527049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project (FT_Byte**)&(bytes) ) ) ) 528049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 529049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#define FT_FRAME_RELEASE( bytes ) \ 530049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_DEBUG_INNER( FT_Stream_ReleaseFrame( stream, \ 531049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project (FT_Byte**)&(bytes) ) ) 532049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 533049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 534049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source ProjectFT_END_HEADER 535049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 536049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#endif /* __FTSTREAM_H__ */ 537049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 538049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 539049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* END */ 540