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

version» Context lines:

pike.git/src/modules/Pipe/pipe.c:23:   #endif   #endif   #endif      #ifdef HAVE_SYS_ID_H   #include <sys/id.h>   #endif /* HAVE_SYS_ID_H */      #include <fcntl.h>    - RCSID("$Id: pipe.c,v 1.43 2000/08/28 22:13:09 hubbe Exp $"); + RCSID("$Id: pipe.c,v 1.44 2000/12/01 08:10:19 hubbe Exp $");      #include "threads.h"   #include "stralloc.h"   #include "pike_macros.h"   #include "object.h"   #include "constants.h"   #include "interpret.h"   #include "svalue.h" - #include "error.h" + #include "pike_error.h"   #include "builtin_functions.h"   #include "fdlib.h"      #ifndef S_ISREG   #ifdef S_IFREG   #define S_ISREG(mode) (((mode) & (S_IFMT)) == (S_IFREG))   #else   #define S_ISREG(mode) (((mode) & (_S_IFMT)) == (_S_IFREG))   #endif   #endif
pike.git/src/modules/Pipe/pipe.c:246:    case I_STRING:    free_string(i->u.str);    nstrings--;    break;       case I_MMAP:   #if defined(HAVE_MMAP) && defined(HAVE_MUNMAP)    munmap(i->u.mmap,i->len);    mmapped -= i->len;   #else -  error("I_MMAP input when MMAP is diabled!"); +  Pike_error("I_MMAP input when MMAP is diabled!");   #endif    break;       case I_NONE: break;    }    free((char *)i);   }      /* do the done_callback, then close and free everything */   static INLINE void pipe_done(void)   {    if (THIS->done_callback.type!=T_INT)    {    assign_svalue_no_free(sp++,&THIS->id);    apply_svalue(&(THIS->done_callback),1);    pop_stack();       if(!THISOBJ->prog) /* We will not free anything in this case. */    return; -  /* error("Pipe done callback destructed pipe.\n"); */ +  /* Pike_error("Pipe done callback destructed pipe.\n"); */    }    close_and_free_everything(THISOBJ,THIS);   }      static void finished_p(void)   {    if(THIS->done) return;       if(THIS->fd != -1)    {
pike.git/src/modules/Pipe/pipe.c:603: Inside #if defined(BLOCKING_CLOSE)
   apply_low(o->obj,o->set_blocking_offset,0);    pop_stack();   #endif    push_int(0);    apply(o->obj,"set_id",1);    pop_stack();       apply(o->obj,"close",0);    pop_stack();    if(!THISOBJ->prog) -  error("Pipe done callback destructed pipe.\n"); +  Pike_error("Pipe done callback destructed pipe.\n");    destruct(o->obj);    }    free_object(o->obj);    noutputs--;    o->obj=NULL;       THIS->living_outputs--;       finished_p(); /* Moved by per, one line down.. :) */   
pike.git/src/modules/Pipe/pipe.c:662:    }    len=s->len;    push_string(s);    apply_low(out->obj,out->write_offset,1);    out->mode=O_RUN;       ret=-1;    if(sp[-1].type == T_INT) ret=sp[-1].u.integer;    pop_stack();    -  if (ret==-1) /* error, byebye */ +  if (ret==-1) /* Pike_error, byebye */    {    output_finish(obj);    return;    }    out->pos+=ret;    THIS->sent+=ret;      #ifdef INSISTANT_WRITE    } while(ret == len);   #endif
pike.git/src/modules/Pipe/pipe.c:687:   /* Add an input to this pipe */   static void pipe_input(INT32 args)   {    struct input *i;    int fd=-1; /* Per, one less warning to worry about... */    char *m;    struct stat s;    struct object *obj;       if (args<1 || sp[-args].type != T_OBJECT) -  error("Bad/missing argument 1 to pipe->input().\n"); +  Pike_error("Bad/missing argument 1 to pipe->input().\n");       obj=sp[-args].u.object;    if(!obj || !obj->prog) -  error("pipe->input() on destructed object.\n"); +  Pike_error("pipe->input() on destructed object.\n");       push_int(0);    apply(sp[-args-1].u.object,"set_id", 1);    pop_stack();       i=new_input();      #if defined(HAVE_MMAP) && defined(HAVE_MUNMAP)       /* We do not handle mmaps if we have a buffer */
pike.git/src/modules/Pipe/pipe.c:780:    if (i->set_nonblocking_offset<0 ||    i->set_blocking_offset<0)    {    if (find_identifier("read", i->u.obj->prog) < 0) {    /* Not even a read function */    free_object(i->u.obj);    i->u.obj=NULL;    i->type=I_NONE;       nobjects--; -  error("illegal file object%s%s\n", +  Pike_error("illegal file object%s%s\n",    ((i->set_nonblocking_offset<0)?"; no set_nonblocking":""),    ((i->set_blocking_offset<0)?"; no set_blocking":""));    } else {    /* Try blocking mode */    i->type = I_BLOCKING_OBJ;    if (i==THIS->firstinput) {    /*    * FIXME: What if read_som_data() returns 0?    */    read_some_data();
pike.git/src/modules/Pipe/pipe.c:823:       pop_n_elems(args);    push_int(0);   }      static void pipe_write(INT32 args)   {    struct input *i;       if (args<1 || sp[-args].type!=T_STRING) -  error("illegal argument to pipe->write()\n"); +  Pike_error("illegal argument to pipe->write()\n");       if (!THIS->firstinput)    {    append_buffer(sp[-args].u.string);    pop_n_elems(args);    push_int(0);    return;    }       i=new_input();
pike.git/src/modules/Pipe/pipe.c:854:    struct object *obj;    struct output *o;    int fd;    struct stat s;    struct buffer *b;       if (args<1 ||    sp[-args].type != T_OBJECT ||    !sp[-args].u.object ||    !sp[-args].u.object->prog) -  error("Bad/missing argument 1 to pipe->output().\n"); +  Pike_error("Bad/missing argument 1 to pipe->output().\n");       if (args==2 &&    sp[1-args].type != T_INT) -  error("Bad argument 2 to pipe->output().\n"); +  Pike_error("Bad argument 2 to pipe->output().\n");       if (THIS->fd==-1) /* no buffer */    {    /* test if usable as buffer */    apply(sp[-args].u.object,"query_fd",0);       if ((sp[-1].type==T_INT)    && (fd=sp[-1].u.integer)>=0    && (fstat(fd,&s)==0)    && S_ISREG(s.st_mode)
pike.git/src/modules/Pipe/pipe.c:928:    add_ref(o->obj=sp[-args].u.object);       o->write_offset=find_identifier("write",o->obj->prog);    o->set_nonblocking_offset=find_identifier("set_nonblocking",o->obj->prog);    o->set_blocking_offset=find_identifier("set_blocking",o->obj->prog);       if (o->write_offset<0 || o->set_nonblocking_offset<0 ||    o->set_blocking_offset<0)    {    free_object(o->obj); -  error("illegal file object%s%s%s\n", +  Pike_error("illegal file object%s%s%s\n",    ((o->write_offset<0)?"; no write":""),    ((o->set_nonblocking_offset<0)?"; no set_nonblocking":""),    ((o->set_blocking_offset<0)?"; no set_blocking":""));    }       o->mode=O_RUN;    /* keep the file pointer of the duped fd    o->pos=0; */    /* allow start position as 2nd argument for additional outputs    o->pos=THIS->pos; */
pike.git/src/modules/Pipe/pipe.c:967:      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)) -  error("Illegal argument to set_done_callback()\n"); +  Pike_error("Illegal argument to set_done_callback()\n");       if (args>1)    {    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);
pike.git/src/modules/Pipe/pipe.c:989:      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)) -  error("Illegal argument to set_output_closed_callback()\n"); +  Pike_error("Illegal argument to set_output_closed_callback()\n");       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);   }
pike.git/src/modules/Pipe/pipe.c:1026:   {    pop_n_elems(args);    push_int(THIS->sent);   }      /********** callbacks *******************************************************/      static void pipe_write_output_callback(INT32 args)   {    if (args<1 || sp[-args].type!=T_OBJECT) -  error("Illegal argument to pipe->write_output_callback\n"); +  Pike_error("Illegal argument to pipe->write_output_callback\n");       if(!sp[-args].u.object->prog) return;       if(sp[-args].u.object->prog != output_program) -  error("Illegal argument to pipe->write_output_callback\n"); +  Pike_error("Illegal argument to pipe->write_output_callback\n");       debug_malloc_touch(sp[-args].u.object);    output_try_write_some(sp[-args].u.object);    pop_n_elems(args-1);   }      static void pipe_close_output_callback(INT32 args)   {    struct output *o;    if (args<1 || sp[-args].type!=T_OBJECT)       if(!sp[-args].u.object->prog) return;       if(sp[-args].u.object->prog != output_program) -  error("Illegal argument to pipe->close_output_callback\n"); +  Pike_error("Illegal argument to pipe->close_output_callback\n");       o=(struct output *)(sp[-args].u.object->storage);       if (THIS->output_closed_callback.type!=T_INT)    {    assign_svalue_no_free(sp++,&THIS->id);    push_object(o->obj);    apply_svalue(&(THIS->output_closed_callback),2);    pop_stack();    }
pike.git/src/modules/Pipe/pipe.c:1068:    output_finish(sp[-args].u.object);    pop_n_elems(args-1);   }      static void pipe_read_input_callback(INT32 args)   {    struct input *i;    struct pike_string *s;       if (args<2 || sp[1-args].type!=T_STRING) -  error("Illegal argument to pipe->read_input_callback\n"); +  Pike_error("Illegal argument to pipe->read_input_callback\n");       i=THIS->firstinput;       if (!i) -  error("Pipe read callback without any inputs left.\n"); +  Pike_error("Pipe read callback without any inputs left.\n");       s=sp[1-args].u.string;       if(append_buffer(s))    {    /* THIS DOES NOT WORK */    push_int(0);    push_int(0);    push_callback(offset_input_close_callback);    apply_low(i->u.obj,i->set_nonblocking_offset,3);
pike.git/src/modules/Pipe/pipe.c:1098:    low_start();    pop_n_elems(args-1);   }      static void pipe_close_input_callback(INT32 args)   {    struct input *i;    i=THIS->firstinput;       if(!i) -  error("Input close callback without inputs!\n"); +  Pike_error("Input close callback without inputs!\n");       if(i->type != I_OBJ) -  error("Premature close callback on pipe!.\n"); +  Pike_error("Premature close callback on pipe!.\n");       if (i->u.obj->prog)    {   #ifdef BLOCKING_CLOSE    apply_low(i->u.obj,i->set_blocking_offset,0);    pop_stack();   #endif    apply(i->u.obj,"close",0);    pop_stack();    }
pike.git/src/modules/Pipe/pipe.c:1246:    pop_stack();   #endif    push_int(0);    apply(o->obj,"set_id",1);    pop_stack();       apply(o->obj,"close",0);    pop_stack();       if(!THISOBJ->prog) -  error("Pipe done callback destructed pipe.\n"); +  Pike_error("Pipe done callback destructed pipe.\n");    }    free_object(o->obj);    noutputs--;    o->obj=0;    o->fd=-1;    }   }      static void init_output_struct(struct object *ob)   {