/modules/freetype2/include/freetype/internal/ftstream.h

http://github.com/zpao/v8monkey · C Header · 539 lines · 325 code · 130 blank · 84 comment · 1 complexity · 098f6efd19fa4a2906cf728ea266a1f0 MD5 · raw file

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