godot/thirdparty/freetype/include/freetype/internal/ftstream.h

/****************************************************************************
 *
 * ftstream.h
 *
 *   Stream handling (specification).
 *
 * Copyright (C) 1996-2023 by
 * David Turner, Robert Wilhelm, and Werner Lemberg.
 *
 * This file is part of the FreeType project, and may only be used,
 * modified, and distributed under the terms of the FreeType project
 * license, LICENSE.TXT.  By continuing to use, modify, or distribute
 * this file you indicate that you have read the license and
 * understand and accept it fully.
 *
 */


#ifndef FTSTREAM_H_
#define FTSTREAM_H_


#include <ft2build.h>
#include <freetype/ftsystem.h>
#include <freetype/internal/ftobjs.h>


FT_BEGIN_HEADER


  /* format of an 8-bit frame_op value:           */
  /*                                              */
  /* bit  76543210                                */
  /*      xxxxxxes                                */
  /*                                              */
  /* s is set to 1 if the value is signed.        */
  /* e is set to 1 if the value is little-endian. */
  /* xxx is a command.                            */

#define FT_FRAME_OP_SHIFT
#define FT_FRAME_OP_SIGNED
#define FT_FRAME_OP_LITTLE
#define FT_FRAME_OP_COMMAND( x )

#define FT_MAKE_FRAME_OP( command, little, sign )

#define FT_FRAME_OP_END
#define FT_FRAME_OP_START
#define FT_FRAME_OP_BYTE
#define FT_FRAME_OP_SHORT
#define FT_FRAME_OP_LONG
#define FT_FRAME_OP_OFF3
#define FT_FRAME_OP_BYTES


  FT_Frame_Op;


  FT_Frame_Field;


  /* Construct an FT_Frame_Field out of a structure type and a field name. */
  /* The structure type must be set in the FT_STRUCTURE macro before       */
  /* calling the FT_FRAME_START() macro.                                   */
  /*                                                                       */
#define FT_FIELD_SIZE( f )

#define FT_FIELD_SIZE_DELTA( f )

#define FT_FIELD_OFFSET( f )

#define FT_FRAME_FIELD( frame_op, field )

#define FT_MAKE_EMPTY_FIELD( frame_op )

#define FT_FRAME_START( size )
#define FT_FRAME_END

#define FT_FRAME_LONG( f )
#define FT_FRAME_ULONG( f )
#define FT_FRAME_SHORT( f )
#define FT_FRAME_USHORT( f )
#define FT_FRAME_OFF3( f )
#define FT_FRAME_UOFF3( f )
#define FT_FRAME_BYTE( f )
#define FT_FRAME_CHAR( f )

#define FT_FRAME_LONG_LE( f )
#define FT_FRAME_ULONG_LE( f )
#define FT_FRAME_SHORT_LE( f )
#define FT_FRAME_USHORT_LE( f )
#define FT_FRAME_OFF3_LE( f )
#define FT_FRAME_UOFF3_LE( f )

#define FT_FRAME_SKIP_LONG
#define FT_FRAME_SKIP_SHORT
#define FT_FRAME_SKIP_BYTE

#define FT_FRAME_BYTES( field, count )

#define FT_FRAME_SKIP_BYTES( count )


  /**************************************************************************
   *
   * Integer extraction macros -- the 'buffer' parameter must ALWAYS be of
   * type 'char*' or equivalent (1-byte elements).
   */

#define FT_BYTE_( p, i )

#define FT_INT16( x )
#define FT_UINT16( x )
#define FT_INT32( x )
#define FT_UINT32( x )


#define FT_BYTE_U16( p, i, s )
#define FT_BYTE_U32( p, i, s )


  /*
   *    function      acts on      increases  does range   for    emits
   *                                pointer    checking   frames  error
   *  -------------------------------------------------------------------
   *   FT_PEEK_XXX  buffer pointer      no         no        no     no
   *   FT_NEXT_XXX  buffer pointer     yes         no        no     no
   *   FT_GET_XXX   stream->cursor     yes        yes       yes     no
   *   FT_READ_XXX  stream->pos        yes        yes        no    yes
   */


  /*
   * `FT_PEEK_XXX' are generic macros to get data from a buffer position.  No
   * safety checks are performed.
   */
#define FT_PEEK_SHORT( p )

#define FT_PEEK_USHORT( p )

#define FT_PEEK_LONG( p )

#define FT_PEEK_ULONG( p )

#define FT_PEEK_OFF3( p )

#define FT_PEEK_UOFF3( p )

#define FT_PEEK_SHORT_LE( p )

#define FT_PEEK_USHORT_LE( p )

#define FT_PEEK_LONG_LE( p )

#define FT_PEEK_ULONG_LE( p )

#define FT_PEEK_OFF3_LE( p )

#define FT_PEEK_UOFF3_LE( p )

  /*
   * `FT_NEXT_XXX' are generic macros to get data from a buffer position
   * which is then increased appropriately.  No safety checks are performed.
   */
#define FT_NEXT_CHAR( buffer )

#define FT_NEXT_BYTE( buffer )

#define FT_NEXT_SHORT( buffer )

#define FT_NEXT_USHORT( buffer )

#define FT_NEXT_OFF3( buffer )

#define FT_NEXT_UOFF3( buffer )

#define FT_NEXT_LONG( buffer )

#define FT_NEXT_ULONG( buffer )


#define FT_NEXT_SHORT_LE( buffer )

#define FT_NEXT_USHORT_LE( buffer )

#define FT_NEXT_OFF3_LE( buffer )

#define FT_NEXT_UOFF3_LE( buffer )

#define FT_NEXT_LONG_LE( buffer )

#define FT_NEXT_ULONG_LE( buffer )


  /**************************************************************************
   *
   * The `FT_GET_XXX` macros use an implicit 'stream' variable.
   *
   * Note that a call to `FT_STREAM_SEEK` or `FT_STREAM_POS` has **no**
   * effect on `FT_GET_XXX`!  They operate on `stream->pos`, while
   * `FT_GET_XXX` use `stream->cursor`.
   */
#if 0
#define FT_GET_MACRO

#define FT_GET_CHAR
#define FT_GET_BYTE
#define FT_GET_SHORT
#define FT_GET_USHORT
#define FT_GET_OFF3
#define FT_GET_UOFF3
#define FT_GET_LONG
#define FT_GET_ULONG
#define FT_GET_TAG4

#define FT_GET_SHORT_LE
#define FT_GET_USHORT_LE
#define FT_GET_LONG_LE
#define FT_GET_ULONG_LE

#else
#define FT_GET_MACRO( func, type )

#define FT_GET_CHAR()
#define FT_GET_BYTE()
#define FT_GET_SHORT()
#define FT_GET_USHORT()
#define FT_GET_UOFF3()
#define FT_GET_LONG()
#define FT_GET_ULONG()
#define FT_GET_TAG4()

#define FT_GET_SHORT_LE()
#define FT_GET_USHORT_LE()
#define FT_GET_LONG_LE()
#define FT_GET_ULONG_LE()
#endif


#define FT_READ_MACRO( func, type, var )

  /*
   * The `FT_READ_XXX' macros use implicit `stream' and `error' variables.
   *
   * `FT_READ_XXX' can be controlled with `FT_STREAM_SEEK' and
   * `FT_STREAM_POS'.  They use the full machinery to check whether a read is
   * valid.
   */
#define FT_READ_BYTE( var )
#define FT_READ_CHAR( var )
#define FT_READ_SHORT( var )
#define FT_READ_USHORT( var )
#define FT_READ_UOFF3( var )
#define FT_READ_LONG( var )
#define FT_READ_ULONG( var )

#define FT_READ_SHORT_LE( var )
#define FT_READ_USHORT_LE( var )
#define FT_READ_LONG_LE( var )
#define FT_READ_ULONG_LE( var )


#ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM

  /* initialize a stream for reading a regular system stream */
  FT_BASE( FT_Error )
  FT_Stream_Open( FT_Stream    stream,
                  const char*  filepathname );

#endif /* FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */


  /* create a new (input) stream from an FT_Open_Args structure */
  FT_BASE( FT_Error )
  FT_Stream_New( FT_Library           library,
                 const FT_Open_Args*  args,
                 FT_Stream           *astream );

  /* free a stream */
  FT_BASE( void )
  FT_Stream_Free( FT_Stream  stream,
                  FT_Int     external );

  /* initialize a stream for reading in-memory data */
  FT_BASE( void )
  FT_Stream_OpenMemory( FT_Stream       stream,
                        const FT_Byte*  base,
                        FT_ULong        size );

  /* close a stream (does not destroy the stream structure) */
  FT_BASE( void )
  FT_Stream_Close( FT_Stream  stream );


  /* seek within a stream. position is relative to start of stream */
  FT_BASE( FT_Error )
  FT_Stream_Seek( FT_Stream  stream,
                  FT_ULong   pos );

  /* skip bytes in a stream */
  FT_BASE( FT_Error )
  FT_Stream_Skip( FT_Stream  stream,
                  FT_Long    distance );

  /* return current stream position */
  FT_BASE( FT_ULong )
  FT_Stream_Pos( FT_Stream  stream );

  /* read bytes from a stream into a user-allocated buffer, returns an */
  /* error if not all bytes could be read.                             */
  FT_BASE( FT_Error )
  FT_Stream_Read( FT_Stream  stream,
                  FT_Byte*   buffer,
                  FT_ULong   count );

  /* read bytes from a stream at a given position */
  FT_BASE( FT_Error )
  FT_Stream_ReadAt( FT_Stream  stream,
                    FT_ULong   pos,
                    FT_Byte*   buffer,
                    FT_ULong   count );

  /* try to read bytes at the end of a stream; return number of bytes */
  /* really available                                                 */
  FT_BASE( FT_ULong )
  FT_Stream_TryRead( FT_Stream  stream,
                     FT_Byte*   buffer,
                     FT_ULong   count );

  /* Enter a frame of `count' consecutive bytes in a stream.  Returns an */
  /* error if the frame could not be read/accessed.  The caller can use  */
  /* the `FT_Stream_GetXXX' functions to retrieve frame data without     */
  /* error checks.                                                       */
  /*                                                                     */
  /* You must _always_ call `FT_Stream_ExitFrame' once you have entered  */
  /* a stream frame!                                                     */
  /*                                                                     */
  /* Nested frames are not permitted.                                    */
  /*                                                                     */
  FT_BASE( FT_Error )
  FT_Stream_EnterFrame( FT_Stream  stream,
                        FT_ULong   count );

  /* exit a stream frame */
  FT_BASE( void )
  FT_Stream_ExitFrame( FT_Stream  stream );


  /* Extract a stream frame.  If the stream is disk-based, a heap block */
  /* is allocated and the frame bytes are read into it.  If the stream  */
  /* is memory-based, this function simply sets a pointer to the data.  */
  /*                                                                    */
  /* Useful to optimize access to memory-based streams transparently.   */
  /*                                                                    */
  /* `FT_Stream_GetXXX' functions can't be used.                        */
  /*                                                                    */
  /* An extracted frame must be `freed' with a call to the function     */
  /* `FT_Stream_ReleaseFrame'.                                          */
  /*                                                                    */
  FT_BASE( FT_Error )
  FT_Stream_ExtractFrame( FT_Stream  stream,
                          FT_ULong   count,
                          FT_Byte**  pbytes );

  /* release an extract frame (see `FT_Stream_ExtractFrame') */
  FT_BASE( void )
  FT_Stream_ReleaseFrame( FT_Stream  stream,
                          FT_Byte**  pbytes );


  /* read a byte from an entered frame */
  FT_BASE( FT_Byte )
  FT_Stream_GetByte( FT_Stream  stream );

  /* read a 16-bit big-endian unsigned integer from an entered frame */
  FT_BASE( FT_UInt16 )
  FT_Stream_GetUShort( FT_Stream  stream );

  /* read a 24-bit big-endian unsigned integer from an entered frame */
  FT_BASE( FT_UInt32 )
  FT_Stream_GetUOffset( FT_Stream  stream );

  /* read a 32-bit big-endian unsigned integer from an entered frame */
  FT_BASE( FT_UInt32 )
  FT_Stream_GetULong( FT_Stream  stream );

  /* read a 16-bit little-endian unsigned integer from an entered frame */
  FT_BASE( FT_UInt16 )
  FT_Stream_GetUShortLE( FT_Stream  stream );

  /* read a 32-bit little-endian unsigned integer from an entered frame */
  FT_BASE( FT_UInt32 )
  FT_Stream_GetULongLE( FT_Stream  stream );


  /* read a byte from a stream */
  FT_BASE( FT_Byte )
  FT_Stream_ReadByte( FT_Stream  stream,
                      FT_Error*  error );

  /* read a 16-bit big-endian unsigned integer from a stream */
  FT_BASE( FT_UInt16 )
  FT_Stream_ReadUShort( FT_Stream  stream,
                        FT_Error*  error );

  /* read a 24-bit big-endian unsigned integer from a stream */
  FT_BASE( FT_ULong )
  FT_Stream_ReadUOffset( FT_Stream  stream,
                         FT_Error*  error );

  /* read a 32-bit big-endian integer from a stream */
  FT_BASE( FT_UInt32 )
  FT_Stream_ReadULong( FT_Stream  stream,
                       FT_Error*  error );

  /* read a 16-bit little-endian unsigned integer from a stream */
  FT_BASE( FT_UInt16 )
  FT_Stream_ReadUShortLE( FT_Stream  stream,
                          FT_Error*  error );

  /* read a 32-bit little-endian unsigned integer from a stream */
  FT_BASE( FT_UInt32 )
  FT_Stream_ReadULongLE( FT_Stream  stream,
                         FT_Error*  error );

  /* Read a structure from a stream.  The structure must be described */
  /* by an array of FT_Frame_Field records.                           */
  FT_BASE( FT_Error )
  FT_Stream_ReadFields( FT_Stream              stream,
                        const FT_Frame_Field*  fields,
                        void*                  structure );


#define FT_STREAM_POS()

#define FT_STREAM_SEEK( position )

#define FT_STREAM_SKIP( distance )

#define FT_STREAM_READ( buffer, count )

#define FT_STREAM_READ_AT( position, buffer, count )

#define FT_STREAM_READ_FIELDS( fields, object )


#define FT_FRAME_ENTER( size )

#define FT_FRAME_EXIT()

#define FT_FRAME_EXTRACT( size, bytes )

#define FT_FRAME_RELEASE( bytes )


FT_END_HEADER

#endif /* FTSTREAM_H_ */


/* END */