ftstream.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. /***************************************************************************/
  2. /* */
  3. /* ftstream.h */
  4. /* */
  5. /* Stream handling (specification). */
  6. /* */
  7. /* Copyright 1996-2002, 2004-2006, 2011, 2013 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_INT16( x ) ( (FT_Int16)(x) )
  121. #define FT_UINT16( x ) ( (FT_UInt16)(x) )
  122. #define FT_INT32( x ) ( (FT_Int32)(x) )
  123. #define FT_UINT32( x ) ( (FT_UInt32)(x) )
  124. #define FT_BYTE_U16( p, i, s ) ( FT_UINT16( FT_BYTE_( p, i ) ) << (s) )
  125. #define FT_BYTE_U32( p, i, s ) ( FT_UINT32( FT_BYTE_( p, i ) ) << (s) )
  126. #define FT_PEEK_SHORT( p ) FT_INT16( FT_BYTE_U16( p, 0, 8) | \
  127. FT_BYTE_U16( p, 1, 0) )
  128. #define FT_PEEK_USHORT( p ) FT_UINT16( FT_BYTE_U16( p, 0, 8 ) | \
  129. FT_BYTE_U16( p, 1, 0 ) )
  130. #define FT_PEEK_LONG( p ) FT_INT32( FT_BYTE_U32( p, 0, 24 ) | \
  131. FT_BYTE_U32( p, 1, 16 ) | \
  132. FT_BYTE_U32( p, 2, 8 ) | \
  133. FT_BYTE_U32( p, 3, 0 ) )
  134. #define FT_PEEK_ULONG( p ) FT_UINT32( FT_BYTE_U32( p, 0, 24 ) | \
  135. FT_BYTE_U32( p, 1, 16 ) | \
  136. FT_BYTE_U32( p, 2, 8 ) | \
  137. FT_BYTE_U32( p, 3, 0 ) )
  138. #define FT_PEEK_OFF3( p ) FT_INT32( FT_BYTE_U32( p, 0, 16 ) | \
  139. FT_BYTE_U32( p, 1, 8 ) | \
  140. FT_BYTE_U32( p, 2, 0 ) )
  141. #define FT_PEEK_UOFF3( p ) FT_UINT32( FT_BYTE_U32( p, 0, 16 ) | \
  142. FT_BYTE_U32( p, 1, 8 ) | \
  143. FT_BYTE_U32( p, 2, 0 ) )
  144. #define FT_PEEK_SHORT_LE( p ) FT_INT16( FT_BYTE_U16( p, 1, 8 ) | \
  145. FT_BYTE_U16( p, 0, 0 ) )
  146. #define FT_PEEK_USHORT_LE( p ) FT_UINT16( FT_BYTE_U16( p, 1, 8 ) | \
  147. FT_BYTE_U16( p, 0, 0 ) )
  148. #define FT_PEEK_LONG_LE( p ) FT_INT32( FT_BYTE_U32( p, 3, 24 ) | \
  149. FT_BYTE_U32( p, 2, 16 ) | \
  150. FT_BYTE_U32( p, 1, 8 ) | \
  151. FT_BYTE_U32( p, 0, 0 ) )
  152. #define FT_PEEK_ULONG_LE( p ) FT_UINT32( FT_BYTE_U32( p, 3, 24 ) | \
  153. FT_BYTE_U32( p, 2, 16 ) | \
  154. FT_BYTE_U32( p, 1, 8 ) | \
  155. FT_BYTE_U32( p, 0, 0 ) )
  156. #define FT_PEEK_OFF3_LE( p ) FT_INT32( FT_BYTE_U32( p, 2, 16 ) | \
  157. FT_BYTE_U32( p, 1, 8 ) | \
  158. FT_BYTE_U32( p, 0, 0 ) )
  159. #define FT_PEEK_UOFF3_LE( p ) FT_UINT32( FT_BYTE_U32( p, 2, 16 ) | \
  160. FT_BYTE_U32( p, 1, 8 ) | \
  161. FT_BYTE_U32( p, 0, 0 ) )
  162. #define FT_NEXT_CHAR( buffer ) \
  163. ( (signed char)*buffer++ )
  164. #define FT_NEXT_BYTE( buffer ) \
  165. ( (unsigned char)*buffer++ )
  166. #define FT_NEXT_SHORT( buffer ) \
  167. ( (short)( buffer += 2, FT_PEEK_SHORT( buffer - 2 ) ) )
  168. #define FT_NEXT_USHORT( buffer ) \
  169. ( (unsigned short)( buffer += 2, FT_PEEK_USHORT( buffer - 2 ) ) )
  170. #define FT_NEXT_OFF3( buffer ) \
  171. ( (long)( buffer += 3, FT_PEEK_OFF3( buffer - 3 ) ) )
  172. #define FT_NEXT_UOFF3( buffer ) \
  173. ( (unsigned long)( buffer += 3, FT_PEEK_UOFF3( buffer - 3 ) ) )
  174. #define FT_NEXT_LONG( buffer ) \
  175. ( (long)( buffer += 4, FT_PEEK_LONG( buffer - 4 ) ) )
  176. #define FT_NEXT_ULONG( buffer ) \
  177. ( (unsigned long)( buffer += 4, FT_PEEK_ULONG( buffer - 4 ) ) )
  178. #define FT_NEXT_SHORT_LE( buffer ) \
  179. ( (short)( buffer += 2, FT_PEEK_SHORT_LE( buffer - 2 ) ) )
  180. #define FT_NEXT_USHORT_LE( buffer ) \
  181. ( (unsigned short)( buffer += 2, FT_PEEK_USHORT_LE( buffer - 2 ) ) )
  182. #define FT_NEXT_OFF3_LE( buffer ) \
  183. ( (long)( buffer += 3, FT_PEEK_OFF3_LE( buffer - 3 ) ) )
  184. #define FT_NEXT_UOFF3_LE( buffer ) \
  185. ( (unsigned long)( buffer += 3, FT_PEEK_UOFF3_LE( buffer - 3 ) ) )
  186. #define FT_NEXT_LONG_LE( buffer ) \
  187. ( (long)( buffer += 4, FT_PEEK_LONG_LE( buffer - 4 ) ) )
  188. #define FT_NEXT_ULONG_LE( buffer ) \
  189. ( (unsigned long)( buffer += 4, FT_PEEK_ULONG_LE( buffer - 4 ) ) )
  190. /*************************************************************************/
  191. /* */
  192. /* Each GET_xxxx() macro uses an implicit `stream' variable. */
  193. /* */
  194. #if 0
  195. #define FT_GET_MACRO( type ) FT_NEXT_ ## type ( stream->cursor )
  196. #define FT_GET_CHAR() FT_GET_MACRO( CHAR )
  197. #define FT_GET_BYTE() FT_GET_MACRO( BYTE )
  198. #define FT_GET_SHORT() FT_GET_MACRO( SHORT )
  199. #define FT_GET_USHORT() FT_GET_MACRO( USHORT )
  200. #define FT_GET_OFF3() FT_GET_MACRO( OFF3 )
  201. #define FT_GET_UOFF3() FT_GET_MACRO( UOFF3 )
  202. #define FT_GET_LONG() FT_GET_MACRO( LONG )
  203. #define FT_GET_ULONG() FT_GET_MACRO( ULONG )
  204. #define FT_GET_TAG4() FT_GET_MACRO( ULONG )
  205. #define FT_GET_SHORT_LE() FT_GET_MACRO( SHORT_LE )
  206. #define FT_GET_USHORT_LE() FT_GET_MACRO( USHORT_LE )
  207. #define FT_GET_LONG_LE() FT_GET_MACRO( LONG_LE )
  208. #define FT_GET_ULONG_LE() FT_GET_MACRO( ULONG_LE )
  209. #else
  210. #define FT_GET_MACRO( func, type ) ( (type)func( stream ) )
  211. #define FT_GET_CHAR() FT_GET_MACRO( FT_Stream_GetChar, FT_Char )
  212. #define FT_GET_BYTE() FT_GET_MACRO( FT_Stream_GetChar, FT_Byte )
  213. #define FT_GET_SHORT() FT_GET_MACRO( FT_Stream_GetUShort, FT_Short )
  214. #define FT_GET_USHORT() FT_GET_MACRO( FT_Stream_GetUShort, FT_UShort )
  215. #define FT_GET_OFF3() FT_GET_MACRO( FT_Stream_GetUOffset, FT_Long )
  216. #define FT_GET_UOFF3() FT_GET_MACRO( FT_Stream_GetUOffset, FT_ULong )
  217. #define FT_GET_LONG() FT_GET_MACRO( FT_Stream_GetULong, FT_Long )
  218. #define FT_GET_ULONG() FT_GET_MACRO( FT_Stream_GetULong, FT_ULong )
  219. #define FT_GET_TAG4() FT_GET_MACRO( FT_Stream_GetULong, FT_ULong )
  220. #define FT_GET_SHORT_LE() FT_GET_MACRO( FT_Stream_GetUShortLE, FT_Short )
  221. #define FT_GET_USHORT_LE() FT_GET_MACRO( FT_Stream_GetUShortLE, FT_UShort )
  222. #define FT_GET_LONG_LE() FT_GET_MACRO( FT_Stream_GetULongLE, FT_Long )
  223. #define FT_GET_ULONG_LE() FT_GET_MACRO( FT_Stream_GetULongLE, FT_ULong )
  224. #endif
  225. #define FT_READ_MACRO( func, type, var ) \
  226. ( var = (type)func( stream, &error ), \
  227. error != FT_Err_Ok )
  228. #define FT_READ_BYTE( var ) FT_READ_MACRO( FT_Stream_ReadChar, FT_Byte, var )
  229. #define FT_READ_CHAR( var ) FT_READ_MACRO( FT_Stream_ReadChar, FT_Char, var )
  230. #define FT_READ_SHORT( var ) FT_READ_MACRO( FT_Stream_ReadUShort, FT_Short, var )
  231. #define FT_READ_USHORT( var ) FT_READ_MACRO( FT_Stream_ReadUShort, FT_UShort, var )
  232. #define FT_READ_OFF3( var ) FT_READ_MACRO( FT_Stream_ReadUOffset, FT_Long, var )
  233. #define FT_READ_UOFF3( var ) FT_READ_MACRO( FT_Stream_ReadUOffset, FT_ULong, var )
  234. #define FT_READ_LONG( var ) FT_READ_MACRO( FT_Stream_ReadULong, FT_Long, var )
  235. #define FT_READ_ULONG( var ) FT_READ_MACRO( FT_Stream_ReadULong, FT_ULong, var )
  236. #define FT_READ_SHORT_LE( var ) FT_READ_MACRO( FT_Stream_ReadUShortLE, FT_Short, var )
  237. #define FT_READ_USHORT_LE( var ) FT_READ_MACRO( FT_Stream_ReadUShortLE, FT_UShort, var )
  238. #define FT_READ_LONG_LE( var ) FT_READ_MACRO( FT_Stream_ReadULongLE, FT_Long, var )
  239. #define FT_READ_ULONG_LE( var ) FT_READ_MACRO( FT_Stream_ReadULongLE, FT_ULong, var )
  240. #ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM
  241. /* initialize a stream for reading a regular system stream */
  242. FT_BASE( FT_Error )
  243. FT_Stream_Open( FT_Stream stream,
  244. const char* filepathname );
  245. #endif /* FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */
  246. /* create a new (input) stream from an FT_Open_Args structure */
  247. FT_BASE( FT_Error )
  248. FT_Stream_New( FT_Library library,
  249. const FT_Open_Args* args,
  250. FT_Stream *astream );
  251. /* free a stream */
  252. FT_BASE( void )
  253. FT_Stream_Free( FT_Stream stream,
  254. FT_Int external );
  255. /* initialize a stream for reading in-memory data */
  256. FT_BASE( void )
  257. FT_Stream_OpenMemory( FT_Stream stream,
  258. const FT_Byte* base,
  259. FT_ULong size );
  260. /* close a stream (does not destroy the stream structure) */
  261. FT_BASE( void )
  262. FT_Stream_Close( FT_Stream stream );
  263. /* seek within a stream. position is relative to start of stream */
  264. FT_BASE( FT_Error )
  265. FT_Stream_Seek( FT_Stream stream,
  266. FT_ULong pos );
  267. /* skip bytes in a stream */
  268. FT_BASE( FT_Error )
  269. FT_Stream_Skip( FT_Stream stream,
  270. FT_Long distance );
  271. /* return current stream position */
  272. FT_BASE( FT_Long )
  273. FT_Stream_Pos( FT_Stream stream );
  274. /* read bytes from a stream into a user-allocated buffer, returns an */
  275. /* error if not all bytes could be read. */
  276. FT_BASE( FT_Error )
  277. FT_Stream_Read( FT_Stream stream,
  278. FT_Byte* buffer,
  279. FT_ULong count );
  280. /* read bytes from a stream at a given position */
  281. FT_BASE( FT_Error )
  282. FT_Stream_ReadAt( FT_Stream stream,
  283. FT_ULong pos,
  284. FT_Byte* buffer,
  285. FT_ULong count );
  286. /* try to read bytes at the end of a stream; return number of bytes */
  287. /* really available */
  288. FT_BASE( FT_ULong )
  289. FT_Stream_TryRead( FT_Stream stream,
  290. FT_Byte* buffer,
  291. FT_ULong count );
  292. /* Enter a frame of `count' consecutive bytes in a stream. Returns an */
  293. /* error if the frame could not be read/accessed. The caller can use */
  294. /* the FT_Stream_Get_XXX functions to retrieve frame data without */
  295. /* error checks. */
  296. /* */
  297. /* You must _always_ call FT_Stream_ExitFrame() once you have entered */
  298. /* a stream frame! */
  299. /* */
  300. FT_BASE( FT_Error )
  301. FT_Stream_EnterFrame( FT_Stream stream,
  302. FT_ULong count );
  303. /* exit a stream frame */
  304. FT_BASE( void )
  305. FT_Stream_ExitFrame( FT_Stream stream );
  306. /* Extract a stream frame. If the stream is disk-based, a heap block */
  307. /* is allocated and the frame bytes are read into it. If the stream */
  308. /* is memory-based, this function simply set a pointer to the data. */
  309. /* */
  310. /* Useful to optimize access to memory-based streams transparently. */
  311. /* */
  312. /* All extracted frames must be `freed' with a call to the function */
  313. /* FT_Stream_ReleaseFrame(). */
  314. /* */
  315. FT_BASE( FT_Error )
  316. FT_Stream_ExtractFrame( FT_Stream stream,
  317. FT_ULong count,
  318. FT_Byte** pbytes );
  319. /* release an extract frame (see FT_Stream_ExtractFrame) */
  320. FT_BASE( void )
  321. FT_Stream_ReleaseFrame( FT_Stream stream,
  322. FT_Byte** pbytes );
  323. /* read a byte from an entered frame */
  324. FT_BASE( FT_Char )
  325. FT_Stream_GetChar( FT_Stream stream );
  326. /* read a 16-bit big-endian unsigned integer from an entered frame */
  327. FT_BASE( FT_UShort )
  328. FT_Stream_GetUShort( FT_Stream stream );
  329. /* read a 24-bit big-endian unsigned integer from an entered frame */
  330. FT_BASE( FT_ULong )
  331. FT_Stream_GetUOffset( FT_Stream stream );
  332. /* read a 32-bit big-endian unsigned integer from an entered frame */
  333. FT_BASE( FT_ULong )
  334. FT_Stream_GetULong( FT_Stream stream );
  335. /* read a 16-bit little-endian unsigned integer from an entered frame */
  336. FT_BASE( FT_UShort )
  337. FT_Stream_GetUShortLE( FT_Stream stream );
  338. /* read a 32-bit little-endian unsigned integer from an entered frame */
  339. FT_BASE( FT_ULong )
  340. FT_Stream_GetULongLE( FT_Stream stream );
  341. /* read a byte from a stream */
  342. FT_BASE( FT_Char )
  343. FT_Stream_ReadChar( FT_Stream stream,
  344. FT_Error* error );
  345. /* read a 16-bit big-endian unsigned integer from a stream */
  346. FT_BASE( FT_UShort )
  347. FT_Stream_ReadUShort( FT_Stream stream,
  348. FT_Error* error );
  349. /* read a 24-bit big-endian unsigned integer from a stream */
  350. FT_BASE( FT_ULong )
  351. FT_Stream_ReadUOffset( FT_Stream stream,
  352. FT_Error* error );
  353. /* read a 32-bit big-endian integer from a stream */
  354. FT_BASE( FT_ULong )
  355. FT_Stream_ReadULong( FT_Stream stream,
  356. FT_Error* error );
  357. /* read a 16-bit little-endian unsigned integer from a stream */
  358. FT_BASE( FT_UShort )
  359. FT_Stream_ReadUShortLE( FT_Stream stream,
  360. FT_Error* error );
  361. /* read a 32-bit little-endian unsigned integer from a stream */
  362. FT_BASE( FT_ULong )
  363. FT_Stream_ReadULongLE( FT_Stream stream,
  364. FT_Error* error );
  365. /* Read a structure from a stream. The structure must be described */
  366. /* by an array of FT_Frame_Field records. */
  367. FT_BASE( FT_Error )
  368. FT_Stream_ReadFields( FT_Stream stream,
  369. const FT_Frame_Field* fields,
  370. void* structure );
  371. #define FT_STREAM_POS() \
  372. FT_Stream_Pos( stream )
  373. #define FT_STREAM_SEEK( position ) \
  374. FT_SET_ERROR( FT_Stream_Seek( stream, \
  375. (FT_ULong)(position) ) )
  376. #define FT_STREAM_SKIP( distance ) \
  377. FT_SET_ERROR( FT_Stream_Skip( stream, \
  378. (FT_Long)(distance) ) )
  379. #define FT_STREAM_READ( buffer, count ) \
  380. FT_SET_ERROR( FT_Stream_Read( stream, \
  381. (FT_Byte*)(buffer), \
  382. (FT_ULong)(count) ) )
  383. #define FT_STREAM_READ_AT( position, buffer, count ) \
  384. FT_SET_ERROR( FT_Stream_ReadAt( stream, \
  385. (FT_ULong)(position), \
  386. (FT_Byte*)buffer, \
  387. (FT_ULong)(count) ) )
  388. #define FT_STREAM_READ_FIELDS( fields, object ) \
  389. FT_SET_ERROR( FT_Stream_ReadFields( stream, fields, object ) )
  390. #define FT_FRAME_ENTER( size ) \
  391. FT_SET_ERROR( \
  392. FT_DEBUG_INNER( FT_Stream_EnterFrame( stream, \
  393. (FT_ULong)(size) ) ) )
  394. #define FT_FRAME_EXIT() \
  395. FT_DEBUG_INNER( FT_Stream_ExitFrame( stream ) )
  396. #define FT_FRAME_EXTRACT( size, bytes ) \
  397. FT_SET_ERROR( \
  398. FT_DEBUG_INNER( FT_Stream_ExtractFrame( stream, \
  399. (FT_ULong)(size), \
  400. (FT_Byte**)&(bytes) ) ) )
  401. #define FT_FRAME_RELEASE( bytes ) \
  402. FT_DEBUG_INNER( FT_Stream_ReleaseFrame( stream, \
  403. (FT_Byte**)&(bytes) ) )
  404. FT_END_HEADER
  405. #endif /* __FTSTREAM_H__ */
  406. /* END */