pike.git / src / modules / _Stdio / buffer.cmod

version» Context lines:

pike.git/src/modules/_Stdio/buffer.cmod:1828:    *! removes the data from the buffer.    */    PIKEFUN string(0..255) read()    {    struct pike_string * s = io_read_string(THIS, io_len(THIS));    if( s )    RETURN s;    push_undefined();    }    +  /*! @decl int(8bit) read_int8() +  */ +  PIKEFUN int(8bit) read_int8( ) +  { +  IOBuffer *io = THIS; +  if( LIKELY(io_avail( io, 1 )) ) +  push_int( io_read_byte_uc(io) ); +  else +  push_int(-1); +  } +  +  /*! @decl int(16bit) read_int16() +  */ +  PIKEFUN int(0..65535) read_int16( ) +  { +  IOBuffer *io = THIS; +  if( LIKELY(io_avail( io, 2 )) ) +  push_int( io_read_number_uc(io,2) ); +  else +  push_int(-1); +  } +  +  /*! @decl int(24bit) read_int24() +  */ +  PIKEFUN int(0..16777215) read_int24( ) +  { +  IOBuffer *io = THIS; +  if( LIKELY(io_avail( io, 3 )) ) +  push_int( io_read_number_uc(io,3) ); +  else +  push_int(-1); +  } +  +  /*! @decl int(24bit) read_int32() +  */ +  PIKEFUN int(0..16777215) read_int32( ) +  { + #if SIZEOF_INT_TYPE > 4 +  IOBuffer *io = THIS; +  if( LIKELY(io_avail( io, 4 )) ) +  push_int( io_read_number_uc(io,4) ); +  else +  push_int(-1); + #else +  push_int( io_read_number( 4 ) ); + #endif +  } +     /*! @decl int read_int( int n )    *!    *! Read a network byte order unsigned number of size n*8 bits, then    *! return it.    *!    *! Will return -1 if there is not enough buffer space available    *! unless error mode is set to throw errors.    */    PIKEFUN int(0..) read_int( int len )    {