pike.git / src / modules / Pipe / pipe.c

version» Context lines:

pike.git/src/modules/Pipe/pipe.c:100:   #define INSISTANT_WRITE   #endif      #ifndef MAP_FILE   # define MAP_FILE 0   #endif      #define READ_BUFFER_SIZE 65536   #define MAX_BYTES_IN_BUFFER 65536    - /* -  * usage: -  * single socket output -  * or regular file output and (multiple, adding) socket output -  * with no mmap input -  * -  * multiple socket output without regular file output illegal + /*! @module Pipe +  *! +  *! Single socket output. +  *! +  *! Regular file output and (multiple, adding) socket output +  *! with no mmap input. +  *! +  *! Multiple socket output without regular file output illegal.    */      static struct program *pipe_program, *output_program;      #ifdef THIS   #undef THIS   #endif   #define THIS ((struct pipe *)(Pike_fp->current_storage))   #define THISOBJ (Pike_fp->current_object)   
pike.git/src/modules/Pipe/pipe.c:154:    struct object *next;    struct pipe *the_pipe;   };      struct buffer   {    struct pike_string *s;    struct buffer *next;   };    + /*! @class pipe +  *! +  *! Concatenation pipe. +  */ +    struct pipe   {    int living_outputs; /* number of output objects */       struct svalue done_callback;    struct svalue output_closed_callback;    struct svalue id;       /*    * if fd is -1: use fd
pike.git/src/modules/Pipe/pipe.c:689:    out->pos+=ret;    THIS->sent+=ret;      #ifdef INSISTANT_WRITE    } while(ret == len);   #endif   }      /********** methods *********************************************************/    - /* Add an input to this pipe */ + /*! @decl void input(object obj) +  *! +  *! Add an input file to this pipe. +  */   static void pipe_input(INT32 args)   {    struct input *i;    int fd=-1; /* Per, one less warning to worry about... */    struct object *obj;       if (args<1 || sp[-args].type != T_OBJECT)    Pike_error("Bad/missing argument 1 to pipe->input().\n");       obj=sp[-args].u.object;
pike.git/src/modules/Pipe/pipe.c:801:    push_int(0);    push_callback(offset_input_close_callback);    apply_low(i->u.obj,i->set_nonblocking_offset,3);    pop_stack();    }       pop_n_elems(args);    push_int(0);   }    + /*! @decl void write(string bytes) +  *! +  *! Add an input string to this pipe. +  */   static void pipe_write(INT32 args)   {    struct input *i;       if (args<1 || sp[-args].type!=T_STRING)    Pike_error("illegal argument to pipe->write()\n");       if (!THIS->firstinput)    {    append_buffer(sp[-args].u.string);
pike.git/src/modules/Pipe/pipe.c:825:       i=new_input();    i->type=I_STRING;    nstrings++;    add_ref(i->u.str=sp[-args].u.string);    pop_n_elems(args-1);   }      void f_mark_fd(INT32 args);    + /*! @decl void output(object obj, int|void start_pos) +  *! +  *! Add an output file object. +  */   static void pipe_output(INT32 args)   {    struct object *obj;    struct output *o;    int fd;    struct stat s;    struct buffer *b;       if (args<1 ||    sp[-args].type != T_OBJECT ||
pike.git/src/modules/Pipe/pipe.c:933:       push_int(0);    push_callback(offset_output_write_callback);    push_callback(offset_output_close_callback);    apply_low(o->obj,o->set_nonblocking_offset,3);    pop_stack();       pop_n_elems(args-1);   }    + /*! @decl void set_done_callback(void|function(mixed:mixed) done_cb, @ +  *! void|mixed id) +  *! +  *! Set the callback function to be called when all the outputs +  *! have been sent. +  */   static void pipe_set_done_callback(INT32 args)   {    if (args==0)    {    free_svalue(&THIS->done_callback);    THIS->done_callback.type=T_INT;    return;    }    if (args<1 || (sp[-args].type!=T_FUNCTION && sp[-args].type!=T_ARRAY))    Pike_error("Illegal argument to set_done_callback()\n");
pike.git/src/modules/Pipe/pipe.c:955:    {    free_svalue(&THIS->id);    assign_svalue_no_free(&(THIS->id),sp-args+1);    }       free_svalue(&THIS->done_callback);    assign_svalue_no_free(&(THIS->done_callback),sp-args);    pop_n_elems(args-1);   }    + /*! @decl void set_output_closed_callback(void|function(mixed, object:mixed) close_cb, @ +  *! void|mixed id) +  *! +  *! Set the callback function to be called when one of the outputs has +  *! been closed from the other side. +  */   static void pipe_set_output_closed_callback(INT32 args)   {    if (args==0)    {    free_svalue(&THIS->output_closed_callback);    THIS->output_closed_callback.type=T_INT;    return;    }    if (args<1 || (sp[-args].type!=T_FUNCTION && sp[-args].type!=T_ARRAY))    Pike_error("Illegal argument to set_output_closed_callback()\n");
pike.git/src/modules/Pipe/pipe.c:976:    if (args>1)    {    free_svalue(&THIS->id);    assign_svalue_no_free(&(THIS->id),sp-args+1);    }    free_svalue(&THIS->output_closed_callback);    assign_svalue_no_free(&(THIS->output_closed_callback),sp-args);    pop_n_elems(args-1);   }    + /*! @decl void finish() +  *! +  *! Terminate and reinitialize the pipe. +  */   static void pipe_finish(INT32 args)   {    pop_n_elems(args);    push_int(0);    pipe_done();   }    -  + /*! @decl void start() +  *! +  *! Start sending the input(s) to the output(s). +  */   static void pipe_start(INT32 args) /* force start */   {    low_start();    if(args)    pop_n_elems(args-1);   }    -  + /*! @decl int bytes_sent() +  *! +  *! Return the number of bytes sent. +  */   static void f_bytes_sent(INT32 args)   {    pop_n_elems(args);    push_int(THIS->sent);   }      /********** callbacks *******************************************************/      static void pipe_write_output_callback(INT32 args)   {
pike.git/src/modules/Pipe/pipe.c:1096:    }    nobjects--;    free_object(i->u.obj);    i->type=I_NONE;       input_finish();    if(args)    pop_n_elems(args-1);   }    + /*! @decl string version() +  *! +  *! Return the version of the module. +  */   static void pipe_version(INT32 args)   {    pop_n_elems(args);    push_text("PIPE ver 2.0");   }      /********** init/exit *******************************************************/      void close_and_free_everything(struct object *thisobj,struct pipe *p)   {
pike.git/src/modules/Pipe/pipe.c:1256:    push_int(DO_NOT_WARN(noutputs));    push_int(DO_NOT_WARN(ninputs));    push_int(DO_NOT_WARN(nstrings));    push_int(DO_NOT_WARN(nobjects));    push_int(DO_NOT_WARN(mmapped));    push_int(DO_NOT_WARN(nbuffers));    push_int(DO_NOT_WARN(sbuffers));    f_aggregate(7);   }    + /*! @endclass +  */ +  + /*! @endmodule +  */ +    PIKE_MODULE_INIT   {    start_new_program();    ADD_STORAGE(struct pipe);       /* function(object:void) */    ADD_FUNCTION("input",pipe_input,tFunc(tObj,tVoid),0);    /* function(object,void|int:void) */    ADD_FUNCTION("output",pipe_output,tFunc(tObj tOr(tVoid,tInt),tVoid),0);    /* function(string:void) */