File: //proc/self/root/proc/2/cwd/installd/perl588installer/Compress-Raw-Zlib-2.015/Zlib.c
/*
* This file was generated automatically by xsubpp version 1.9508 from the
* contents of Zlib.xs. Do not edit this file, edit Zlib.xs instead.
*
* ANY CHANGES MADE HERE WILL BE LOST!
*
*/
#line 1 "Zlib.xs"
/* Filename: Zlib.xs
* Author : Paul Marquess, <pmqs@cpan.org>
* Created : 22nd January 1996
* Version : 2.000
*
* Copyright (c) 1995-2007 Paul Marquess. All rights reserved.
* This program is free software; you can redistribute it and/or
* modify it under the same terms as Perl itself.
*
*/
/* Parts of this code are based on the files gzio.c and gzappend.c from
* the standard zlib source distribution. Below are the copyright statements
* from each.
*/
/* gzio.c -- IO on .gz files
* Copyright (C) 1995 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* gzappend -- command to append to a gzip file
Copyright (C) 2003 Mark Adler, all rights reserved
version 1.1, 4 Nov 2003
*/
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include <zlib.h>
/* zlib prior to 1.06 doesn't know about z_off_t */
#ifndef z_off_t
# define z_off_t long
#endif
#if ! defined(ZLIB_VERNUM) || ZLIB_VERNUM < 0x1200
# define NEED_DUMMY_BYTE_AT_END
#endif
#if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1210
# define MAGIC_APPEND
#endif
#if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1221
# define AT_LEAST_ZLIB_1_2_2_1
#endif
#if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1222
# define AT_LEAST_ZLIB_1_2_2_2
#endif
#if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1223
# define AT_LEAST_ZLIB_1_2_2_3
#endif
#if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1230
# define AT_LEAST_ZLIB_1_2_3
#endif
#ifdef USE_PPPORT_H
# define NEED_sv_2pvbyte
# define NEED_sv_2pv_nolen
# include "ppport.h"
#endif
#if PERL_REVISION == 5 && PERL_VERSION == 9
/* For Andreas */
# define sv_pvbyte_force(sv,lp) sv_pvbyten_force(sv,lp)
#endif
#if PERL_REVISION == 5 && (PERL_VERSION < 8 || (PERL_VERSION == 8 && PERL_SUBVERSION < 4 ))
# ifdef SvPVbyte_force
# undef SvPVbyte_force
# endif
# define SvPVbyte_force(sv,lp) SvPV_force(sv,lp)
#endif
#ifndef SvPVbyte_nolen
# define SvPVbyte_nolen SvPV_nolen
#endif
#if 0
# ifndef SvPVbyte_nolen
# define SvPVbyte_nolen SvPV_nolen
# endif
# ifndef SvPVbyte_force
# define SvPVbyte_force(sv,lp) SvPV_force(sv,lp)
# endif
#endif
#if PERL_REVISION == 5 && (PERL_VERSION >= 8 || (PERL_VERSION == 8 && PERL_SUBVERSION < 4 ))
# define UTF8_AVAILABLE
#endif
typedef int DualType ;
typedef int int_undef ;
typedef struct di_stream {
int flags ;
#define FLAG_APPEND 1
#define FLAG_CRC32 2
#define FLAG_ADLER32 4
#define FLAG_CONSUME_INPUT 8
#define FLAG_LIMIT_OUTPUT 16
uLong crc32 ;
uLong adler32 ;
z_stream stream;
uLong bufsize;
SV * dictionary ;
uLong dict_adler ;
int last_error ;
bool zip_mode ;
#define SETP_BYTE
#ifdef SETP_BYTE
bool deflateParams_out_valid ;
Bytef deflateParams_out_byte;
#else
#define deflateParams_BUFFER_SIZE 0x4000
uLong deflateParams_out_length;
Bytef* deflateParams_out_buffer;
#endif
int Level;
int Method;
int WindowBits;
int MemLevel;
int Strategy;
uLong bytesInflated ;
uLong compressedBytes ;
uLong uncompressedBytes ;
#ifdef MAGIC_APPEND
#define WINDOW_SIZE 32768U
bool matchedEndBlock;
Bytef* window ;
int window_lastbit, window_left, window_full;
unsigned window_have;
off_t window_lastoff, window_end;
off_t window_endOffset;
uLong lastBlockOffset ;
unsigned char window_lastByte ;
#endif
} di_stream;
typedef di_stream * deflateStream ;
typedef di_stream * Compress__Raw__Zlib__deflateStream ;
typedef di_stream * inflateStream ;
typedef di_stream * Compress__Raw__Zlib__inflateStream ;
typedef di_stream * Compress__Raw__Zlib__inflateScanStream ;
#define ZMALLOC(to, typ) ((to = (typ *)safemalloc(sizeof(typ))), \
Zero(to,1,typ))
/* Figure out the Operating System */
#ifdef MSDOS
# define OS_CODE 0x00
#endif
#if defined(AMIGA) || defined(AMIGAOS)
# define OS_CODE 0x01
#endif
#if defined(VAXC) || defined(VMS)
# define OS_CODE 0x02
#endif
#if 0 /* VM/CMS */
# define OS_CODE 0x04
#endif
#if defined(ATARI) || defined(atarist)
# define OS_CODE 0x05
#endif
#ifdef OS2
# define OS_CODE 0x06
#endif
#if defined(MACOS) || defined(TARGET_OS_MAC)
# define OS_CODE 0x07
#endif
#if 0 /* Z-System */
# define OS_CODE 0x08
#endif
#if 0 /* CP/M */
# define OS_CODE 0x09
#endif
#ifdef TOPS20
# define OS_CODE 0x0a
#endif
#ifdef WIN32 /* Window 95 & Windows NT */
# define OS_CODE 0x0b
#endif
#if 0 /* QDOS */
# define OS_CODE 0x0c
#endif
#if 0 /* Acorn RISCOS */
# define OS_CODE 0x0d
#endif
#if 0 /* ??? */
# define OS_CODE 0x0e
#endif
#ifdef __50SERIES /* Prime/PRIMOS */
# define OS_CODE 0x0F
#endif
/* Default to UNIX */
#ifndef OS_CODE
# define OS_CODE 0x03 /* assume Unix */
#endif
#ifndef GZIP_OS_CODE
# define GZIP_OS_CODE OS_CODE
#endif
#define adlerInitial adler32(0L, Z_NULL, 0)
#define crcInitial crc32(0L, Z_NULL, 0)
/* static const char * const my_z_errmsg[] = { */
static const char my_z_errmsg[][32] = {
"need dictionary", /* Z_NEED_DICT 2 */
"stream end", /* Z_STREAM_END 1 */
"", /* Z_OK 0 */
"file error", /* Z_ERRNO (-1) */
"stream error", /* Z_STREAM_ERROR (-2) */
"data error", /* Z_DATA_ERROR (-3) */
"insufficient memory", /* Z_MEM_ERROR (-4) */
"buffer error", /* Z_BUF_ERROR (-5) */
"incompatible version",/* Z_VERSION_ERROR(-6) */
""};
#define setDUALstatus(var, err) \
sv_setnv(var, (double)err) ; \
sv_setpv(var, ((err) ? GetErrorString(err) : "")) ; \
SvNOK_on(var);
#if defined(__SYMBIAN32__)
# define NO_WRITEABLE_DATA
#endif
#define TRACE_DEFAULT 0
#ifdef NO_WRITEABLE_DATA
# define trace TRACE_DEFAULT
#else
static int trace = TRACE_DEFAULT ;
#endif
/* Dodge PerlIO hiding of these functions. */
#undef printf
static char *
#ifdef CAN_PROTOTYPE
GetErrorString(int error_no)
#else
GetErrorString(error_no)
int error_no ;
#endif
{
dTHX;
char * errstr ;
if (error_no == Z_ERRNO) {
errstr = Strerror(errno) ;
}
else
/* errstr = gzerror(fil, &error_no) ; */
errstr = (char*) my_z_errmsg[2 - error_no];
return errstr ;
}
#ifdef MAGIC_APPEND
/*
The following two functions are taken almost directly from
examples/gzappend.c. Only cosmetic changes have been made to conform to
the coding style of the rest of the code in this file.
*/
/* return the greatest common divisor of a and b using Euclid's algorithm,
modified to be fast when one argument much greater than the other, and
coded to avoid unnecessary swapping */
static unsigned
#ifdef CAN_PROTOTYPE
gcd(unsigned a, unsigned b)
#else
gcd(a, b)
unsigned a;
unsigned b;
#endif
{
unsigned c;
while (a && b)
if (a > b) {
c = b;
while (a - c >= c)
c <<= 1;
a -= c;
}
else {
c = a;
while (b - c >= c)
c <<= 1;
b -= c;
}
return a + b;
}
/* rotate list[0..len-1] left by rot positions, in place */
static void
#ifdef CAN_PROTOTYPE
rotate(unsigned char *list, unsigned len, unsigned rot)
#else
rotate(list, len, rot)
unsigned char *list;
unsigned len ;
unsigned rot;
#endif
{
unsigned char tmp;
unsigned cycles;
unsigned char *start, *last, *to, *from;
/* normalize rot and handle degenerate cases */
if (len < 2) return;
if (rot >= len) rot %= len;
if (rot == 0) return;
/* pointer to last entry in list */
last = list + (len - 1);
/* do simple left shift by one */
if (rot == 1) {
tmp = *list;
memcpy(list, list + 1, len - 1);
*last = tmp;
return;
}
/* do simple right shift by one */
if (rot == len - 1) {
tmp = *last;
memmove(list + 1, list, len - 1);
*list = tmp;
return;
}
/* otherwise do rotate as a set of cycles in place */
cycles = gcd(len, rot); /* number of cycles */
do {
start = from = list + cycles; /* start index is arbitrary */
tmp = *from; /* save entry to be overwritten */
for (;;) {
to = from; /* next step in cycle */
from += rot; /* go right rot positions */
if (from > last) from -= len; /* (pointer better not wrap) */
if (from == start) break; /* all but one shifted */
*to = *from; /* shift left */
}
*to = tmp; /* complete the circle */
} while (--cycles);
}
#endif /* MAGIC_APPEND */
static void
#ifdef CAN_PROTOTYPE
DispHex(void * ptr, int length)
#else
DispHex(ptr, length)
void * ptr;
int length;
#endif
{
char * p = (char*)ptr;
int i;
for (i = 0; i < length; ++i) {
printf(" %02x", 0xFF & *(p+i));
}
}
static void
#ifdef CAN_PROTOTYPE
DispStream(di_stream * s, char * message)
#else
DispStream(s, message)
di_stream * s;
char * message;
#endif
{
#if 0
if (! trace)
return ;
#endif
#define EnDis(f) (s->flags & f ? "Enabled" : "Disabled")
printf("DispStream 0x%p", s) ;
if (message)
printf("- %s \n", message) ;
printf("\n") ;
if (!s) {
printf(" stream pointer is NULL\n");
}
else {
printf(" stream 0x%p\n", &(s->stream));
printf(" zalloc 0x%p\n", s->stream.zalloc);
printf(" zfree 0x%p\n", s->stream.zfree);
printf(" opaque 0x%p\n", s->stream.opaque);
if (s->stream.msg)
printf(" msg %s\n", s->stream.msg);
else
printf(" msg \n");
printf(" next_in 0x%p", s->stream.next_in);
if (s->stream.next_in){
printf(" =>");
DispHex(s->stream.next_in, 4);
}
printf("\n");
printf(" next_out 0x%p", s->stream.next_out);
if (s->stream.next_out){
printf(" =>");
DispHex(s->stream.next_out, 4);
}
printf("\n");
printf(" avail_in %lu\n", (unsigned long)s->stream.avail_in);
printf(" avail_out %lu\n", (unsigned long)s->stream.avail_out);
printf(" total_in %ld\n", s->stream.total_in);
printf(" total_out %ld\n", s->stream.total_out);
printf(" adler %ld\n", s->stream.adler );
printf(" bufsize %ld\n", s->bufsize);
printf(" dictionary 0x%p\n", s->dictionary);
printf(" dict_adler 0x%ld\n",s->dict_adler);
printf(" zip_mode %d\n", s->zip_mode);
printf(" crc32 0x%x\n", (unsigned)s->crc32);
printf(" adler32 0x%x\n", (unsigned)s->adler32);
printf(" flags 0x%x\n", s->flags);
printf(" APPEND %s\n", EnDis(FLAG_APPEND));
printf(" CRC32 %s\n", EnDis(FLAG_CRC32));
printf(" ADLER32 %s\n", EnDis(FLAG_ADLER32));
printf(" CONSUME %s\n", EnDis(FLAG_CONSUME_INPUT));
printf(" LIMIT %s\n", EnDis(FLAG_LIMIT_OUTPUT));
#ifdef MAGIC_APPEND
printf(" window 0x%p\n", s->window);
#endif
printf("\n");
}
}
static di_stream *
#ifdef CAN_PROTOTYPE
InitStream(void)
#else
InitStream()
#endif
{
di_stream *s ;
ZMALLOC(s, di_stream) ;
return s ;
}
static void
#ifdef CAN_PROTOTYPE
PostInitStream(di_stream * s, int flags, int bufsize, int windowBits)
#else
PostInitStream(s, flags, bufsize, windowBits)
di_stream *s ;
int flags ;
int bufsize ;
int windowBits ;
#endif
{
s->bufsize = bufsize ;
s->compressedBytes =
s->uncompressedBytes =
s->last_error = 0 ;
s->flags = flags ;
s->zip_mode = (windowBits < 0) ;
if (flags & FLAG_CRC32)
s->crc32 = crcInitial ;
if (flags & FLAG_ADLER32)
s->adler32 = adlerInitial ;
}
static SV*
#ifdef CAN_PROTOTYPE
deRef(SV * sv, const char * string)
#else
deRef(sv, string)
SV * sv ;
char * string;
#endif
{
dTHX;
SvGETMAGIC(sv);
if (SvROK(sv)) {
sv = SvRV(sv) ;
SvGETMAGIC(sv);
switch(SvTYPE(sv)) {
case SVt_PVAV:
case SVt_PVHV:
case SVt_PVCV:
croak("%s: buffer parameter is not a SCALAR reference", string);
}
if (SvROK(sv))
croak("%s: buffer parameter is a reference to a reference", string) ;
}
if (!SvOK(sv)) {
sv = newSVpv("", 0);
}
return sv ;
}
static SV*
#ifdef CAN_PROTOTYPE
deRef_l(SV * sv, const char * string)
#else
deRef_l(sv, string)
SV * sv ;
char * string ;
#endif
{
dTHX;
bool wipe = 0 ;
SvGETMAGIC(sv);
wipe = ! SvOK(sv) ;
if (SvROK(sv)) {
sv = SvRV(sv) ;
SvGETMAGIC(sv);
wipe = ! SvOK(sv) ;
switch(SvTYPE(sv)) {
case SVt_PVAV:
case SVt_PVHV:
case SVt_PVCV:
croak("%s: buffer parameter is not a SCALAR reference", string);
}
if (SvROK(sv))
croak("%s: buffer parameter is a reference to a reference", string) ;
}
if (SvREADONLY(sv) && PL_curcop != &PL_compiling)
croak("%s: buffer parameter is read-only", string);
SvUPGRADE(sv, SVt_PV);
if (wipe)
SvCUR_set(sv, 0);
SvOOK_off(sv);
SvPOK_only(sv);
return sv ;
}
#include "constants.h"
#line 613 "Zlib.c"
/* INCLUDE: Including 'constants.xs' from 'Zlib.xs' */
XS(XS_Compress__Raw__Zlib_constant); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib_constant)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::constant(sv)");
SP -= items;
{
#line 4 "constants.xs"
#ifdef dXSTARG
dXSTARG; /* Faster if we have it. */
#else
dTARGET;
#endif
STRLEN len;
int type;
IV iv;
/* NV nv; Uncomment this if you need to return NVs */
const char *pv;
#line 637 "Zlib.c"
SV * sv = ST(0);
const char * s = SvPV(sv, len);
#line 18 "constants.xs"
/* Change this to constant(aTHX_ s, len, &iv, &nv);
if you need to return both NVs and IVs */
type = constant(aTHX_ s, len, &iv, &pv);
/* Return 1 or 2 items. First is error message, or undef if no error.
Second, if present, is found value */
switch (type) {
case PERL_constant_NOTFOUND:
sv = sv_2mortal(newSVpvf("%s is not a valid Zlib macro", s));
PUSHs(sv);
break;
case PERL_constant_NOTDEF:
sv = sv_2mortal(newSVpvf(
"Your vendor has not defined Zlib macro %s, used", s));
PUSHs(sv);
break;
case PERL_constant_ISIV:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHi(iv);
break;
/* Uncomment this if you need to return NOs
case PERL_constant_ISNO:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHs(&PL_sv_no);
break; */
/* Uncomment this if you need to return NVs
case PERL_constant_ISNV:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHn(nv);
break; */
case PERL_constant_ISPV:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHp(pv, strlen(pv));
break;
/* Uncomment this if you need to return PVNs
case PERL_constant_ISPVN:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHp(pv, iv);
break; */
/* Uncomment this if you need to return SVs
case PERL_constant_ISSV:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHs(sv);
break; */
/* Uncomment this if you need to return UNDEFs
case PERL_constant_ISUNDEF:
break; */
/* Uncomment this if you need to return UVs
case PERL_constant_ISUV:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHu((UV)iv);
break; */
/* Uncomment this if you need to return YESs
case PERL_constant_ISYES:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHs(&PL_sv_yes);
break; */
default:
sv = sv_2mortal(newSVpvf(
"Unexpected return type %d while processing Zlib macro %s, used",
type, s));
PUSHs(sv);
}
#line 711 "Zlib.c"
PUTBACK;
return;
}
}
/* INCLUDE: Returning to 'Zlib.xs' from 'constants.xs' */
#define Zip_zlib_version() (const char*)zlib_version
XS(XS_Compress__Raw__Zlib_zlib_version); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib_zlib_version)
{
dXSARGS;
if (items != 0)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::zlib_version()");
{
const char * RETVAL;
dXSTARG;
RETVAL = Zip_zlib_version();
sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib_ZLIB_VERNUM); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib_ZLIB_VERNUM)
{
dXSARGS;
if (items != 0)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::ZLIB_VERNUM()");
{
unsigned RETVAL;
dXSTARG;
#line 629 "Zlib.xs"
#ifdef ZLIB_VERNUM
RETVAL = ZLIB_VERNUM ;
#else
/* 1.1.4 => 0x1140 */
RETVAL = (ZLIB_VERSION[0] - '0') << 12 ;
RETVAL += (ZLIB_VERSION[2] - '0') << 8 ;
RETVAL += (ZLIB_VERSION[4] - '0') << 4 ;
#endif
#line 757 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
#define Zip_adler32(buf, adler) adler32(adler, buf, (uInt)len)
XS(XS_Compress__Raw__Zlib_adler32); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib_adler32)
{
dXSARGS;
if (items < 1 || items > 2)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::adler32(buf, adler=adlerInitial)");
{
uLong adler;
STRLEN len;
Bytef * buf;
SV * sv = ST(0) ;
uLong RETVAL;
dXSTARG;
#line 651 "Zlib.xs"
/* If the buffer is a reference, dereference it */
sv = deRef(sv, "adler32") ;
#ifdef UTF8_AVAILABLE
if (DO_UTF8(sv) && !sv_utf8_downgrade(sv, 1))
croak("Wide character in Compress::Raw::Zlib::adler32");
#endif
buf = (Byte*)SvPVbyte(sv, len) ;
if (items < 2)
adler = adlerInitial;
else if (SvOK(ST(1)))
adler = SvUV(ST(1)) ;
else
adler = adlerInitial;
#line 793 "Zlib.c"
RETVAL = Zip_adler32(buf, adler);
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
#define Zip_crc32(buf, crc) crc32(crc, buf, (uInt)len)
XS(XS_Compress__Raw__Zlib_crc32); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib_crc32)
{
dXSARGS;
if (items < 1 || items > 2)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::crc32(buf, crc=crcInitial)");
{
uLong crc;
STRLEN len;
Bytef * buf;
SV * sv = ST(0) ;
uLong RETVAL;
dXSTARG;
#line 677 "Zlib.xs"
/* If the buffer is a reference, dereference it */
sv = deRef(sv, "crc32") ;
#ifdef UTF8_AVAILABLE
if (DO_UTF8(sv) && !sv_utf8_downgrade(sv, 1))
croak("Wide character in Compress::Raw::Zlib::crc32");
#endif
buf = (Byte*)SvPVbyte(sv, len) ;
if (items < 2)
crc = crcInitial;
else if (SvOK(ST(1)))
crc = SvUV(ST(1)) ;
else
crc = crcInitial;
#line 831 "Zlib.c"
RETVAL = Zip_crc32(buf, crc);
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib_crc32_combine); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib_crc32_combine)
{
dXSARGS;
if (items != 3)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::crc32_combine(crc1, crc2, len2)");
{
uLong crc1 = (unsigned long)SvUV(ST(0));
uLong crc2 = (unsigned long)SvUV(ST(1));
z_off_t len2 = (unsigned long)SvUV(ST(2));
uLong RETVAL;
dXSTARG;
#line 699 "Zlib.xs"
#ifndef AT_LEAST_ZLIB_1_2_2_1
crc1 = crc1; crc2 = crc2 ; len2 = len2; /* Silence -Wall */
croak("crc32_combine needs zlib 1.2.3 or better");
#else
RETVAL = crc32_combine(crc1, crc2, len2);
#endif
#line 859 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib_adler32_combine); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib_adler32_combine)
{
dXSARGS;
if (items != 3)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::adler32_combine(adler1, adler2, len2)");
{
uLong adler1 = (unsigned long)SvUV(ST(0));
uLong adler2 = (unsigned long)SvUV(ST(1));
z_off_t len2 = (unsigned long)SvUV(ST(2));
uLong RETVAL;
dXSTARG;
#line 715 "Zlib.xs"
#ifndef AT_LEAST_ZLIB_1_2_2_1
adler1 = adler1; adler2 = adler2 ; len2 = len2; /* Silence -Wall */
croak("adler32_combine needs zlib 1.2.3 or better");
#else
RETVAL = adler32_combine(adler1, adler2, len2);
#endif
#line 885 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__deflateInit); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__deflateInit)
{
dXSARGS;
if (items != 8)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::_deflateInit(flags, level, method, windowBits, memLevel, strategy, bufsize, dictionary)");
SP -= items;
{
int flags = (int)SvIV(ST(0));
int level = (int)SvIV(ST(1));
int method = (int)SvIV(ST(2));
int windowBits = (int)SvIV(ST(3));
int memLevel = (int)SvIV(ST(4));
int strategy = (int)SvIV(ST(5));
uLong bufsize = (unsigned long)SvUV(ST(6));
SV* dictionary = ST(7);
#line 738 "Zlib.xs"
int err ;
deflateStream s ;
if (trace)
warn("in _deflateInit(level=%d, method=%d, windowBits=%d, memLevel=%d, strategy=%d, bufsize=%ld dictionary=%p)\n",
level, method, windowBits, memLevel, strategy, bufsize, dictionary) ;
if ((s = InitStream() )) {
s->Level = level;
s->Method = method;
s->WindowBits = windowBits;
s->MemLevel = memLevel;
s->Strategy = strategy;
err = deflateInit2(&(s->stream), level,
method, windowBits, memLevel, strategy);
/* Check if a dictionary has been specified */
if (err == Z_OK && SvCUR(dictionary)) {
#ifdef UTF8_AVAILABLE
if (DO_UTF8(dictionary) && !sv_utf8_downgrade(dictionary, 1))
croak("Wide character in Compress::Raw::Zlib::Deflate::new dicrionary parameter");
#endif
err = deflateSetDictionary(&(s->stream), (const Bytef*) SvPVbyte_nolen(dictionary),
SvCUR(dictionary)) ;
s->dict_adler = s->stream.adler ;
}
if (err != Z_OK) {
Safefree(s) ;
s = NULL ;
}
else
PostInitStream(s, flags, bufsize, windowBits) ;
}
else
err = Z_MEM_ERROR ;
{
SV* obj = sv_setref_pv(sv_newmortal(),
"Compress::Raw::Zlib::deflateStream", (void*)s);
XPUSHs(obj);
}
if (GIMME == G_ARRAY) {
SV * sv = sv_2mortal(newSViv(err)) ;
setDUALstatus(sv, err);
XPUSHs(sv) ;
}
#line 959 "Zlib.c"
PUTBACK;
return;
}
}
XS(XS_Compress__Raw__Zlib__inflateInit); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateInit)
{
dXSARGS;
dXSI32;
if (items != 4)
Perl_croak(aTHX_ "Usage: %s(flags, windowBits, bufsize, dictionary)", GvNAME(CvGV(cv)));
SP -= items;
{
int flags = (int)SvIV(ST(0));
int windowBits = (int)SvIV(ST(1));
uLong bufsize = (unsigned long)SvUV(ST(2));
SV * dictionary = ST(3);
#line 799 "Zlib.xs"
int err = Z_OK ;
inflateStream s ;
#ifndef MAGIC_APPEND
if (ix == 1)
croak("inflateScanInit needs zlib 1.2.1 or better");
#endif
if (trace)
warn("in _inflateInit(windowBits=%d, bufsize=%lu, dictionary=%lu\n",
windowBits, bufsize, (unsigned long)SvCUR(dictionary)) ;
if ((s = InitStream() )) {
s->WindowBits = windowBits;
err = inflateInit2(&(s->stream), windowBits);
if (err != Z_OK) {
Safefree(s) ;
s = NULL ;
}
else if (SvCUR(dictionary)) {
#ifdef AT_LEAST_ZLIB_1_2_2_1
/* Zlib 1.2.2.1 or better allows a dictionary with raw inflate */
if (s->WindowBits < 0) {
err = inflateSetDictionary(&(s->stream),
(const Bytef*)SvPVbyte_nolen(dictionary),
SvCUR(dictionary));
if (err != Z_OK) {
Safefree(s) ;
s = NULL ;
}
}
else
#endif
/* Dictionary specified - take a copy for use in inflate */
s->dictionary = newSVsv(dictionary) ;
}
if (s) {
PostInitStream(s, flags, bufsize, windowBits) ;
#ifdef MAGIC_APPEND
if (ix == 1)
{
s->window = (unsigned char *)safemalloc(WINDOW_SIZE);
}
#endif
}
}
else
err = Z_MEM_ERROR ;
{
SV* obj = sv_setref_pv(sv_newmortal(),
ix == 1
? "Compress::Raw::Zlib::inflateScanStream"
: "Compress::Raw::Zlib::inflateStream",
(void*)s);
XPUSHs(obj);
}
if (GIMME == G_ARRAY) {
SV * sv = sv_2mortal(newSViv(err)) ;
setDUALstatus(sv, err);
XPUSHs(sv) ;
}
#line 1041 "Zlib.c"
PUTBACK;
return;
}
}
XS(XS_Compress__Raw__Zlib__deflateStream_DispStream); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__deflateStream_DispStream)
{
dXSARGS;
if (items < 1 || items > 2)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::deflateStream::DispStream(s, message=NULL)");
{
Compress__Raw__Zlib__deflateStream s;
char * message;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::deflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__deflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::deflateStream");
if (items < 2)
message = NULL;
else {
if (SvOK(ST(1)))
message = (char *)SvPVbyte_nolen(ST(1));
else
message = NULL ;
}
DispStream(s, message);
}
XSRETURN_EMPTY;
}
XS(XS_Compress__Raw__Zlib__deflateStream_deflateReset); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__deflateStream_deflateReset)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::deflateStream::deflateReset(s)");
{
Compress__Raw__Zlib__deflateStream s;
DualType RETVAL;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::deflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__deflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::deflateStream");
#line 874 "Zlib.xs"
RETVAL = deflateReset(&(s->stream)) ;
if (RETVAL == Z_OK) {
PostInitStream(s, s->flags, s->bufsize, s->WindowBits) ;
}
#line 1101 "Zlib.c"
ST(0) = sv_newmortal();
setDUALstatus(ST(0), RETVAL) ;
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__deflateStream_deflate); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__deflateStream_deflate)
{
dXSARGS;
if (items != 3)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::deflateStream::deflate(s, buf, output)");
{
Compress__Raw__Zlib__deflateStream s;
SV * buf = ST(1);
SV * output = ST(2);
uInt cur_length;
uInt increment;
uInt prefix;
int RETVAL = 0;
uLong bufinc;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::deflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__deflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::deflateStream");
#line 892 "Zlib.xs"
bufinc = s->bufsize;
/* If the input buffer is a reference, dereference it */
buf = deRef(buf, "deflate") ;
/* initialise the input buffer */
#ifdef UTF8_AVAILABLE
if (DO_UTF8(buf) && !sv_utf8_downgrade(buf, 1))
croak("Wide character in Compress::Raw::Zlib::Deflate::deflate input parameter");
#endif
s->stream.next_in = (Bytef*)SvPVbyte_nolen(buf) ;
s->stream.avail_in = SvCUR(buf) ;
if (s->flags & FLAG_CRC32)
s->crc32 = crc32(s->crc32, s->stream.next_in, s->stream.avail_in) ;
if (s->flags & FLAG_ADLER32)
s->adler32 = adler32(s->adler32, s->stream.next_in, s->stream.avail_in) ;
/* and retrieve the output buffer */
output = deRef_l(output, "deflate") ;
#ifdef UTF8_AVAILABLE
if (DO_UTF8(output) && !sv_utf8_downgrade(output, 1))
croak("Wide character in Compress::Raw::Zlib::Deflate::deflate output parameter");
#endif
if((s->flags & FLAG_APPEND) != FLAG_APPEND) {
SvCUR_set(output, 0);
/* sv_setpvn(output, "", 0); */
}
prefix = cur_length = SvCUR(output) ;
s->stream.next_out = (Bytef*) SvPVbyte_nolen(output) + cur_length;
increment = SvLEN(output) - cur_length;
s->stream.avail_out = increment;
#ifdef SETP_BYTE
/* Check for saved output from deflateParams */
if (s->deflateParams_out_valid) {
*(s->stream.next_out) = s->deflateParams_out_byte;
++ s->stream.next_out;
-- s->stream.avail_out ;
s->deflateParams_out_valid = FALSE;
}
#else
/* Check for saved output from deflateParams */
if (s->deflateParams_out_length) {
uLong plen = s->deflateParams_out_length ;
/* printf("Copy %d bytes saved data\n", plen);*/
if (s->stream.avail_out < plen) {
/*printf("GROW from %d to %d\n", s->stream.avail_out,
SvLEN(output) + plen - s->stream.avail_out); */
Sv_Grow(output, SvLEN(output) + plen - s->stream.avail_out) ;
}
Copy(s->stream.next_out, s->deflateParams_out_buffer, plen, Bytef) ;
cur_length = cur_length + plen;
SvCUR_set(output, cur_length);
s->stream.next_out += plen ;
s->stream.avail_out = SvLEN(output) - cur_length ;
increment = s->stream.avail_out;
s->deflateParams_out_length = 0;
}
#endif
while (s->stream.avail_in != 0) {
if (s->stream.avail_out == 0) {
/* out of space in the output buffer so make it bigger */
Sv_Grow(output, SvLEN(output) + bufinc) ;
cur_length += increment ;
s->stream.next_out = (Bytef*) SvPVbyte_nolen(output) + cur_length ;
increment = bufinc ;
s->stream.avail_out = increment;
bufinc *= 2 ;
}
RETVAL = deflate(&(s->stream), Z_NO_FLUSH);
if (RETVAL != Z_OK)
break;
}
s->compressedBytes += cur_length + increment - prefix - s->stream.avail_out ;
s->uncompressedBytes += SvCUR(buf) - s->stream.avail_in ;
s->last_error = RETVAL ;
if (RETVAL == Z_OK) {
SvPOK_only(output);
SvCUR_set(output, cur_length + increment - s->stream.avail_out) ;
SvSETMAGIC(output);
}
#line 1221 "Zlib.c"
ST(0) = sv_newmortal();
setDUALstatus(ST(0), RETVAL) ;
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__deflateStream_DESTROY); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__deflateStream_DESTROY)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::deflateStream::DESTROY(s)");
{
Compress__Raw__Zlib__deflateStream s;
if (SvROK(ST(0))) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__deflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not a reference");
#line 988 "Zlib.xs"
deflateEnd(&s->stream) ;
if (s->dictionary)
SvREFCNT_dec(s->dictionary) ;
#ifndef SETP_BYTE
if (s->deflateParams_out_buffer)
Safefree(s->deflateParams_out_buffer);
#endif
Safefree(s) ;
#line 1254 "Zlib.c"
}
XSRETURN_EMPTY;
}
XS(XS_Compress__Raw__Zlib__deflateStream_flush); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__deflateStream_flush)
{
dXSARGS;
if (items < 2 || items > 3)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::deflateStream::flush(s, output, f=Z_FINISH)");
{
Compress__Raw__Zlib__deflateStream s;
SV * output = ST(1);
int f;
uInt cur_length;
uInt increment;
uInt prefix;
uLong bufinc;
DualType RETVAL;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::deflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__deflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::deflateStream");
if (items < 3)
f = Z_FINISH;
else {
f = (int)SvIV(ST(2));
}
#line 1008 "Zlib.xs"
bufinc = s->bufsize;
s->stream.avail_in = 0; /* should be zero already anyway */
/* retrieve the output buffer */
output = deRef_l(output, "flush") ;
#ifdef UTF8_AVAILABLE
if (DO_UTF8(output) && !sv_utf8_downgrade(output, 1))
croak("Wide character in Compress::Raw::Zlib::Deflate::flush input parameter");
#endif
if(! s->flags & FLAG_APPEND) {
SvCUR_set(output, 0);
/* sv_setpvn(output, "", 0); */
}
prefix = cur_length = SvCUR(output) ;
s->stream.next_out = (Bytef*) SvPVbyte_nolen(output) + cur_length;
increment = SvLEN(output) - cur_length;
s->stream.avail_out = increment;
#ifdef SETP_BYTE
/* Check for saved output from deflateParams */
if (s->deflateParams_out_valid) {
*(s->stream.next_out) = s->deflateParams_out_byte;
++ s->stream.next_out;
-- s->stream.avail_out ;
s->deflateParams_out_valid = FALSE;
}
#else
/* Check for saved output from deflateParams */
if (s->deflateParams_out_length) {
uLong plen = s->deflateParams_out_length ;
/* printf("Copy %d bytes saved data\n", plen); */
if (s->stream.avail_out < plen) {
/* printf("GROW from %d to %d\n", s->stream.avail_out,
SvLEN(output) + plen - s->stream.avail_out); */
Sv_Grow(output, SvLEN(output) + plen - s->stream.avail_out) ;
}
Copy(s->stream.next_out, s->deflateParams_out_buffer, plen, Bytef) ;
cur_length = cur_length + plen;
SvCUR_set(output, cur_length);
s->stream.next_out += plen ;
s->stream.avail_out = SvLEN(output) - cur_length ;
increment = s->stream.avail_out;
s->deflateParams_out_length = 0;
}
#endif
for (;;) {
if (s->stream.avail_out == 0) {
/* consumed all the available output, so extend it */
Sv_Grow(output, SvLEN(output) + bufinc) ;
cur_length += increment ;
s->stream.next_out = (Bytef*) SvPVbyte_nolen(output) + cur_length ;
increment = bufinc ;
s->stream.avail_out = increment;
bufinc *= 2 ;
}
RETVAL = deflate(&(s->stream), f);
/* deflate has finished flushing only when it hasn't used up
* all the available space in the output buffer:
*/
if (s->stream.avail_out != 0 || RETVAL != Z_OK )
break;
}
RETVAL = (RETVAL == Z_STREAM_END ? Z_OK : RETVAL) ;
s->last_error = RETVAL ;
s->compressedBytes += cur_length + increment - prefix - s->stream.avail_out ;
if (RETVAL == Z_OK) {
SvPOK_only(output);
SvCUR_set(output, cur_length + increment - s->stream.avail_out) ;
SvSETMAGIC(output);
}
#line 1365 "Zlib.c"
ST(0) = sv_newmortal();
setDUALstatus(ST(0), RETVAL) ;
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__deflateStream__deflateParams); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__deflateStream__deflateParams)
{
dXSARGS;
if (items != 5)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::deflateStream::_deflateParams(s, flags, level, strategy, bufsize)");
{
Compress__Raw__Zlib__deflateStream s;
int flags = (int)SvIV(ST(1));
int level = (int)SvIV(ST(2));
int strategy = (int)SvIV(ST(3));
uLong bufsize = (unsigned long)SvUV(ST(4));
DualType RETVAL;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::deflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__deflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::deflateStream");
#line 1096 "Zlib.xs"
/* printf("_deflateParams(Flags %d Level %d Strategy %d Bufsize %d)\n", flags, level, strategy, bufsize);
printf("Before -- Level %d, Strategy %d, Bufsize %d\n", s->Level, s->Strategy, s->bufsize); */
if (flags & 1)
s->Level = level ;
if (flags & 2)
s->Strategy = strategy ;
if (flags & 4) {
s->bufsize = bufsize;
}
/* printf("After -- Level %d, Strategy %d, Bufsize %d\n", s->Level, s->Strategy, s->bufsize);*/
#ifdef SETP_BYTE
s->stream.avail_in = 0;
s->stream.next_out = &(s->deflateParams_out_byte) ;
s->stream.avail_out = 1;
RETVAL = deflateParams(&(s->stream), s->Level, s->Strategy);
s->deflateParams_out_valid =
(RETVAL == Z_OK && s->stream.avail_out == 0) ;
/* printf("RETVAL %d, avail out %d, byte %c\n", RETVAL, s->stream.avail_out, s->deflateParams_out_byte); */
#else
/* printf("Level %d Strategy %d, Prev Len %d\n",
s->Level, s->Strategy, s->deflateParams_out_length); */
s->stream.avail_in = 0;
if (s->deflateParams_out_buffer == NULL)
s->deflateParams_out_buffer = safemalloc(deflateParams_BUFFER_SIZE);
s->stream.next_out = s->deflateParams_out_buffer ;
s->stream.avail_out = deflateParams_BUFFER_SIZE;
RETVAL = deflateParams(&(s->stream), s->Level, s->Strategy);
s->deflateParams_out_length = deflateParams_BUFFER_SIZE - s->stream.avail_out;
/* printf("RETVAL %d, length out %d, avail %d\n",
RETVAL, s->deflateParams_out_length, s->stream.avail_out ); */
#endif
#line 1427 "Zlib.c"
ST(0) = sv_newmortal();
setDUALstatus(ST(0), RETVAL) ;
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__deflateStream_get_Level); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__deflateStream_get_Level)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::deflateStream::get_Level(s)");
{
Compress__Raw__Zlib__deflateStream s;
int RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::deflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__deflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::deflateStream");
#line 1136 "Zlib.xs"
RETVAL = s->Level ;
#line 1455 "Zlib.c"
XSprePUSH; PUSHi((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__deflateStream_get_Strategy); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__deflateStream_get_Strategy)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::deflateStream::get_Strategy(s)");
{
Compress__Raw__Zlib__deflateStream s;
int RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::deflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__deflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::deflateStream");
#line 1144 "Zlib.xs"
RETVAL = s->Strategy ;
#line 1481 "Zlib.c"
XSprePUSH; PUSHi((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__deflateStream_get_Bufsize); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__deflateStream_get_Bufsize)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::deflateStream::get_Bufsize(s)");
{
Compress__Raw__Zlib__deflateStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::deflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__deflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::deflateStream");
#line 1153 "Zlib.xs"
RETVAL = s->bufsize ;
#line 1507 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__deflateStream_status); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__deflateStream_status)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::deflateStream::status(s)");
{
Compress__Raw__Zlib__deflateStream s;
int RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::deflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__deflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::deflateStream");
#line 1162 "Zlib.xs"
RETVAL = s->last_error ;
#line 1533 "Zlib.c"
XSprePUSH; PUSHi((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__deflateStream_crc32); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__deflateStream_crc32)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::deflateStream::crc32(s)");
{
Compress__Raw__Zlib__deflateStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::deflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__deflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::deflateStream");
#line 1170 "Zlib.xs"
RETVAL = s->crc32 ;
#line 1559 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__deflateStream_dict_adler); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__deflateStream_dict_adler)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::deflateStream::dict_adler(s)");
{
Compress__Raw__Zlib__deflateStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::deflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__deflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::deflateStream");
#line 1178 "Zlib.xs"
RETVAL = s->dict_adler ;
#line 1585 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__deflateStream_adler32); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__deflateStream_adler32)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::deflateStream::adler32(s)");
{
Compress__Raw__Zlib__deflateStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::deflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__deflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::deflateStream");
#line 1186 "Zlib.xs"
RETVAL = s->adler32 ;
#line 1611 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__deflateStream_compressedBytes); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__deflateStream_compressedBytes)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::deflateStream::compressedBytes(s)");
{
Compress__Raw__Zlib__deflateStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::deflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__deflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::deflateStream");
#line 1194 "Zlib.xs"
RETVAL = s->compressedBytes;
#line 1637 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__deflateStream_uncompressedBytes); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__deflateStream_uncompressedBytes)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::deflateStream::uncompressedBytes(s)");
{
Compress__Raw__Zlib__deflateStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::deflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__deflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::deflateStream");
#line 1202 "Zlib.xs"
RETVAL = s->uncompressedBytes;
#line 1663 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__deflateStream_total_in); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__deflateStream_total_in)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::deflateStream::total_in(s)");
{
Compress__Raw__Zlib__deflateStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::deflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__deflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::deflateStream");
#line 1210 "Zlib.xs"
RETVAL = s->stream.total_in ;
#line 1689 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__deflateStream_total_out); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__deflateStream_total_out)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::deflateStream::total_out(s)");
{
Compress__Raw__Zlib__deflateStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::deflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__deflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::deflateStream");
#line 1218 "Zlib.xs"
RETVAL = s->stream.total_out ;
#line 1715 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__deflateStream_msg); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__deflateStream_msg)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::deflateStream::msg(s)");
{
Compress__Raw__Zlib__deflateStream s;
char * RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::deflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__deflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::deflateStream");
#line 1226 "Zlib.xs"
RETVAL = s->stream.msg;
#line 1741 "Zlib.c"
sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__deflateStream_deflateTune); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__deflateStream_deflateTune)
{
dXSARGS;
if (items != 5)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::deflateStream::deflateTune(s, good_length, max_lazy, nice_length, max_chain)");
{
Compress__Raw__Zlib__deflateStream s;
int good_length = (int)SvIV(ST(1));
int max_lazy = (int)SvIV(ST(2));
int nice_length = (int)SvIV(ST(3));
int max_chain = (int)SvIV(ST(4));
int RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::deflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__deflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::deflateStream");
#line 1238 "Zlib.xs"
#ifndef AT_LEAST_ZLIB_1_2_2_3
good_length = good_length; max_lazy = max_lazy ; /* Silence -Wall */
nice_length = nice_length; max_chain = max_chain; /* Silence -Wall */
croak("deflateTune needs zlib 1.2.2.3 or better");
#else
RETVAL = deflateTune(&(s->stream), good_length, max_lazy, nice_length, max_chain);
#endif
#line 1777 "Zlib.c"
XSprePUSH; PUSHi((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateStream_DispStream); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateStream_DispStream)
{
dXSARGS;
if (items < 1 || items > 2)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateStream::DispStream(s, message=NULL)");
{
Compress__Raw__Zlib__inflateStream s;
char * message;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateStream");
if (items < 2)
message = NULL;
else {
if (SvOK(ST(1)))
message = (char *)SvPVbyte_nolen(ST(1));
else
message = NULL ;
}
DispStream(s, message);
}
XSRETURN_EMPTY;
}
XS(XS_Compress__Raw__Zlib__inflateStream_inflateReset); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateStream_inflateReset)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateStream::inflateReset(s)");
{
Compress__Raw__Zlib__inflateStream s;
DualType RETVAL;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateStream");
#line 1260 "Zlib.xs"
RETVAL = inflateReset(&(s->stream)) ;
if (RETVAL == Z_OK) {
PostInitStream(s, s->flags, s->bufsize, s->WindowBits) ;
}
#line 1837 "Zlib.c"
ST(0) = sv_newmortal();
setDUALstatus(ST(0), RETVAL) ;
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateStream_inflate); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateStream_inflate)
{
dXSARGS;
if (items < 3 || items > 4)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateStream::inflate(s, buf, output, eof=FALSE)");
{
Compress__Raw__Zlib__inflateStream s;
SV * buf = ST(1);
SV * output = ST(2);
bool eof;
uInt cur_length = 0;
uInt prefix_length = 0;
uInt increment = 0;
STRLEN stmp;
uLong bufinc;
#line 1279 "Zlib.xs"
#ifdef UTF8_AVAILABLE
bool out_utf8 = FALSE;
#endif
#line 1866 "Zlib.c"
DualType RETVAL;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateStream");
if (items < 4)
eof = FALSE;
else {
eof = (bool)SvTRUE(ST(3));
}
#line 1283 "Zlib.xs"
bufinc = s->bufsize;
/* If the buffer is a reference, dereference it */
buf = deRef(buf, "inflate") ;
if (s->flags & FLAG_CONSUME_INPUT && SvREADONLY(buf))
croak("Compress::Raw::Zlib::Inflate::inflate input parameter cannot be read-only when ConsumeInput is specified");
#ifdef UTF8_AVAILABLE
if (DO_UTF8(buf) && !sv_utf8_downgrade(buf, 1))
croak("Wide character in Compress::Raw::Zlib::Inflate::inflate input parameter");
#endif
/* initialise the input buffer */
s->stream.next_in = (Bytef*)SvPVbyte_force(buf, stmp) ;
s->stream.avail_in = SvCUR(buf) ;
/* and retrieve the output buffer */
output = deRef_l(output, "inflate") ;
#ifdef UTF8_AVAILABLE
if (DO_UTF8(output))
out_utf8 = TRUE ;
if (DO_UTF8(output) && !sv_utf8_downgrade(output, 1))
croak("Wide character in Compress::Raw::Zlib::Inflate::inflate output parameter");
#endif
if((s->flags & FLAG_APPEND) != FLAG_APPEND) {
SvCUR_set(output, 0);
}
if (SvLEN(output)) {
prefix_length = cur_length = SvCUR(output) ;
s->stream.next_out = (Bytef*) SvPVbyte_nolen(output) + cur_length;
increment = SvLEN(output) - cur_length - 1;
s->stream.avail_out = increment;
}
else {
s->stream.avail_out = 0;
}
s->bytesInflated = 0;
RETVAL = Z_OK;
while (RETVAL == Z_OK) {
if (s->stream.avail_out == 0 ) {
/* out of space in the output buffer so make it bigger */
Sv_Grow(output, SvLEN(output) + bufinc) ;
cur_length += increment ;
s->stream.next_out = (Bytef*) SvPVbyte_nolen(output) + cur_length ;
increment = bufinc ;
s->stream.avail_out = increment;
bufinc *= 2 ;
}
RETVAL = inflate(&(s->stream), Z_SYNC_FLUSH);
if (RETVAL == Z_NEED_DICT && s->dictionary) {
s->dict_adler = s->stream.adler ;
RETVAL = inflateSetDictionary(&(s->stream),
(const Bytef*)SvPVbyte_nolen(s->dictionary),
SvCUR(s->dictionary));
}
if (s->flags & FLAG_LIMIT_OUTPUT ||
RETVAL == Z_STREAM_ERROR || RETVAL == Z_MEM_ERROR ||
RETVAL == Z_DATA_ERROR || RETVAL == Z_STREAM_END )
break ;
if (RETVAL == Z_BUF_ERROR) {
if (s->stream.avail_out == 0)
continue ;
if (s->stream.avail_in == 0) {
RETVAL = Z_OK ;
break ;
}
}
}
#ifdef NEED_DUMMY_BYTE_AT_END
if (eof && RETVAL == Z_OK && s->flags & FLAG_LIMIT_OUTPUT == 0) {
Bytef* nextIn = s->stream.next_in;
uInt availIn = s->stream.avail_in;
s->stream.next_in = (Bytef*) " ";
s->stream.avail_in = 1;
if (s->stream.avail_out == 0) {
/* out of space in the output buffer so make it bigger */
Sv_Grow(output, SvLEN(output) + bufinc) ;
cur_length += increment ;
s->stream.next_out = (Bytef*) SvPVbyte_nolen(output) + cur_length ;
increment = bufinc ;
s->stream.avail_out = increment;
bufinc *= 2 ;
}
RETVAL = inflate(&(s->stream), Z_SYNC_FLUSH);
s->stream.next_in = nextIn ;
s->stream.avail_in = availIn ;
}
#endif
s->last_error = RETVAL ;
if (RETVAL == Z_OK || RETVAL == Z_STREAM_END || RETVAL == Z_DATA_ERROR) {
unsigned in ;
s->bytesInflated = cur_length + increment - s->stream.avail_out - prefix_length;
s->uncompressedBytes += s->bytesInflated ;
s->compressedBytes += SvCUR(buf) - s->stream.avail_in ;
SvPOK_only(output);
SvCUR_set(output, prefix_length + s->bytesInflated) ;
*SvEND(output) = '\0';
#ifdef UTF8_AVAILABLE
if (out_utf8)
sv_utf8_upgrade(output);
#endif
SvSETMAGIC(output);
if (s->flags & FLAG_CRC32 )
s->crc32 = crc32(s->crc32,
(const Bytef*)SvPVbyte_nolen(output)+prefix_length,
SvCUR(output)-prefix_length) ;
if (s->flags & FLAG_ADLER32)
s->adler32 = adler32(s->adler32,
(const Bytef*)SvPVbyte_nolen(output)+prefix_length,
SvCUR(output)-prefix_length) ;
/* fix the input buffer */
if (s->flags & FLAG_CONSUME_INPUT || s->flags & FLAG_LIMIT_OUTPUT) {
in = s->stream.avail_in ;
SvCUR_set(buf, in) ;
if (in)
Move(s->stream.next_in, SvPVbyte_nolen(buf), in, char) ;
*SvEND(buf) = '\0';
SvSETMAGIC(buf);
}
}
#line 2014 "Zlib.c"
ST(0) = sv_newmortal();
setDUALstatus(ST(0), RETVAL) ;
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateStream_inflateCount); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateStream_inflateCount)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateStream::inflateCount(s)");
{
Compress__Raw__Zlib__inflateStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateStream");
#line 1422 "Zlib.xs"
RETVAL = s->bytesInflated;
#line 2042 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateStream_compressedBytes); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateStream_compressedBytes)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateStream::compressedBytes(s)");
{
Compress__Raw__Zlib__inflateStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateStream");
#line 1430 "Zlib.xs"
RETVAL = s->compressedBytes;
#line 2068 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateStream_uncompressedBytes); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateStream_uncompressedBytes)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateStream::uncompressedBytes(s)");
{
Compress__Raw__Zlib__inflateStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateStream");
#line 1438 "Zlib.xs"
RETVAL = s->uncompressedBytes;
#line 2094 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateStream_inflateSync); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateStream_inflateSync)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateStream::inflateSync(s, buf)");
{
Compress__Raw__Zlib__inflateStream s;
SV * buf = ST(1);
DualType RETVAL;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateStream");
#line 1449 "Zlib.xs"
/* If the buffer is a reference, dereference it */
buf = deRef(buf, "inflateSync") ;
#ifdef UTF8_AVAILABLE
if (DO_UTF8(buf) && !sv_utf8_downgrade(buf, 1))
croak("Wide character in Compress::Raw::Zlib::Inflate::inflateSync");
#endif
/* initialise the input buffer */
s->stream.next_in = (Bytef*)SvPVbyte_nolen(buf) ;
s->stream.avail_in = SvCUR(buf) ;
/* inflateSync doesn't create any output */
s->stream.next_out = (Bytef*) NULL;
s->stream.avail_out = 0;
RETVAL = inflateSync(&(s->stream));
s->last_error = RETVAL ;
/* fix the input buffer */
{
unsigned in = s->stream.avail_in ;
SvCUR_set(buf, in) ;
if (in)
Move(s->stream.next_in, SvPVbyte_nolen(buf), in, char) ;
*SvEND(buf) = '\0';
SvSETMAGIC(buf);
}
#line 2146 "Zlib.c"
ST(0) = sv_newmortal();
setDUALstatus(ST(0), RETVAL) ;
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateStream_DESTROY); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateStream_DESTROY)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateStream::DESTROY(s)");
{
Compress__Raw__Zlib__inflateStream s;
if (SvROK(ST(0))) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not a reference");
#line 1483 "Zlib.xs"
inflateEnd(&s->stream) ;
if (s->dictionary)
SvREFCNT_dec(s->dictionary) ;
#ifndef SETP_BYTE
if (s->deflateParams_out_buffer)
Safefree(s->deflateParams_out_buffer);
#endif
#ifdef MAGIC_APPEND
if (s->window)
Safefree(s->window);
#endif
Safefree(s) ;
#line 2183 "Zlib.c"
}
XSRETURN_EMPTY;
}
XS(XS_Compress__Raw__Zlib__inflateStream_status); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateStream_status)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateStream::status(s)");
{
Compress__Raw__Zlib__inflateStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateStream");
#line 1501 "Zlib.xs"
RETVAL = s->last_error ;
#line 2208 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateStream_crc32); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateStream_crc32)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateStream::crc32(s)");
{
Compress__Raw__Zlib__inflateStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateStream");
#line 1509 "Zlib.xs"
RETVAL = s->crc32 ;
#line 2234 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateStream_dict_adler); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateStream_dict_adler)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateStream::dict_adler(s)");
{
Compress__Raw__Zlib__inflateStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateStream");
#line 1517 "Zlib.xs"
RETVAL = s->dict_adler ;
#line 2260 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateStream_total_in); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateStream_total_in)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateStream::total_in(s)");
{
Compress__Raw__Zlib__inflateStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateStream");
#line 1525 "Zlib.xs"
RETVAL = s->stream.total_in ;
#line 2286 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateStream_adler32); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateStream_adler32)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateStream::adler32(s)");
{
Compress__Raw__Zlib__inflateStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateStream");
#line 1533 "Zlib.xs"
RETVAL = s->adler32 ;
#line 2312 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateStream_total_out); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateStream_total_out)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateStream::total_out(s)");
{
Compress__Raw__Zlib__inflateStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateStream");
#line 1541 "Zlib.xs"
RETVAL = s->stream.total_out ;
#line 2338 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateStream_msg); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateStream_msg)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateStream::msg(s)");
{
Compress__Raw__Zlib__inflateStream s;
char * RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateStream");
#line 1549 "Zlib.xs"
RETVAL = s->stream.msg;
#line 2364 "Zlib.c"
sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateStream_get_Bufsize); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateStream_get_Bufsize)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateStream::get_Bufsize(s)");
{
Compress__Raw__Zlib__inflateStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateStream");
#line 1558 "Zlib.xs"
RETVAL = s->bufsize ;
#line 2390 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateStream_set_Append); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateStream_set_Append)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateStream::set_Append(s, mode)");
{
Compress__Raw__Zlib__inflateStream s;
bool mode = (bool)SvTRUE(ST(1));
bool RETVAL;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateStream");
#line 1567 "Zlib.xs"
RETVAL = ((s->flags & FLAG_APPEND) == FLAG_APPEND);
if (mode)
s->flags |= FLAG_APPEND ;
else
s->flags &= ~FLAG_APPEND ;
#line 2420 "Zlib.c"
ST(0) = boolSV(RETVAL);
sv_2mortal(ST(0));
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateScanStream_DESTROY); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateScanStream_DESTROY)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateScanStream::DESTROY(s)");
{
Compress__Raw__Zlib__inflateScanStream s;
if (SvROK(ST(0))) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateScanStream,tmp);
}
else
Perl_croak(aTHX_ "s is not a reference");
#line 1581 "Zlib.xs"
inflateEnd(&s->stream) ;
if (s->dictionary)
SvREFCNT_dec(s->dictionary) ;
#ifndef SETP_BYTE
if (s->deflateParams_out_buffer)
Safefree(s->deflateParams_out_buffer);
#endif
#ifdef MAGIC_APPEND
if (s->window)
Safefree(s->window);
#endif
Safefree(s) ;
#line 2456 "Zlib.c"
}
XSRETURN_EMPTY;
}
XS(XS_Compress__Raw__Zlib__inflateScanStream_DispStream); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateScanStream_DispStream)
{
dXSARGS;
if (items < 1 || items > 2)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateScanStream::DispStream(s, message=NULL)");
{
Compress__Raw__Zlib__inflateScanStream s;
char * message;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateScanStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateScanStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateScanStream");
if (items < 2)
message = NULL;
else {
if (SvOK(ST(1)))
message = (char *)SvPVbyte_nolen(ST(1));
else
message = NULL ;
}
DispStream(s, message);
}
XSRETURN_EMPTY;
}
XS(XS_Compress__Raw__Zlib__inflateScanStream_inflateReset); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateScanStream_inflateReset)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateScanStream::inflateReset(s)");
{
Compress__Raw__Zlib__inflateScanStream s;
DualType RETVAL;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateScanStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateScanStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateScanStream");
#line 1603 "Zlib.xs"
RETVAL = inflateReset(&(s->stream)) ;
if (RETVAL == Z_OK) {
PostInitStream(s, s->flags, s->bufsize, s->WindowBits) ;
}
#line 2515 "Zlib.c"
ST(0) = sv_newmortal();
setDUALstatus(ST(0), RETVAL) ;
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateScanStream_scan); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateScanStream_scan)
{
dXSARGS;
if (items < 2 || items > 4)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateScanStream::scan(s, buf, out=NULL, eof=FALSE)");
{
Compress__Raw__Zlib__inflateScanStream s;
SV * buf = ST(1);
SV * out;
bool eof;
bool eof_mode = FALSE;
int start_len;
STRLEN stmp;
DualType RETVAL;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateScanStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateScanStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateScanStream");
if (items < 3)
out = NULL;
else {
out = ST(2);
}
if (items < 4)
eof = FALSE;
else {
eof = (bool)SvTRUE(ST(3));
}
#line 1620 "Zlib.xs"
/* If the input buffer is a reference, dereference it */
#ifndef MAGIC_APPEND
buf = buf;
croak("scan needs zlib 1.2.1 or better");
#else
buf = deRef(buf, "inflateScan") ;
#ifdef UTF8_AVAILABLE
if (DO_UTF8(buf) && !sv_utf8_downgrade(buf, 1))
croak("Wide character in Compress::Raw::Zlib::InflateScan::scan input parameter");
#endif
/* initialise the input buffer */
s->stream.next_in = (Bytef*)SvPVbyte_force(buf, stmp) ;
s->stream.avail_in = SvCUR(buf) ;
start_len = s->stream.avail_in ;
s->bytesInflated = 0 ;
do
{
if (s->stream.avail_in == 0) {
RETVAL = Z_OK ;
break ;
}
/* set up output to next available section of sliding window */
s->stream.avail_out = WINDOW_SIZE - s->window_have;
s->stream.next_out = s->window + s->window_have;
/* DispStream(s, "before inflate\n"); */
/* inflate and check for errors */
RETVAL = inflate(&(s->stream), Z_BLOCK);
if (start_len > 1 && ! eof_mode)
s->window_lastByte = *(s->stream.next_in - 1 ) ;
if (RETVAL == Z_STREAM_ERROR || RETVAL == Z_MEM_ERROR ||
RETVAL == Z_DATA_ERROR )
break ;
if (s->flags & FLAG_CRC32 )
s->crc32 = crc32(s->crc32, s->window + s->window_have,
WINDOW_SIZE - s->window_have - s->stream.avail_out);
if (s->flags & FLAG_ADLER32)
s->adler32 = adler32(s->adler32, s->window + s->window_have,
WINDOW_SIZE - s->window_have - s->stream.avail_out);
s->uncompressedBytes =
s->bytesInflated += WINDOW_SIZE - s->window_have - s->stream.avail_out;
if (s->stream.avail_out)
s->window_have = WINDOW_SIZE - s->stream.avail_out;
else {
s->window_have = 0;
s->window_full = 1;
}
/* process end of block */
if (s->stream.data_type & 128) {
if (s->stream.data_type & 64) {
s->window_left = s->stream.data_type & 0x1f;
}
else {
s->window_lastbit = s->stream.data_type & 0x1f;
s->lastBlockOffset = s->stream.total_in;
}
}
} while (RETVAL != Z_STREAM_END);
s->last_error = RETVAL ;
s->window_lastoff = s->stream.total_in ;
s->compressedBytes += SvCUR(buf) - s->stream.avail_in ;
if (RETVAL == Z_STREAM_END)
{
s->matchedEndBlock = 1 ;
/* save the location of the end of the compressed data */
s->window_end = SvCUR(buf) - s->stream.avail_in - 1 ;
s->window_endOffset = s->stream.total_in ;
if (s->window_left)
{
-- s->window_endOffset ;
}
/* if window wrapped, build dictionary from window by rotating */
if (s->window_full) {
rotate(s->window, WINDOW_SIZE, s->window_have);
s->window_have = WINDOW_SIZE;
}
/* if (s->flags & FLAG_CONSUME_INPUT) { */
if (1) {
unsigned in = s->stream.avail_in ;
SvCUR_set(buf, in) ;
if (in)
Move(s->stream.next_in, SvPVbyte_nolen(buf), in, char) ;
*SvEND(buf) = '\0';
SvSETMAGIC(buf);
}
}
#endif
#line 2661 "Zlib.c"
ST(0) = sv_newmortal();
setDUALstatus(ST(0), RETVAL) ;
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateScanStream_getEndOffset); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateScanStream_getEndOffset)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateScanStream::getEndOffset(s)");
{
Compress__Raw__Zlib__inflateScanStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateScanStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateScanStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateScanStream");
#line 1730 "Zlib.xs"
#ifndef MAGIC_APPEND
croak("getEndOffset needs zlib 1.2.1 or better");
#else
RETVAL = s->window_endOffset;
#endif
#line 2693 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateScanStream_inflateCount); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateScanStream_inflateCount)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateScanStream::inflateCount(s)");
{
Compress__Raw__Zlib__inflateScanStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateScanStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateScanStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateScanStream");
#line 1742 "Zlib.xs"
#ifndef MAGIC_APPEND
croak("inflateCount needs zlib 1.2.1 or better");
#else
RETVAL = s->bytesInflated;
#endif
#line 2723 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateScanStream_compressedBytes); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateScanStream_compressedBytes)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateScanStream::compressedBytes(s)");
{
Compress__Raw__Zlib__inflateScanStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateScanStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateScanStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateScanStream");
#line 1754 "Zlib.xs"
RETVAL = s->compressedBytes;
#line 2749 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateScanStream_uncompressedBytes); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateScanStream_uncompressedBytes)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateScanStream::uncompressedBytes(s)");
{
Compress__Raw__Zlib__inflateScanStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateScanStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateScanStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateScanStream");
#line 1762 "Zlib.xs"
RETVAL = s->uncompressedBytes;
#line 2775 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateScanStream_getLastBlockOffset); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateScanStream_getLastBlockOffset)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateScanStream::getLastBlockOffset(s)");
{
Compress__Raw__Zlib__inflateScanStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateScanStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateScanStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateScanStream");
#line 1771 "Zlib.xs"
#ifndef MAGIC_APPEND
croak("getLastBlockOffset needs zlib 1.2.1 or better");
#else
RETVAL = s->lastBlockOffset - (s->window_lastbit != 0);
#endif
#line 2805 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateScanStream_getLastBufferOffset); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateScanStream_getLastBufferOffset)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateScanStream::getLastBufferOffset(s)");
{
Compress__Raw__Zlib__inflateScanStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateScanStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateScanStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateScanStream");
#line 1783 "Zlib.xs"
#ifndef MAGIC_APPEND
croak("getLastBufferOffset needs zlib 1.2.1 or better");
#else
RETVAL = s->window_lastoff;
#endif
#line 2835 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateScanStream_resetLastBlockByte); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateScanStream_resetLastBlockByte)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateScanStream::resetLastBlockByte(s, byte)");
{
Compress__Raw__Zlib__inflateScanStream s;
unsigned char* byte;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateScanStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateScanStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateScanStream");
if (SvOK(ST(1)))
byte = (unsigned char *)SvPVbyte_nolen(ST(1));
else
byte = NULL ;
#line 1796 "Zlib.xs"
#ifndef MAGIC_APPEND
croak("resetLastBlockByte needs zlib 1.2.1 or better");
#else
if (byte != NULL)
*byte = *byte ^ (1 << ((8 - s->window_lastbit) & 7));
#endif
#line 2870 "Zlib.c"
}
XSRETURN_EMPTY;
}
XS(XS_Compress__Raw__Zlib__inflateScanStream__createDeflateStream); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateScanStream__createDeflateStream)
{
dXSARGS;
if (items != 8)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateScanStream::_createDeflateStream(inf_s, flags, level, method, windowBits, memLevel, strategy, bufsize)");
SP -= items;
{
Compress__Raw__Zlib__inflateScanStream inf_s;
int flags = (int)SvIV(ST(1));
int level = (int)SvIV(ST(2));
int method = (int)SvIV(ST(3));
int windowBits = (int)SvIV(ST(4));
int memLevel = (int)SvIV(ST(5));
int strategy = (int)SvIV(ST(6));
uLong bufsize = (unsigned long)SvUV(ST(7));
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateScanStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
inf_s = INT2PTR(Compress__Raw__Zlib__inflateScanStream,tmp);
}
else
Perl_croak(aTHX_ "inf_s is not of type Compress::Raw::Zlib::inflateScanStream");
#line 1815 "Zlib.xs"
{
#ifndef MAGIC_APPEND
flags = flags;
level = level ;
method = method;
windowBits = windowBits;
memLevel = memLevel;
strategy = strategy;
bufsize= bufsize;
croak("_createDeflateStream needs zlib 1.2.1 or better");
#else
int err ;
deflateStream s ;
if (trace)
warn("in _createDeflateStream(level=%d, method=%d, windowBits=%d, memLevel=%d, strategy=%d, bufsize=%lu\n",
level, method, windowBits, memLevel, strategy, bufsize) ;
if ((s = InitStream() )) {
s->Level = level;
s->Method = method;
s->WindowBits = windowBits;
s->MemLevel = memLevel;
s->Strategy = strategy;
err = deflateInit2(&(s->stream), level,
method, windowBits, memLevel, strategy);
if (err == Z_OK) {
err = deflateSetDictionary(&(s->stream), inf_s->window, inf_s->window_have);
s->dict_adler = s->stream.adler ;
}
if (err != Z_OK) {
Safefree(s) ;
s = NULL ;
}
else {
PostInitStream(s, flags, bufsize, windowBits) ;
s->crc32 = inf_s->crc32;
s->adler32 = inf_s->adler32;
s->stream.adler = inf_s->stream.adler ;
/* s->stream.total_out = inf_s->bytesInflated ; */
s->stream.total_in = inf_s->stream.total_out ;
if (inf_s->window_left) {
/* printf("** window_left %d, window_lastByte %d\n", inf_s->window_left, inf_s->window_lastByte); */
deflatePrime(&(s->stream), 8 - inf_s->window_left, inf_s->window_lastByte);
}
}
}
else
err = Z_MEM_ERROR ;
XPUSHs(sv_setref_pv(sv_newmortal(),
"Compress::Raw::Zlib::deflateStream", (void*)s));
if (GIMME == G_ARRAY) {
SV * sv = sv_2mortal(newSViv(err)) ;
setDUALstatus(sv, err);
XPUSHs(sv) ;
}
#endif
}
#line 2962 "Zlib.c"
PUTBACK;
return;
}
}
XS(XS_Compress__Raw__Zlib__inflateScanStream_status); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateScanStream_status)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateScanStream::status(s)");
{
Compress__Raw__Zlib__inflateScanStream s;
DualType RETVAL;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateScanStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateScanStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateScanStream");
#line 1882 "Zlib.xs"
RETVAL = s->last_error ;
#line 2987 "Zlib.c"
ST(0) = sv_newmortal();
setDUALstatus(ST(0), RETVAL) ;
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateScanStream_crc32); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateScanStream_crc32)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateScanStream::crc32(s)");
{
Compress__Raw__Zlib__inflateScanStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateScanStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateScanStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateScanStream");
#line 1890 "Zlib.xs"
RETVAL = s->crc32 ;
#line 3015 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Compress__Raw__Zlib__inflateScanStream_adler32); /* prototype to pass -Wmissing-prototypes */
XS(XS_Compress__Raw__Zlib__inflateScanStream_adler32)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Compress::Raw::Zlib::inflateScanStream::adler32(s)");
{
Compress__Raw__Zlib__inflateScanStream s;
uLong RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Compress::Raw::Zlib::inflateScanStream")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
s = INT2PTR(Compress__Raw__Zlib__inflateScanStream,tmp);
}
else
Perl_croak(aTHX_ "s is not of type Compress::Raw::Zlib::inflateScanStream");
#line 1899 "Zlib.xs"
RETVAL = s->adler32 ;
#line 3041 "Zlib.c"
XSprePUSH; PUSHu((IV)RETVAL);
}
XSRETURN(1);
}
#ifdef __cplusplus
extern "C"
#endif
XS(boot_Compress__Raw__Zlib); /* prototype to pass -Wmissing-prototypes */
XS(boot_Compress__Raw__Zlib)
{
dXSARGS;
char* file = __FILE__;
XS_VERSION_BOOTCHECK ;
{
CV * cv ;
newXS("Compress::Raw::Zlib::constant", XS_Compress__Raw__Zlib_constant, file);
newXS("Compress::Raw::Zlib::zlib_version", XS_Compress__Raw__Zlib_zlib_version, file);
newXS("Compress::Raw::Zlib::ZLIB_VERNUM", XS_Compress__Raw__Zlib_ZLIB_VERNUM, file);
newXS("Compress::Raw::Zlib::adler32", XS_Compress__Raw__Zlib_adler32, file);
newXS("Compress::Raw::Zlib::crc32", XS_Compress__Raw__Zlib_crc32, file);
newXS("Compress::Raw::Zlib::crc32_combine", XS_Compress__Raw__Zlib_crc32_combine, file);
newXS("Compress::Raw::Zlib::adler32_combine", XS_Compress__Raw__Zlib_adler32_combine, file);
newXS("Compress::Raw::Zlib::_deflateInit", XS_Compress__Raw__Zlib__deflateInit, file);
cv = newXS("Compress::Raw::Zlib::_inflateScanInit", XS_Compress__Raw__Zlib__inflateInit, file);
XSANY.any_i32 = 1 ;
cv = newXS("Compress::Raw::Zlib::_inflateInit", XS_Compress__Raw__Zlib__inflateInit, file);
XSANY.any_i32 = 0 ;
newXS("Compress::Raw::Zlib::deflateStream::DispStream", XS_Compress__Raw__Zlib__deflateStream_DispStream, file);
newXS("Compress::Raw::Zlib::deflateStream::deflateReset", XS_Compress__Raw__Zlib__deflateStream_deflateReset, file);
newXS("Compress::Raw::Zlib::deflateStream::deflate", XS_Compress__Raw__Zlib__deflateStream_deflate, file);
newXS("Compress::Raw::Zlib::deflateStream::DESTROY", XS_Compress__Raw__Zlib__deflateStream_DESTROY, file);
newXS("Compress::Raw::Zlib::deflateStream::flush", XS_Compress__Raw__Zlib__deflateStream_flush, file);
newXS("Compress::Raw::Zlib::deflateStream::_deflateParams", XS_Compress__Raw__Zlib__deflateStream__deflateParams, file);
newXS("Compress::Raw::Zlib::deflateStream::get_Level", XS_Compress__Raw__Zlib__deflateStream_get_Level, file);
newXS("Compress::Raw::Zlib::deflateStream::get_Strategy", XS_Compress__Raw__Zlib__deflateStream_get_Strategy, file);
newXS("Compress::Raw::Zlib::deflateStream::get_Bufsize", XS_Compress__Raw__Zlib__deflateStream_get_Bufsize, file);
newXS("Compress::Raw::Zlib::deflateStream::status", XS_Compress__Raw__Zlib__deflateStream_status, file);
newXS("Compress::Raw::Zlib::deflateStream::crc32", XS_Compress__Raw__Zlib__deflateStream_crc32, file);
newXS("Compress::Raw::Zlib::deflateStream::dict_adler", XS_Compress__Raw__Zlib__deflateStream_dict_adler, file);
newXS("Compress::Raw::Zlib::deflateStream::adler32", XS_Compress__Raw__Zlib__deflateStream_adler32, file);
newXS("Compress::Raw::Zlib::deflateStream::compressedBytes", XS_Compress__Raw__Zlib__deflateStream_compressedBytes, file);
newXS("Compress::Raw::Zlib::deflateStream::uncompressedBytes", XS_Compress__Raw__Zlib__deflateStream_uncompressedBytes, file);
newXS("Compress::Raw::Zlib::deflateStream::total_in", XS_Compress__Raw__Zlib__deflateStream_total_in, file);
newXS("Compress::Raw::Zlib::deflateStream::total_out", XS_Compress__Raw__Zlib__deflateStream_total_out, file);
newXS("Compress::Raw::Zlib::deflateStream::msg", XS_Compress__Raw__Zlib__deflateStream_msg, file);
newXS("Compress::Raw::Zlib::deflateStream::deflateTune", XS_Compress__Raw__Zlib__deflateStream_deflateTune, file);
newXS("Compress::Raw::Zlib::inflateStream::DispStream", XS_Compress__Raw__Zlib__inflateStream_DispStream, file);
newXS("Compress::Raw::Zlib::inflateStream::inflateReset", XS_Compress__Raw__Zlib__inflateStream_inflateReset, file);
newXS("Compress::Raw::Zlib::inflateStream::inflate", XS_Compress__Raw__Zlib__inflateStream_inflate, file);
newXS("Compress::Raw::Zlib::inflateStream::inflateCount", XS_Compress__Raw__Zlib__inflateStream_inflateCount, file);
newXS("Compress::Raw::Zlib::inflateStream::compressedBytes", XS_Compress__Raw__Zlib__inflateStream_compressedBytes, file);
newXS("Compress::Raw::Zlib::inflateStream::uncompressedBytes", XS_Compress__Raw__Zlib__inflateStream_uncompressedBytes, file);
newXS("Compress::Raw::Zlib::inflateStream::inflateSync", XS_Compress__Raw__Zlib__inflateStream_inflateSync, file);
newXS("Compress::Raw::Zlib::inflateStream::DESTROY", XS_Compress__Raw__Zlib__inflateStream_DESTROY, file);
newXS("Compress::Raw::Zlib::inflateStream::status", XS_Compress__Raw__Zlib__inflateStream_status, file);
newXS("Compress::Raw::Zlib::inflateStream::crc32", XS_Compress__Raw__Zlib__inflateStream_crc32, file);
newXS("Compress::Raw::Zlib::inflateStream::dict_adler", XS_Compress__Raw__Zlib__inflateStream_dict_adler, file);
newXS("Compress::Raw::Zlib::inflateStream::total_in", XS_Compress__Raw__Zlib__inflateStream_total_in, file);
newXS("Compress::Raw::Zlib::inflateStream::adler32", XS_Compress__Raw__Zlib__inflateStream_adler32, file);
newXS("Compress::Raw::Zlib::inflateStream::total_out", XS_Compress__Raw__Zlib__inflateStream_total_out, file);
newXS("Compress::Raw::Zlib::inflateStream::msg", XS_Compress__Raw__Zlib__inflateStream_msg, file);
newXS("Compress::Raw::Zlib::inflateStream::get_Bufsize", XS_Compress__Raw__Zlib__inflateStream_get_Bufsize, file);
newXS("Compress::Raw::Zlib::inflateStream::set_Append", XS_Compress__Raw__Zlib__inflateStream_set_Append, file);
newXS("Compress::Raw::Zlib::inflateScanStream::DESTROY", XS_Compress__Raw__Zlib__inflateScanStream_DESTROY, file);
newXS("Compress::Raw::Zlib::inflateScanStream::DispStream", XS_Compress__Raw__Zlib__inflateScanStream_DispStream, file);
newXS("Compress::Raw::Zlib::inflateScanStream::inflateReset", XS_Compress__Raw__Zlib__inflateScanStream_inflateReset, file);
newXS("Compress::Raw::Zlib::inflateScanStream::scan", XS_Compress__Raw__Zlib__inflateScanStream_scan, file);
newXS("Compress::Raw::Zlib::inflateScanStream::getEndOffset", XS_Compress__Raw__Zlib__inflateScanStream_getEndOffset, file);
newXS("Compress::Raw::Zlib::inflateScanStream::inflateCount", XS_Compress__Raw__Zlib__inflateScanStream_inflateCount, file);
newXS("Compress::Raw::Zlib::inflateScanStream::compressedBytes", XS_Compress__Raw__Zlib__inflateScanStream_compressedBytes, file);
newXS("Compress::Raw::Zlib::inflateScanStream::uncompressedBytes", XS_Compress__Raw__Zlib__inflateScanStream_uncompressedBytes, file);
newXS("Compress::Raw::Zlib::inflateScanStream::getLastBlockOffset", XS_Compress__Raw__Zlib__inflateScanStream_getLastBlockOffset, file);
newXS("Compress::Raw::Zlib::inflateScanStream::getLastBufferOffset", XS_Compress__Raw__Zlib__inflateScanStream_getLastBufferOffset, file);
newXS("Compress::Raw::Zlib::inflateScanStream::resetLastBlockByte", XS_Compress__Raw__Zlib__inflateScanStream_resetLastBlockByte, file);
newXS("Compress::Raw::Zlib::inflateScanStream::_createDeflateStream", XS_Compress__Raw__Zlib__inflateScanStream__createDeflateStream, file);
newXS("Compress::Raw::Zlib::inflateScanStream::status", XS_Compress__Raw__Zlib__inflateScanStream_status, file);
newXS("Compress::Raw::Zlib::inflateScanStream::crc32", XS_Compress__Raw__Zlib__inflateScanStream_crc32, file);
newXS("Compress::Raw::Zlib::inflateScanStream::adler32", XS_Compress__Raw__Zlib__inflateScanStream_adler32, file);
}
/* Initialisation Section */
#line 611 "Zlib.xs"
/* Check this version of zlib is == 1 */
if (zlibVersion()[0] != '1')
croak("Compress::Raw::Zlib needs zlib version 1.x\n") ;
{
/* Create the $os_code scalar */
SV * os_code_sv = perl_get_sv("Compress::Raw::Zlib::gzip_os_code", GV_ADDMULTI) ;
sv_setiv(os_code_sv, GZIP_OS_CODE) ;
}
#line 3139 "Zlib.c"
/* End of Initialisation Section */
XSRETURN_YES;
}