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 158 #define FT_INT16( x ) ( (FT_Int16)(x) ) 159 #define FT_UINT16( x ) ( (FT_UInt16)(x) ) 160 #define FT_INT32( x ) ( (FT_Int32)(x) ) 161 #define FT_UINT32( x ) ( (FT_UInt32)(x) ) 162 163 164 #define FT_BYTE_U16( p, i, s ) ( FT_UINT16( FT_BYTE_( p, i ) ) << (s) ) 165 #define FT_BYTE_U32( p, i, s ) ( FT_UINT32( FT_BYTE_( p, i ) ) << (s) ) 166 167 168 /* 169 * `FT_PEEK_XXX' are generic macros to get data from a buffer position. No 170 * safety checks are performed. 171 */ 172 #define FT_PEEK_SHORT( p ) FT_INT16( FT_BYTE_U16( p, 0, 8 ) | \ 173 FT_BYTE_U16( p, 1, 0 ) ) 174 175 #define FT_PEEK_USHORT( p ) FT_UINT16( FT_BYTE_U16( p, 0, 8 ) | \ 176 FT_BYTE_U16( p, 1, 0 ) ) 177 178 #define FT_PEEK_LONG( p ) FT_INT32( FT_BYTE_U32( p, 0, 24 ) | \ 179 FT_BYTE_U32( p, 1, 16 ) | \ 180 FT_BYTE_U32( p, 2, 8 ) | \ 181 FT_BYTE_U32( p, 3, 0 ) ) 182 183 #define FT_PEEK_ULONG( p ) FT_UINT32( FT_BYTE_U32( p, 0, 24 ) | \ 184 FT_BYTE_U32( p, 1, 16 ) | \ 185 FT_BYTE_U32( p, 2, 8 ) | \ 186 FT_BYTE_U32( p, 3, 0 ) ) 187 188 #define FT_PEEK_OFF3( p ) FT_INT32( FT_BYTE_U32( p, 0, 16 ) | \ | 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 158 #define FT_INT16( x ) ( (FT_Int16)(x) ) 159 #define FT_UINT16( x ) ( (FT_UInt16)(x) ) 160 #define FT_INT32( x ) ( (FT_Int32)(x) ) 161 #define FT_UINT32( x ) ( (FT_UInt32)(x) ) 162 163 164 #define FT_BYTE_U16( p, i, s ) ( FT_UINT16( FT_BYTE_( p, i ) ) << (s) ) 165 #define FT_BYTE_U32( p, i, s ) ( FT_UINT32( FT_BYTE_( p, i ) ) << (s) ) 166 167 168 /* 169 * function acts on increases does range for emits 170 * pointer checking frames error 171 * ------------------------------------------------------------------- 172 * FT_PEEK_XXX buffer pointer no no no no 173 * FT_NEXT_XXX buffer pointer yes no no no 174 * FT_GET_XXX stream->cursor yes yes yes no 175 * FT_READ_XXX stream->pos yes yes no yes 176 */ 177 178 179 /* 180 * `FT_PEEK_XXX' are generic macros to get data from a buffer position. No 181 * safety checks are performed. 182 */ 183 #define FT_PEEK_SHORT( p ) FT_INT16( FT_BYTE_U16( p, 0, 8 ) | \ 184 FT_BYTE_U16( p, 1, 0 ) ) 185 186 #define FT_PEEK_USHORT( p ) FT_UINT16( FT_BYTE_U16( p, 0, 8 ) | \ 187 FT_BYTE_U16( p, 1, 0 ) ) 188 189 #define FT_PEEK_LONG( p ) FT_INT32( FT_BYTE_U32( p, 0, 24 ) | \ 190 FT_BYTE_U32( p, 1, 16 ) | \ 191 FT_BYTE_U32( p, 2, 8 ) | \ 192 FT_BYTE_U32( p, 3, 0 ) ) 193 194 #define FT_PEEK_ULONG( p ) FT_UINT32( FT_BYTE_U32( p, 0, 24 ) | \ 195 FT_BYTE_U32( p, 1, 16 ) | \ 196 FT_BYTE_U32( p, 2, 8 ) | \ 197 FT_BYTE_U32( p, 3, 0 ) ) 198 199 #define FT_PEEK_OFF3( p ) FT_INT32( FT_BYTE_U32( p, 0, 16 ) | \ |