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.17 1997/11/11 03:56:25 grubba Exp $"); + RCSID("$Id: zlibmod.c,v 1.18 1998/02/27 20:21:27 mirar 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:160:    flush=sp[1-args].u.integer;       switch(flush)    {    case Z_PARTIAL_FLUSH:    case Z_FINISH:    case Z_SYNC_FLUSH:    case Z_NO_FLUSH:    break;    -  defualt: +  default:    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=data->len;       fail=do_deflate(&buf,this,flush);
pike.git/src/modules/Gz/zlibmod.c:336:    inflateEnd(&THIS->gz);   }      static void exit_gz_inflate(struct object *o)   {   /* mt_lock(& THIS->lock); */    inflateEnd(& THIS->gz);   /* mt_unlock(& 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"); +  +  if (args>1) +  if (sp[1-args].type!=T_INT) +  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, +  sp[-args].u.string->len); +  +  pop_n_elems(args); +  push_int((INT32)crc); + } +  +    #endif      void pike_module_exit(void) {}      void pike_module_init(void)   {   #ifdef HAVE_ZLIB_H    start_new_program();    add_storage(sizeof(struct zipper));   
pike.git/src/modules/Gz/zlibmod.c:380: Inside #if defined(HAVE_ZLIB_H)
   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("PARTIAL_FLUSH",Z_PARTIAL_FLUSH,0);    add_integer_constant("SYNC_FLUSH",Z_SYNC_FLUSH,0);    add_integer_constant("FINISH",Z_FINISH,0);    +  add_function("crc32",gz_crc32, +  "function(string,void|int:int)", +  OPT_TRY_OPTIMIZE); +    #endif   }      #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);