pike.git / src / post_modules / Shuffler / d_source_pikestream.c

version» Context lines:

pike.git/src/post_modules/Shuffler/d_source_pikestream.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: d_source_pikestream.c,v 1.8 2007/11/10 21:23:02 nilsson Exp $ + || $Id: d_source_pikestream.c,v 1.9 2009/08/13 16:21:14 grubba Exp $   */      #include "global.h"   #include "bignum.h"   #include "object.h"   #include "interpret.h"      #include "fdlib.h"   #include "fd_control.h"   
pike.git/src/post_modules/Shuffler/d_source_pikestream.c:36:    void *when_data_cb_arg;    size_t len, skip;   };         struct callback_prog   {    struct pf_source *s;   };    - static void setup_callbacks( struct source *_s ) + static void setup_callbacks( struct source *src )   { -  struct pf_source *s = (struct pf_source *)_s; +  struct pf_source *s = (struct pf_source *)src;    if( !s->str )    {    ref_push_object( s->cb_obj );    apply( s->obj, "set_read_callback", 1 );    pop_stack();    ref_push_object( s->cb_obj );    apply( s->obj, "set_close_callback", 1 );    pop_stack();    }   }    - static void remove_callbacks( struct source *_s ) + static void remove_callbacks( struct source *src )   { -  struct pf_source *s = (struct pf_source *)_s; +  struct pf_source *s = (struct pf_source *)src;    push_int(0);    apply( s->obj, "set_read_callback", 1 );    pop_stack();    push_int(0);    apply( s->obj, "set_close_callback", 1 );    pop_stack();   }       - static struct data get_data( struct source *_s, off_t len ) + static struct data get_data( struct source *src, off_t len )   { -  struct pf_source *s = (struct pf_source *)_s; +  struct pf_source *s = (struct pf_source *)src;    struct data res = { 0, 0, 0, NULL };    char *buffer = NULL;       if( s->str )    {    len = s->str->len;    if( s->skip )    {    if( s->skip >= (size_t)s->str->len )    {
pike.git/src/post_modules/Shuffler/d_source_pikestream.c:101:    s->s.eof = 1;    }    buffer = malloc( len );    MEMCPY( buffer, s->str->str, len );    }    res.data = buffer;    res.len = len;    res.do_free = 1;    free_string( s->str );    s->str = 0; -  setup_callbacks( _s ); +  setup_callbacks( src );    }    else if( !s->len )    s->s.eof = 1;    else    /* No data available, but there should be in the future (no EOF, nor    * out of the range of data to send as specified by the arguments to    * source_stream_make)    */    res.len = -2;       return res;   }    - static void free_source( struct source *_s ) + static void free_source( struct source *src )   { -  remove_callbacks( _s ); -  free_object(((struct pf_source *)_s)->cb_obj); -  free_object(((struct pf_source *)_s)->obj); +  remove_callbacks( src ); +  free_object(((struct pf_source *)src)->cb_obj); +  free_object(((struct pf_source *)src)->obj);   }      static void f_got_data( INT32 args )   {    struct pf_source *s =    ((struct callback_prog *)Pike_fp->current_object->storage)->s;       remove_callbacks( (struct source *)s );       if( s->str ||
pike.git/src/post_modules/Shuffler/d_source_pikestream.c:148:    }    s->str = Pike_sp[-1].u.string;    Pike_sp--;    pop_n_elems(args-1);    push_int(0);       if( s->when_data_cb )    s->when_data_cb( s->when_data_cb_arg );   }    - static void set_callback( struct source *_s, void (*cb)( void *a ), void *a ) + static void set_callback( struct source *src, void (*cb)( void *a ), void *a )   { -  struct pf_source *s = (struct pf_source *)_s; +  struct pf_source *s = (struct pf_source *)src;    s->when_data_cb = cb;    s->when_data_cb_arg = a;   }      struct source *source_pikestream_make( struct svalue *s,    INT64 start, INT64 len )   {    struct pf_source *res;       if( (s->type != PIKE_T_OBJECT) ||