pike.git / src / modules / Gz / zlibmod.c

version» Context lines:

pike.git/src/modules/Gz/zlibmod.c:1:   /*\   ||| This file a part of Pike, and is copyright by Fredrik Hubinette   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/   /**/   #include "global.h" - RCSID("$Id: zlibmod.c,v 1.31 2000/08/17 15:41:30 grubba Exp $"); + RCSID("$Id: zlibmod.c,v 1.32 2000/12/01 08:09:57 hubbe Exp $");      #include "zlib_machine.h"      #if !defined(HAVE_LIBZ) && !defined(HAVE_LIBGZ)   #undef HAVE_ZLIB_H   #endif      #ifdef HAVE_ZLIB_H      #include "interpret.h"
pike.git/src/modules/Gz/zlibmod.c:53:    if(THIS->gz.state)    {   /* mt_lock(& THIS->lock); */    deflateEnd(&THIS->gz);   /* mt_unlock(& THIS->lock); */    }       if(args)    {    if(sp[-args].type != T_INT) -  error("Bad argument 1 to gz->create()\n"); +  Pike_error("Bad argument 1 to gz->create()\n");    level=sp[-args].u.integer;    if(level < Z_NO_COMPRESSION ||    level > Z_BEST_COMPRESSION)    { -  error("Compression level out of range for gz_deflate->create()\n"); +  Pike_error("Compression level out of range for gz_deflate->create()\n");    }    }       THIS->gz.zalloc=Z_NULL;    THIS->gz.zfree=Z_NULL;    THIS->gz.opaque=(void *)THIS;       pop_n_elems(args);   /* mt_lock(& THIS->lock); */    level=deflateInit(&THIS->gz, level);   /* mt_unlock(& THIS->lock); */    switch(level)    {    case Z_OK:    return;       case Z_VERSION_ERROR: -  error("libz not compatible with zlib.h!!!\n"); +  Pike_error("libz not compatible with zlib.h!!!\n");    break;       default:    if(THIS->gz.msg) -  error("Failed to initialize gz_deflate: %s\n",THIS->gz.msg); +  Pike_error("Failed to initialize gz_deflate: %s\n",THIS->gz.msg);    else -  error("Failed to initialize gz_deflate\n"); +  Pike_error("Failed to initialize gz_deflate\n");    }   }      static int do_deflate(dynamic_buffer *buf,    struct zipper *this,    int flush)   {    int ret=0;       THREADS_ALLOW();
pike.git/src/modules/Gz/zlibmod.c:130:   }      static void gz_deflate(INT32 args)   {    struct pike_string *data;    int flush, fail;    struct zipper *this=THIS;    dynamic_buffer buf;       if(!THIS->gz.state) -  error("gz_deflate not initialized or destructed\n"); +  Pike_error("gz_deflate not initialized or destructed\n");       if(args<1) -  error("Too few arguments to gz_deflate->deflate()\n"); +  Pike_error("Too few arguments to gz_deflate->deflate()\n");       if(sp[-args].type != T_STRING) -  error("Bad argument 1 to gz_deflate->deflate()\n"); +  Pike_error("Bad argument 1 to gz_deflate->deflate()\n");       data=sp[-args].u.string;       if(args>1)    {    if(sp[1-args].type != T_INT) -  error("Bad argument 2 to gz_deflate->deflate()\n"); +  Pike_error("Bad argument 2 to gz_deflate->deflate()\n");       flush=sp[1-args].u.integer;       switch(flush)    {    case Z_PARTIAL_FLUSH:    case Z_FINISH:    case Z_SYNC_FLUSH:    case Z_NO_FLUSH:    break;       default: -  error("Argument 2 to gz_deflate->deflate() out of range.\n"); +  Pike_error("Argument 2 to gz_deflate->deflate() out of range.\n");    }    }else{    flush=Z_FINISH;    }       this->gz.next_in=(Bytef *)data->str;    this->gz.avail_in = DO_NOT_WARN(data->len);       initialize_buf(&buf);       fail=do_deflate(&buf,this,flush);    pop_n_elems(args);       if(fail != Z_OK && fail != Z_STREAM_END)    {    free(buf.s.str);    if(THIS->gz.msg) -  error("Error in gz_deflate->deflate(): %s\n",THIS->gz.msg); +  Pike_error("Error in gz_deflate->deflate(): %s\n",THIS->gz.msg);    else -  error("Error in gz_deflate->deflate(): %d\n",fail); +  Pike_error("Error in gz_deflate->deflate(): %d\n",fail);    }       push_string(low_free_buf(&buf));   }         static void init_gz_deflate(struct object *o)   {    mt_init(& THIS->lock);    MEMSET(& THIS->gz, 0, sizeof(THIS->gz));
pike.git/src/modules/Gz/zlibmod.c:229:    pop_n_elems(args);   /* mt_lock(& THIS->lock); */    tmp=inflateInit(& THIS->gz);   /* mt_unlock(& THIS->lock); */    switch(tmp)    {    case Z_OK:    return;       case Z_VERSION_ERROR: -  error("libz not compatible with zlib.h!!!\n"); +  Pike_error("libz not compatible with zlib.h!!!\n");    break;       default:    if(THIS->gz.msg) -  error("Failed to initialize gz_inflate: %s\n",THIS->gz.msg); +  Pike_error("Failed to initialize gz_inflate: %s\n",THIS->gz.msg);    else -  error("Failed to initialize gz_inflate\n"); +  Pike_error("Failed to initialize gz_inflate\n");    }   }      static int do_inflate(dynamic_buffer *buf,    struct zipper *this,    int flush)   {    int fail=0;    THREADS_ALLOW();    mt_lock(& this->lock);
pike.git/src/modules/Gz/zlibmod.c:282:   }      static void gz_inflate(INT32 args)   {    struct pike_string *data;    int fail;    struct zipper *this=THIS;    dynamic_buffer buf;       if(!THIS->gz.state) -  error("gz_inflate not initialized or destructed\n"); +  Pike_error("gz_inflate not initialized or destructed\n");       if(args<1) -  error("Too few arguments to gz_inflate->inflate()\n"); +  Pike_error("Too few arguments to gz_inflate->inflate()\n");       if(sp[-args].type != T_STRING) -  error("Bad argument 1 to gz_inflate->inflate()\n"); +  Pike_error("Bad argument 1 to gz_inflate->inflate()\n");       data=sp[-args].u.string;       this->gz.next_in=(Bytef *)data->str;    this->gz.avail_in = DO_NOT_WARN(data->len);       initialize_buf(&buf);       fail=do_inflate(&buf,this,Z_PARTIAL_FLUSH);    pop_n_elems(args);       if(fail != Z_OK && fail != Z_STREAM_END)    {    free(buf.s.str);    if(THIS->gz.msg) -  error("Error in gz_inflate->inflate(): %s\n",THIS->gz.msg); +  Pike_error("Error in gz_inflate->inflate(): %s\n",THIS->gz.msg);    else -  error("Error in gz_inflate->inflate(): %d\n",fail); +  Pike_error("Error in gz_inflate->inflate(): %d\n",fail);    }    push_string(low_free_buf(&buf));    if(fail != Z_STREAM_END && fail!=Z_OK && !sp[-1].u.string->len)    {    pop_stack();    push_int(0);    }   }      static void init_gz_inflate(struct object *o)
pike.git/src/modules/Gz/zlibmod.c:341:   /* mt_unlock(& THIS->lock); */    mt_destroy( & THIS->lock );   }         static void gz_crc32(INT32 args)   {    unsigned INT32 crc;    if (!args ||    sp[-args].type!=T_STRING) -  error("Gz.crc32: illegal or missing argument 1 (expected string)\n"); +  Pike_error("Gz.crc32: illegal or missing argument 1 (expected string)\n");       if (args>1) {    if (sp[1-args].type!=T_INT) -  error("Gz.crc32: illegal argument 2 (expected integer)\n"); +  Pike_error("Gz.crc32: illegal argument 2 (expected integer)\n");    else    crc=(unsigned INT32)sp[1-args].u.integer;    } else    crc=0;       crc=crc32(crc,    (unsigned char*)sp[-args].u.string->str,    DO_NOT_WARN(sp[-args].u.string->len));       pop_n_elems(args);