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

version» Context lines:

pike.git/src/modules/_Stdio/buffer.cmod:988:       if (f)    assign_svalue(&io->output, f);    else {    if (io->output.u.object)    free_svalue(&io->output);    SET_SVAL(io->output, PIKE_T_INT, NUMBER_NUMBER, integer, 0);    }    }    -  /*! @decl int(-1..) output_to( Stdio.Stream|function(string:int) fun, @ +  /*! @decl int(-1..) output_to( Stdio.Stream|function(string(8bit):int) fun, @    *! int(0..)|void nbytes )    *!    *! Write data from the buffer to the indicated file.    *!    *! @param fun    *! Write function. Either one of:    *! @mixed    *! @type Stdio.Stream    *! A file object in which the function @expr{write()@} will    *! be called. -  *! @type function(string:int) +  *! @type function(string(8bit):int)    *! A function which will be called with a @expr{string(8bit)@}    *! to write and is expected to return an @expr{int@} indicating    *! the number of bytes successfully written or @expr{-1@} on    *! failure.    *! @endmixed    *!    *! @param nbytes    *! If @[nbytes] is not specified the whole buffer will be written    *! if possible. Otherwise at most @[nbytes] will be written.    *!
pike.git/src/modules/_Stdio/buffer.cmod:1023:    *! If no bytes have been written successfully and @expr{fun()@} failed    *! with an error, @expr{-1@} will be returned.    *!    *! @deprecated    *! This function is going to get deprecated. In case you want to use    *! it against an @[Stdio.File] like object, please consider using    *! the @expr{f->write(buf)@} API. If you want to use it against a custom    *! write function, please consider supporting the @expr{f->write(buf)@}    *! API in it.    */ -  PIKEFUN int(-1..) output_to( object|function(string:int) f, int|void nbytes ) +  PIKEFUN int(-1..) output_to( object|function(string(8bit):int) f, +  int|void nbytes )    {    Buffer *io = THIS;    ptrdiff_t written = 0;    ptrdiff_t sz = io_len( io );    int write_fun_num = -1;       if( !sz )    {    io_range_error(io, sz);    sz = io_len(io);
pike.git/src/modules/_Stdio/buffer.cmod:1210:    *! @type array(AddArgument)    *! Add all elements in the array individually. Each element may be    *! any one of the types listed here.    *! @endmixed    *!    *! @seealso    *! @[sprintf], @[add_int8], @[add_int16], @[add_int32], @[add_int]    *! and    *! @[add_hstring]    */ -  PIKEFUN Buffer add( object|string|int|array(object|string|int) ... argp) +  PIKEFUN Buffer add( object|string(8bit)|int|array(object|string(8bit)|int) ... argp)    {    int i;    Buffer *io = THIS;       for(i=0; i<args; i++ )    io_append_svalue( io, argp+i );       pop_stack();    ref_push_object(io->this);    }
pike.git/src/modules/_Stdio/buffer.cmod:1367:    *! @endmixed    */       /* we can not use the actual type here.       the reason is that this class is loaded before the master is, so    we cannot possibly use things that require the master (such as    resolving things.)    */    PIKEFUN Buffer add_hstring( -  int|string|object|array(int|string|Buffer|array) str, +  int|string(8bit)|object|array(int|string(8bit)|Buffer|array) str,    int size_size, void|int offset )    {    Buffer *io = THIS;    size_t len = io_svalue_len(io, str);       if( offset )    len += offset->u.integer;       if( size_size < (int)sizeof(size_t) &&    len > (((size_t)1)<<(8*size_size))-1 )
pike.git/src/modules/_Stdio/buffer.cmod:1585:    *!    *! Returns the buffer size, in bytes.    *! This is how much you can read from the buffer until it runs out of data.    */    PIKEFUN int(0..) _sizeof()    flags ID_PROTECTED;    {    push_ulongest(io_len(THIS));    }    -  /*! @decl string cast(string type) +  /*! @decl string(8bit) cast("string")    *!    *! Convert the buffer to a string.    *!    *!@note    *! This only works for buffers whose length is less than 0x7fffffff.    */    PIKEFUN string(8bit) cast(string to)    flags ID_PROTECTED;    {    if( to != literal_string_string )
pike.git/src/modules/_Stdio/buffer.cmod:1627:    *! verify that each and every read operation suceeds.    *!    *! However, the non-error mode is more useful when checking to see    *! if a packet/segment/whatever has arrived.    *!    *! The thrown error object will have the constant buffer_error set    *! to a non-false value.    *!    *! @example    *! @code -  *! void read_callback(int i, string new_data) +  *! void read_callback(int i, string(8bit) new_data)    *! {    *! inbuffer->add( new_data );    *!    *! while( Buffer packet = inbuffer->read_hbuffer(2) )    *! {    *! packet->set_error_mode(Buffer.THROW_ERROR);    *! if( mixed e = catch( handle_packet( packet ) ) )    *! if( e->buffer_error )    *! protocol_error(); // illegal data in packet    *! else
pike.git/src/modules/_Stdio/buffer.cmod:2120:       /*! @decl array sscanf(string(8bit) format)    *!    *! Reads data from the beginning of the buffer to match the    *! specifed format, then return an array with the matches.    *!    *! The non-matching data will be left in the buffer.    *!    *! See @[array_sscanf] for more information.    */ -  PIKEFUN array sscanf( string format ) +  PIKEFUN array sscanf( string(8bit) format )    {    INT32 i;    ptrdiff_t num_used;    struct svalue *start = Pike_sp;    retry:    i = low_sscanf_pcharp(    MKPCHARP(io_read_pointer(THIS), 0), io_len(THIS),    MKPCHARP(format->str,format->size_shift), format->len,    &num_used);   
pike.git/src/modules/_Stdio/buffer.cmod:2241:    *! This function is very similar to @[sscanf], but the    *! result is the sum of the matches. Most useful to match    *! a single value.    *!    *! @example    *! @code    *! // get the next whitespace separated word from the buffer.    *! buffer->match("%*[ \t\r\n]%[^ \t\r\n]");    *! @endcode    */ -  PIKEFUN string(8bit)|int|float|array match( string format ) +  PIKEFUN string(8bit)|int|float|array match( string(8bit) format )    {    INT32 i;    ptrdiff_t num_used;    struct svalue *start = Pike_sp;    retry:    i = low_sscanf_pcharp(    MKPCHARP(io_read_pointer(THIS), 0), io_len(THIS),    MKPCHARP(format->str,format->size_shift), format->len,    &num_used);   
pike.git/src/modules/_Stdio/buffer.cmod:2647:    }       for( i=0; i<num; i++ )    {    push_object(io_read_bignum( io, len, 1 ));    reduce_stack_top_bignum();    }    f_aggregate(num);    }    - /*! @decl string _encode() -  *! @decl void _decode(string x) + /*! @decl string(8bit) _encode() +  *! @decl void _decode(string(8bit) x)    *!    *! Encode and decode Stdio.Buffer objects.    *! Only the buffer data is kept, no other state is saved.    */    PIKEFUN string _encode()    {    push_string(io_read_string(THIS, io_len(THIS)));    }       PIKEFUN void _decode(string(8bit) x)
pike.git/src/modules/_Stdio/buffer.cmod:2782:    *! so the buffer creation is fast regardless of the length of the    *! string.    *!    *! However, as an example, if the buffer is created with a 100Gb    *! @[System.Memory] mmap:ed file as the @[contents] and you later on    *! try to modify the buffer using one of the @[add] functions (or    *! @[sprintf] and similar) the old contents @b{will@} be copied.    *!    *! You can use @[read_only()] to avoid accidents.    */ -  PIKEFUN void create( int|void|string|object|array x ) +  PIKEFUN void create( int|void|string(8bit)|object|array x )    flags ID_PROTECTED;    {    Buffer *this = THIS;    if( this->buffer )    Pike_error("Can not initialize twice.\n");    if( !x )    {    this->buffer = xalloc(256-32);    this->allocated = 256-32;    this->malloced = 1;