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

version» Context lines:

pike.git/src/modules/Gz/zlibmod.c:51:    size_t len;    int shift;   };      #define BUF 32768   #define MAX_BUF (64*BUF)      #undef THIS   #define THIS ((struct zipper *)(Pike_fp->current_storage))    + static struct program *deflate_program; +    /*! @module Gz    *!    *! The Gz module contains functions to compress and uncompress strings using    *! the same algorithm as the program @tt{gzip@}. Compressing can be done in    *! streaming mode or all at once.    *!    *! The Gz module consists of two classes; Gz.deflate and Gz.inflate.    *! Gz.deflate is used to pack data    *! and Gz.inflate is used to unpack data. (Think "inflatable boat")    *!
pike.git/src/modules/Gz/zlibmod.c:283:    break;       default:    if(THIS->gz.msg)    Pike_error("Failed to initialize Gz.deflate: %s\n",THIS->gz.msg);    else    Pike_error("Failed to initialize Gz.deflate (%d).\n", tmp);    }   }    + /*! @decl Gz.deflate clone() +  *! +  *! Clones the deflate object. Typically used to test compression +  *! of new content using the same exact state. +  *! +  */ + static void gz_deflate_clone(INT32 args) { +  int tmp; +  struct object *ob = low_clone(deflate_program); +  struct zipper *clone = get_storage(ob, deflate_program);    -  +  clone->level = THIS->level; +  clone->state = THIS->state; +  +  push_object(ob); +  +  switch(tmp = deflateCopy(&clone->gz, &THIS->gz)) { +  case Z_OK: +  break; +  +  case Z_MEM_ERROR: +  Pike_error ("Out of memory while cloning Gz.deflate.\n"); +  break; +  +  default: +  if(THIS->gz.msg) +  Pike_error("Failed to clone Gz.deflate: %s\n",THIS->gz.msg); +  else +  Pike_error("Failed to clone Gz.deflate (%d).\n", tmp); +  } + } +    #ifdef _REENTRANT   static void do_mt_unlock (PIKE_MUTEX_T *lock)   {    mt_unlock (lock);   }   #endif      static int do_deflate(dynamic_buffer *buf,    struct zipper *this,    int flush)
pike.git/src/modules/Gz/zlibmod.c:1225:   }      PIKE_MODULE_INIT   {   #ifdef HAVE_ZLIB_H    struct z_stream_s z; /* Used to detect support for extensions. */    int have_rle = 0;    int have_fixed = 0;       start_new_program(); +  deflate_program = Pike_compiler->new_program;    ADD_STORAGE(struct zipper);       /* function(int|void,int|void,int|void:void) */    ADD_FUNCTION("create",gz_deflate_create,tFunc(tOr(tMapping, tOr(tInt,tVoid)) tOr(tInt,tVoid) tOr(tInt,tVoid),tVoid),0);    /* function(string(8bit)|String.Buffer|System.Memory|Stdio.Buffer,int|void:string(8bit)) */    ADD_FUNCTION("deflate",gz_deflate,tFunc(tOr(tStr8,tObj) tOr(tInt,tVoid),tStr8),0);    ADD_FUNCTION("_size_object", gz_deflate_size, tFunc(tVoid,tInt), 0);       add_integer_constant("NO_FLUSH",Z_NO_FLUSH,0);    add_integer_constant("PARTIAL_FLUSH",Z_PARTIAL_FLUSH,0);
pike.git/src/modules/Gz/zlibmod.c:1284: Inside #if defined(HAVE_ZLIB_H)
   add_integer_constant("PARTIAL_FLUSH",Z_PARTIAL_FLUSH,0);    add_integer_constant("SYNC_FLUSH",Z_SYNC_FLUSH,0);    add_integer_constant("FINISH",Z_FINISH,0);       set_init_callback(init_gz_inflate);    set_exit_callback(exit_gz_inflate);       end_class("inflate",0);       add_integer_constant("NO_FLUSH",Z_NO_FLUSH,0); +  add_integer_constant("BLOCK",Z_BLOCK,0);    add_integer_constant("PARTIAL_FLUSH",Z_PARTIAL_FLUSH,0);    add_integer_constant("SYNC_FLUSH",Z_SYNC_FLUSH,0); -  +  add_integer_constant("FULL_FLUSH",Z_FULL_FLUSH,0);    add_integer_constant("FINISH",Z_FINISH,0);    add_integer_constant("DEFAULT_STRATEGY", Z_DEFAULT_STRATEGY,0);    add_integer_constant("FILTERED", Z_FILTERED,0);    add_integer_constant("HUFFMAN_ONLY", Z_HUFFMAN_ONLY,0);   #ifdef Z_RLE    if (have_rle) {    add_integer_constant("RLE", Z_RLE,0);    }   #endif   #ifdef Z_FIXED