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

version» Context lines:

pike.git/src/modules/Gz/zlibmod.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.   */    - #include "global.h" - #include "zlib_machine.h" +    #include "module.h" - #include "program.h" - #include "mapping.h" + #include "zlib_machine.h"   #include "module_support.h"      #if !defined(HAVE_LIBZ) && !defined(HAVE_LIBGZ)   #undef HAVE_ZLIB_H   #endif      #ifdef HAVE_ZLIB_H      #include "interpret.h" - #include "svalue.h" - #include "stralloc.h" - #include "array.h" +    #include "pike_macros.h" - #include "stralloc.h" - #include "object.h" +    #include "pike_types.h"   #include "threads.h"   #include "buffer.h"   #include "operators.h"   #include "bignum.h"      #include <zlib.h>         #define sp Pike_sp
pike.git/src/modules/Gz/zlibmod.c:239: Inside #if defined(Z_FIXED)
  #endif   #ifdef Z_FIXED    strategy != Z_FIXED &&   #endif    strategy != Z_HUFFMAN_ONLY)    {    Pike_error("Invalid compression strategy for gz_deflate->create()\n");    }    }    +  pop_n_elems(args); +     THIS->gz.zalloc=Z_NULL;    THIS->gz.zfree=Z_NULL;    THIS->gz.opaque=(void *)THIS;      /* mt_lock(& THIS->lock); */    do {    tmp=deflateInit2(&THIS->gz, THIS->level, Z_DEFLATED, wbits, 9, strategy );    if (tmp == Z_STREAM_ERROR) {    /* zlib 1.1.4's deflateInit2() only supports wbits 9..15 (not 8). */    if (wbits == -8) wbits = -9;
pike.git/src/modules/Gz/zlibmod.c:523:    struct svalue *data_arg;    struct memobj data;    struct byte_buffer buf;    ONERROR err;       int wbits = 15;    int raw = 0;    int level = 8;    int strategy = Z_DEFAULT_STRATEGY;    -  get_all_args("compress", args, "%*.%d%d%d%d", &data_arg, &raw, &level, &strategy, +  get_all_args(NULL, args, "%*.%d%d%d%d", &data_arg, &raw, &level, &strategy,    &wbits);       switch (TYPEOF(*data_arg))    {    case PIKE_T_STRING:    {    struct pike_string *s = data_arg->u.string;    data.ptr = (unsigned char*)s->str;    data.len = s->len;    data.shift = s->size_shift;    break;    }    case PIKE_T_OBJECT:    {    enum memobj_type t = get_memory_object_memory(data_arg->u.object,    &data.ptr, &data.len,    &data.shift);    if (t != MEMOBJ_NONE)    break; -  // fall through +     } -  +  /* FALLTHRU */    default:    SIMPLE_ARG_TYPE_ERROR("compress", 1, "string|String.Buffer|System.Memory|Stdio.Buffer");    }    if (data.shift)    Pike_error("Cannot input wide string to compress\n");       if( !wbits )    wbits = 15;       if( raw )
pike.git/src/modules/Gz/zlibmod.c:629:    data.shift = s->size_shift;    break;    }    case PIKE_T_OBJECT:    {    enum memobj_type t = get_memory_object_memory(Pike_sp[-args].u.object,    &data.ptr, &data.len,    &data.shift);    if (t != MEMOBJ_NONE)    break; -  // fall through +     } -  +  /* FALLTHRU */    default:    Pike_error("Bad argument 1 to gz_deflate->deflate()\n");    }       if (data.shift)    Pike_error("Cannot input wide string to gz_deflate->deflate()\n");       if(args>1)    {    if(TYPEOF(sp[1-args]) != T_INT)
pike.git/src/modules/Gz/zlibmod.c:690:       pop_n_elems(args);       push_string(buffer_finish_pike_string(&buf));   }         static void init_gz_deflate(struct object *UNUSED(o))   {    mt_init(& THIS->lock); -  memset(& THIS->gz, 0, sizeof(THIS->gz)); +     THIS->gz.zalloc=Z_NULL;    THIS->gz.zfree=Z_NULL;    THIS->gz.opaque=(void *)THIS;    THIS->state=0;    deflateInit(& THIS->gz, THIS->level = Z_DEFAULT_COMPRESSION);    THIS->epilogue = NULL;   }      static void exit_gz_deflate(struct object *UNUSED(o))   {   /* mt_lock(& THIS->lock); */    deflateEnd(&THIS->gz);    do_free_string(THIS->epilogue);    do_free_string(THIS->dict); -  THIS->dict = NULL; +    /* mt_unlock(& THIS->lock); */    mt_destroy( & THIS->lock );   }      /*! @endclass    */      /*******************************************************************/      /*! @class inflate
pike.git/src/modules/Gz/zlibmod.c:776:    {   /* mt_lock(& THIS->lock); */    inflateEnd(&THIS->gz);   /* mt_unlock(& THIS->lock); */    }          THIS->gz.zalloc=Z_NULL;    THIS->gz.zfree=Z_NULL;    THIS->gz.opaque=(void *)THIS; -  if( args && TYPEOF(Pike_sp[-1]) == PIKE_T_MAPPING) +  if(args && TYPEOF(Pike_sp[-1]) == PIKE_T_MAPPING)    {    struct mapping *m = Pike_sp[-1].u.mapping;    struct svalue *tmp;       if (GET_TYPE(STRING, "dictionary")) {    if (tmp->u.string->size_shift)    Pike_error("dictionary cannot be a wide string in "    "gz_inflate->create().\n");    THIS->dict = tmp->u.string;    add_ref(THIS->dict);
pike.git/src/modules/Gz/zlibmod.c:804:    {    if( args && TYPEOF(Pike_sp[-1]) == PIKE_T_INT )    {    tmp=inflateInit2(& THIS->gz, Pike_sp[-1].u.integer);    }    else    {    tmp=inflateInit( &THIS->gz );    }    } +  pop_n_elems(args);      /* mt_lock(& THIS->lock); */   /* mt_unlock(& THIS->lock); */    switch(tmp)    {    case Z_OK:   #if 0 /* this apparently works with newer zlibs only. */    if (THIS->dict) {    int err;   
pike.git/src/modules/Gz/zlibmod.c:991:    data.shift = s->size_shift;    break;    }    case PIKE_T_OBJECT:    {    enum memobj_type t = get_memory_object_memory(Pike_sp[-args].u.object,    &data.ptr, &data.len,    &data.shift);    if (t != MEMOBJ_NONE)    break; -  // fall through +     } -  +  /* FALLTHRU */    default:    SIMPLE_ARG_TYPE_ERROR("uncompress", 1, "string|String.Buffer|System.Memory|Stdio.Buffer");    }    if (data.shift)    Pike_error("Cannot input wide string to uncompress\n");    if(args>1)    {    if(TYPEOF(Pike_sp[1-args]) == PIKE_T_INT)    raw = Pike_sp[1-args].u.integer;    else
pike.git/src/modules/Gz/zlibmod.c:1069:    data.shift = s->size_shift;    break;    }    case PIKE_T_OBJECT:    {    enum memobj_type t = get_memory_object_memory(Pike_sp[-args].u.object,    &data.ptr, &data.len,    &data.shift);    if (t != MEMOBJ_NONE)    break; -  // fall through +     } -  +  /* FALLTHRU */    default:    Pike_error("Bad argument 1 to gz_inflate->inflate()\n");    }       if (data.shift)    Pike_error("Cannot input wide string to gz_inflate->inflate()\n");       this->gz.next_in=(Bytef *)data.ptr;    this->gz.avail_in = (unsigned INT32)(data.len);   
pike.git/src/modules/Gz/zlibmod.c:1139:    pop_n_elems(args);    if(this->epilogue)    ref_push_string(this->epilogue);    else    push_int(0);   }      static void init_gz_inflate(struct object *UNUSED(o))   {    mt_init(& THIS->lock); -  memset(& THIS->gz, 0, sizeof(THIS->gz)); +     THIS->gz.zalloc=Z_NULL;    THIS->gz.zfree=Z_NULL;    THIS->gz.opaque=(void *)THIS;    inflateInit(&THIS->gz);    inflateEnd(&THIS->gz);    THIS->epilogue = NULL;   }      static void exit_gz_inflate(struct object *UNUSED(o))   {   /* mt_lock(& THIS->lock); */    inflateEnd(& THIS->gz);    do_free_string(THIS->epilogue);    do_free_string(THIS->dict); -  THIS->dict = NULL; +    /* mt_unlock(& THIS->lock); */    mt_destroy( & THIS->lock );   }      /*! @endclass    */      /*! @decl int crc32(string(8bit) data, void|int(0..) start_value)    *!    *! This function calculates the standard ISO3309 Cyclic Redundancy Check.
pike.git/src/modules/Gz/zlibmod.c:1360: Inside #if defined(HAVE_ZLIB_H)
      PIKE_MODULE_EXPORT(Gz, crc32);    PIKE_MODULE_EXPORT(Gz, zlibmod_pack);    PIKE_MODULE_EXPORT(Gz, zlibmod_unpack);   #else    HIDE_MODULE();   #endif   }      PIKE_MODULE_EXIT {} -  - #if defined(HAVE___VTBL__9TYPE_INFO) || defined(HAVE___T_9__NOTHROW) - /* Super-special kluge for IRIX 6.3 */ - #ifdef HAVE___VTBL__9TYPE_INFO - extern void __vtbl__9type_info(void); - #endif /* HAVE___VTBL__9TYPE_INFO */ - #ifdef HAVE___T_9__NOTHROW - extern void __T_9__nothrow(void); - #endif /* HAVE___T_9__NOTHROW */ - /* Don't even think of calling this one -  * Not static, so the compiler can't optimize it away totally. -  */ - void zlibmod_strap_kluge(void) - { - #ifdef HAVE___VTBL__9TYPE_INFO -  __vtbl__9type_info(); - #endif /* HAVE___VTBL__9TYPE_INFO */ - #ifdef HAVE___T_9__NOTHROW -  __T_9__nothrow(); - #endif /* HAVE___T_9__NOTHROW */ - } - #endif /* HAVE___VTBL__9TYPE_INFO || HAVE___T_9__NOTHROW */ +