     1			/*
     2			 * This file was generated automatically by ExtUtils::ParseXS version 2.10 from the
     3			 * contents of Zlib.xs. Do not edit this file, edit Zlib.xs instead.
     4			 *
     5			 *	ANY CHANGES MADE HERE WILL BE LOST! 
     6			 *
     7			 */
     8			
     9			#line 1 "Zlib.xs"
    10			/* Filename: Zlib.xs
    11			 * Author  : Paul Marquess, <pmqs@cpan.org>
    12			 * Created : 30 January 2005
    13			 * Version : 1.34
    14			 *
    15			 *   Copyright (c) 1995-2005 Paul Marquess. All rights reserved.
    16			 *   This program is free software; you can redistribute it and/or
    17			 *   modify it under the same terms as Perl itself.
    18			 *
    19			 */
    20			
    21			/* Part of this code is based on the file gzio.c */
    22			
    23			/* gzio.c -- IO on .gz files
    24			 * Copyright (C) 1995 Jean-loup Gailly.
    25			 * For conditions of distribution and use, see copyright notice in zlib.h
    26			 */
    27			
    28			
    29			
    30			#include "EXTERN.h"
    31			#include "perl.h"
    32			#include "XSUB.h"
    33			
    34			#include <zlib.h> 
    35			
    36			#ifndef PERL_VERSION
    37			#include "patchlevel.h"
    38			#define PERL_REVISION	5
    39			#define PERL_VERSION	PATCHLEVEL
    40			#define PERL_SUBVERSION	SUBVERSION
    41			#endif
    42			
    43			#if PERL_REVISION == 5 && (PERL_VERSION < 4 || (PERL_VERSION == 4 && PERL_SUBVERSION <= 75 ))
    44			
    45			#    define PL_sv_undef		sv_undef
    46			#    define PL_na		na
    47			#    define PL_curcop		curcop
    48			#    define PL_compiling	compiling
    49			
    50			#endif
    51			
    52			#ifndef newSVuv
    53			#    define newSVuv	newSViv
    54			#endif
    55			
    56			typedef struct di_stream {
    57			    z_stream stream;
    58			    uLong    bufsize; 
    59			    uLong    bufinc; 
    60			    SV *     dictionary ;
    61			    uLong    dict_adler ;
    62			    bool     deflateParams_out_valid ;
    63			    Bytef    deflateParams_out_byte;
    64			    int      Level;
    65			    int      Method;
    66			    int      WindowBits;
    67			    int      MemLevel;
    68			    int      Strategy;
    69			} di_stream;
    70			
    71			typedef di_stream * deflateStream ;
    72			typedef di_stream * Compress__Zlib__deflateStream ;
    73			typedef di_stream * inflateStream ;
    74			typedef di_stream * Compress__Zlib__inflateStream ;
    75			
    76			/* typedef gzFile Compress__Zlib__gzFile ; */
    77			typedef struct gzType {
    78			    gzFile gz ;
    79			    SV *   buffer ;
    80			    uLong   offset ;
    81			    bool   closed ;
    82			}  gzType ;
    83			
    84			typedef gzType* Compress__Zlib__gzFile ; 
    85			
    86			
    87			
    88			#define GZERRNO	"Compress::Zlib::gzerrno"
    89			
    90			#define ZMALLOC(to, typ) ((to = (typ *)safemalloc(sizeof(typ))), \
    91			                                Zero(to,1,typ))
    92			
    93			#define adlerInitial adler32(0L, Z_NULL, 0)
    94			#define crcInitial crc32(0L, Z_NULL, 0)
    95			
    96			#if 1
    97			static char *my_z_errmsg[] = {
    98			    "need dictionary",     /* Z_NEED_DICT     2 */
    99			    "stream end",          /* Z_STREAM_END    1 */
   100			    "",                    /* Z_OK            0 */
   101			    "file error",          /* Z_ERRNO        (-1) */
   102			    "stream error",        /* Z_STREAM_ERROR (-2) */
   103			    "data error",          /* Z_DATA_ERROR   (-3) */
   104			    "insufficient memory", /* Z_MEM_ERROR    (-4) */
   105			    "buffer error",        /* Z_BUF_ERROR    (-5) */
   106			    "incompatible version",/* Z_VERSION_ERROR(-6) */
   107			    ""};
   108			#endif
   109			
   110			
   111			static int trace = 0 ;
   112			
   113			static void
   114			#ifdef CAN_PROTOTYPE
   115			SetGzErrorNo(int error_no)
   116			#else
   117			SetGzErrorNo(error_no)
   118			int error_no ;
   119			#endif
   120			{
   121			    char * errstr ;
   122			    SV * gzerror_sv = perl_get_sv(GZERRNO, FALSE) ;
   123			  
   124			    if (error_no == Z_ERRNO) {
   125			        error_no = errno ;
   126			        errstr = Strerror(errno) ;
   127			    }
   128			    else
   129			        /* errstr = gzerror(fil, &error_no) ; */
   130			        errstr = (char*) my_z_errmsg[2 - error_no]; 
   131			
   132			    if (SvIV(gzerror_sv) != error_no) {
   133			        sv_setiv(gzerror_sv, error_no) ;
   134			        sv_setpv(gzerror_sv, errstr) ;
   135			        SvIOK_on(gzerror_sv) ;
   136			    }
   137			
   138			}
   139			
   140			static void
   141			#ifdef CAN_PROTOTYPE
   142			SetGzError(gzFile file)
   143			#else
   144			SetGzError(file)
   145			gzFile file ;
   146			#endif
   147			{
   148			    int error_no ;
   149			
   150			    (void)gzerror(file, &error_no) ;
   151			    SetGzErrorNo(error_no) ;
   152			}
   153			
   154			static void
   155			#ifdef CAN_PROTOTYPE
   156			DispHex(void * ptr, int length)
   157			#else
   158			DispHex(ptr, length)
   159			    void * ptr;
   160			    int length;
   161			#endif
   162			{
   163			    char * p = (char*)ptr;
   164			    int i;
   165			    for (i = 0; i < length; ++i) {
   166			        printf(" %02x", 0xFF & *(p+i));
   167			    }
   168			}
   169			
   170			
   171			static void
   172			#ifdef CAN_PROTOTYPE
   173			DispStream(di_stream * s, char * message)
   174			#else
   175			DispStream(s, message)
   176			    di_stream * s;
   177			    char * message;
   178			#endif
   179			{
   180			
   181			#if 0
   182			    if (! trace)
   183			        return ;
   184			#endif
   185			
   186			    printf("DispStream 0x%p - %s \n", s, message) ;
   187			
   188			    if (!s)  {
   189				printf("    stream pointer is NULL\n");
   190			    }
   191			    else     {
   192				printf("    stream           0x%p\n", &(s->stream));
   193				printf("           zalloc    0x%p\n", s->stream.zalloc);
   194				printf("           zfree     0x%p\n", s->stream.zfree);
   195				printf("           opaque    0x%p\n", s->stream.opaque);
   196				if (s->stream.msg)
   197				    printf("           msg       %s\n", s->stream.msg);
   198				else
   199				    printf("           msg       \n");
   200				printf("           next_in   0x%p", s->stream.next_in);
   201			    	if (s->stream.next_in) {
   202				    printf(" =>");
   203			            DispHex(s->stream.next_in, 4);
   204				}
   205			        printf("\n");
   206			
   207				printf("           next_out  0x%p", s->stream.next_out);
   208			    	if (s->stream.next_out){
   209				    printf(" =>");
   210			            DispHex(s->stream.next_out, 4);
   211				}
   212			        printf("\n");
   213			
   214				printf("           avail_in  %ld\n", s->stream.avail_in);
   215				printf("           avail_out %ld\n", s->stream.avail_out);
   216				printf("           total_in  %ld\n", s->stream.total_in);
   217				printf("           total_out %ld\n", s->stream.total_out);
   218				printf("           adler     0x%lx\n", s->stream.adler);
   219				printf("           reserved  0x%lx\n", s->stream.reserved);
   220				printf("    bufsize          %ld\n", s->bufsize);
   221				printf("    dictionary       0x%p\n", s->dictionary);
   222				printf("    dict_adler       0x%ld\n", s->dict_adler);
   223				printf("\n");
   224			
   225			    }
   226			}
   227			
   228			
   229			static di_stream *
   230			#ifdef CAN_PROTOTYPE
   231			InitStream(uLong bufsize)
   232			#else
   233			InitStream(bufsize)
   234			    uLong bufsize ;
   235			#endif
   236			{
   237			    di_stream *s ;
   238			
   239			    ZMALLOC(s, di_stream) ;
   240			
   241			    if (s)  {
   242			        s->bufsize = bufsize ;
   243			        s->bufinc  = bufsize ;
   244			    }
   245			
   246			    return s ;
   247			    
   248			}
   249			
   250			#define SIZE 4096
   251			
   252			static int
   253			#ifdef CAN_PROTOTYPE
   254			gzreadline(Compress__Zlib__gzFile file, SV * output)
   255			#else
   256			gzreadline(file, output)
   257			  Compress__Zlib__gzFile file ;
   258			  SV * output ;
   259			#endif
   260			{
   261			
   262			    SV * store = file->buffer ;
   263			    char *nl = "\n"; 
   264			    char *p;
   265			    char *out_ptr = SvPVX(store) ;
   266			    int n;
   267			
   268			    while (1) {
   269			
   270				/* anything left from last time */
   271				if ((n = SvCUR(store))) {
   272			
   273			    	    out_ptr = SvPVX(store) + file->offset ;
   274				    if ((p = ninstr(out_ptr, out_ptr + n - 1, nl, nl))) {
   275			            /* if (rschar != 0777 && */
   276			                /* p = ninstr(out_ptr, out_ptr + n - 1, rs, rs+rslen-1)) { */
   277			
   278			         	sv_catpvn(output, out_ptr, p - out_ptr + 1);
   279			
   280					file->offset += (p - out_ptr + 1) ;
   281				        n = n - (p - out_ptr + 1);
   282				        SvCUR_set(store, n) ;
   283				        return SvCUR(output);
   284			            }
   285				    else /* no EOL, so append the complete buffer */
   286			         	sv_catpvn(output, out_ptr, n);
   287				    
   288				}
   289			
   290			
   291				SvCUR_set(store, 0) ;
   292				file->offset = 0 ;
   293			        out_ptr = SvPVX(store) ;
   294			
   295				n = gzread(file->gz, out_ptr, SIZE) ;
   296			
   297				if (n <= 0) 
   298				    /* Either EOF or an error */
   299				    /* so return what we have so far else signal eof */
   300				    return (SvCUR(output)>0) ? SvCUR(output) : n ;
   301			
   302				SvCUR_set(store, n) ;
   303			    }
   304			}
   305			
   306			static SV* 
   307			#ifdef CAN_PROTOTYPE
   308			deRef(SV * sv, char * string)
   309			#else
   310			deRef(sv, string)
   311			SV * sv ;
   312			char * string;
   313			#endif
   314			{
   315			    if (SvROK(sv)) {
   316				sv = SvRV(sv) ;
   317				switch(SvTYPE(sv)) {
   318			            case SVt_PVAV:
   319			            case SVt_PVHV:
   320			            case SVt_PVCV:
   321			                croak("%s: buffer parameter is not a SCALAR reference", string);
   322				}
   323				if (SvROK(sv))
   324				    croak("%s: buffer parameter is a reference to a reference", string) ;
   325			    }
   326			
   327			    if (!SvOK(sv)) { 
   328			        sv = newSVpv("", 0);
   329			    }	
   330			    return sv ;
   331			}
   332			
   333			#include "constants.h"
   334			
   335			#ifndef PERL_UNUSED_VAR
   336			#  define PERL_UNUSED_VAR(var) if (0) var = var
   337			#endif
   338			
   339			#line 340 "Zlib.c"
   340			
   341			/* INCLUDE:  Including 'constants.xs' from 'Zlib.xs' */
   342			
   343			
   344			XS(XS_Compress__Zlib_constant); /* prototype to pass -Wmissing-prototypes */
   345			XS(XS_Compress__Zlib_constant)
   346	         153    {
   347	         153        dXSARGS;
   348	         153        if (items != 1)
   349	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::constant(sv)");
   350	         153        PERL_UNUSED_VAR(cv); /* -W */
   351	         153        PERL_UNUSED_VAR(ax); /* -Wall */
   352	         153        SP -= items;
   353			    {
   354			#line 4 "Zlib.xs"
   355			#ifdef dXSTARG
   356				dXSTARG; /* Faster if we have it.  */
   357			#else
   358				dTARGET;
   359			#endif
   360				STRLEN		len;
   361			        int		type;
   362				IV		iv;
   363				/* NV		nv;	Uncomment this if you need to return NVs */
   364				const char	*pv;
   365			#line 366 "Zlib.c"
   366	         153    	SV *	sv = ST(0);
   367	         153    	const char *	s = SvPV(sv, len);
   368			#line 18 "Zlib.xs"
   369			        /* Change this to constant(aTHX_ s, len, &iv, &nv);
   370			           if you need to return both NVs and IVs */
   371				type = constant(aTHX_ s, len, &iv, &pv);
   372			      /* Return 1 or 2 items. First is error message, or undef if no error.
   373			           Second, if present, is found value */
   374			        switch (type) {
   375			        case PERL_constant_NOTFOUND:
   376			          sv = sv_2mortal(newSVpvf("%s is not a valid Zlib macro", s));
   377			          PUSHs(sv);
   378			          break;
   379			        case PERL_constant_NOTDEF:
   380			          sv = sv_2mortal(newSVpvf(
   381				    "Your vendor has not defined Zlib macro %s, used", s));
   382			          PUSHs(sv);
   383			          break;
   384			        case PERL_constant_ISIV:
   385			          EXTEND(SP, 1);
   386			          PUSHs(&PL_sv_undef);
   387			          PUSHi(iv);
   388			          break;
   389				/* Uncomment this if you need to return NOs
   390			        case PERL_constant_ISNO:
   391			          EXTEND(SP, 1);
   392			          PUSHs(&PL_sv_undef);
   393			          PUSHs(&PL_sv_no);
   394			          break; */
   395				/* Uncomment this if you need to return NVs
   396			        case PERL_constant_ISNV:
   397			          EXTEND(SP, 1);
   398			          PUSHs(&PL_sv_undef);
   399			          PUSHn(nv);
   400			          break; */
   401			        case PERL_constant_ISPV:
   402			          EXTEND(SP, 1);
   403			          PUSHs(&PL_sv_undef);
   404			          PUSHp(pv, strlen(pv));
   405			          break;
   406				/* Uncomment this if you need to return PVNs
   407			        case PERL_constant_ISPVN:
   408			          EXTEND(SP, 1);
   409			          PUSHs(&PL_sv_undef);
   410			          PUSHp(pv, iv);
   411			          break; */
   412				/* Uncomment this if you need to return SVs
   413			        case PERL_constant_ISSV:
   414			          EXTEND(SP, 1);
   415			          PUSHs(&PL_sv_undef);
   416			          PUSHs(sv);
   417			          break; */
   418				/* Uncomment this if you need to return UNDEFs
   419			        case PERL_constant_ISUNDEF:
   420			          break; */
   421				/* Uncomment this if you need to return UVs
   422			        case PERL_constant_ISUV:
   423			          EXTEND(SP, 1);
   424			          PUSHs(&PL_sv_undef);
   425			          PUSHu((UV)iv);
   426			          break; */
   427				/* Uncomment this if you need to return YESs
   428			        case PERL_constant_ISYES:
   429			          EXTEND(SP, 1);
   430			          PUSHs(&PL_sv_undef);
   431			          PUSHs(&PL_sv_yes);
   432			          break; */
   433			        default:
   434			          sv = sv_2mortal(newSVpvf(
   435				    "Unexpected return type %d while processing Zlib macro %s, used",
   436			               type, s));
   437			          PUSHs(sv);
   438			        }
   439			#line 440 "Zlib.c"
   440	         153    	PUTBACK;
   441				return;
   442			    }
   443			}
   444			
   445			
   446			/* INCLUDE: Returning to 'Zlib.xs' from 'constants.xs' */
   447			
   448			#define Zip_zlib_version()	(char*)zlib_version
   449			
   450			XS(XS_Compress__Zlib_zlib_version); /* prototype to pass -Wmissing-prototypes */
   451			XS(XS_Compress__Zlib_zlib_version)
   452	           6    {
   453	           6        dXSARGS;
   454	           6        if (items != 0)
   455	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::zlib_version()");
   456	           6        PERL_UNUSED_VAR(cv); /* -W */
   457			    {
   458	           6    	char *	RETVAL;
   459	           6    	dXSTARG;
   460			
   461	           6    	RETVAL = Zip_zlib_version();
   462	           6    	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
   463			    }
   464	           6        XSRETURN(1);
   465			}
   466			
   467			
   468			XS(XS_Compress__Zlib_DispStream); /* prototype to pass -Wmissing-prototypes */
   469			XS(XS_Compress__Zlib_DispStream)
   470	      ######    {
   471	      ######        dXSARGS;
   472	      ######        if (items < 1 || items > 2)
   473	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::DispStream(s, message=NULL)");
   474	      ######        PERL_UNUSED_VAR(cv); /* -W */
   475			    {
   476	      ######    	Compress__Zlib__inflateStream	s;
   477	      ######    	char *	message;
   478			
   479	      ######    	if (sv_derived_from(ST(0), "Compress::Zlib::inflateStream")) {
   480	      ######    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
   481	      ######    	    s = INT2PTR(Compress__Zlib__inflateStream,tmp);
   482				}
   483				else
   484	      ######    	    Perl_croak(aTHX_ "s is not of type Compress::Zlib::inflateStream");
   485			
   486	      ######    	if (items < 2)
   487	      ######    	    message = NULL;
   488				else {
   489	      ######    	    message = (char *)SvPV_nolen(ST(1));
   490				}
   491			
   492	      ######    	DispStream(s, message);
   493			    }
   494	      ######        XSRETURN_EMPTY;
   495			}
   496			
   497			
   498			XS(XS_Compress__Zlib_gzopen_); /* prototype to pass -Wmissing-prototypes */
   499			XS(XS_Compress__Zlib_gzopen_)
   500	          76    {
   501	          76        dXSARGS;
   502	          76        if (items != 2)
   503	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::gzopen_(path, mode)");
   504	          76        PERL_UNUSED_VAR(cv); /* -W */
   505			    {
   506	          76    	char *	path = (char *)SvPV_nolen(ST(0));
   507	          76    	char *	mode = (char *)SvPV_nolen(ST(1));
   508	          76    	Compress__Zlib__gzFile	RETVAL;
   509			#line 362 "Zlib.xs"
   510				gzFile	gz ;
   511				gz = gzopen(path, mode) ;
   512				if (gz) {
   513				    ZMALLOC(RETVAL, gzType) ;
   514			    	    RETVAL->buffer = newSV(SIZE) ;
   515			    	    SvPOK_only(RETVAL->buffer) ;
   516			    	    SvCUR_set(RETVAL->buffer, 0) ; 
   517				    RETVAL->offset = 0 ;
   518				    RETVAL->gz = gz ;
   519				    RETVAL->closed = FALSE ;
   520				    SetGzErrorNo(0) ;
   521				}
   522				else {
   523				    RETVAL = NULL ;
   524				    SetGzErrorNo(errno ? Z_ERRNO : Z_MEM_ERROR) ;
   525				}
   526			#line 527 "Zlib.c"
   527	          76    	ST(0) = sv_newmortal();
   528	          76    	sv_setref_pv(ST(0), "Compress::Zlib::gzFile", (void*)RETVAL);
   529			    }
   530	          76        XSRETURN(1);
   531			}
   532			
   533			
   534			XS(XS_Compress__Zlib_gzdopen_); /* prototype to pass -Wmissing-prototypes */
   535			XS(XS_Compress__Zlib_gzdopen_)
   536	           5    {
   537	           5        dXSARGS;
   538	           5        if (items != 3)
   539	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::gzdopen_(fh, mode, offset)");
   540	           5        PERL_UNUSED_VAR(cv); /* -W */
   541			    {
   542	           5    	int	fh = (int)SvIV(ST(0));
   543	           5    	char *	mode = (char *)SvPV_nolen(ST(1));
   544	           5    	long	offset = (long)SvIV(ST(2));
   545	           5    	Compress__Zlib__gzFile	RETVAL;
   546			#line 388 "Zlib.xs"
   547			        gzFile  gz ;
   548			        if (offset != -1)
   549			            lseek(fh, offset, 0) ; 
   550			        gz = gzdopen(fh, mode) ;
   551			        if (gz) {
   552				    ZMALLOC(RETVAL, gzType) ;
   553			            RETVAL->buffer = newSV(SIZE) ;
   554			            SvPOK_only(RETVAL->buffer) ;
   555			            SvCUR_set(RETVAL->buffer, 0) ;
   556			            RETVAL->offset = 0 ;
   557			            RETVAL->gz = gz ;
   558				    RETVAL->closed = FALSE ;
   559				    SetGzErrorNo(0) ;
   560			        }
   561			        else {
   562			            RETVAL = NULL ;
   563				    SetGzErrorNo(errno ? Z_ERRNO : Z_MEM_ERROR) ;
   564				}
   565			#line 566 "Zlib.c"
   566	           5    	ST(0) = sv_newmortal();
   567	           5    	sv_setref_pv(ST(0), "Compress::Zlib::gzFile", (void*)RETVAL);
   568			    }
   569	           5        XSRETURN(1);
   570			}
   571			
   572			#define Zip_gzread(file, buf, len) gzread(file->gz, bufp, len)
   573			
   574			XS(XS_Compress__Zlib__gzFile_gzread); /* prototype to pass -Wmissing-prototypes */
   575			XS(XS_Compress__Zlib__gzFile_gzread)
   576	         329    {
   577	         329        dXSARGS;
   578	         329        if (items < 2 || items > 3)
   579	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::gzFile::gzread(file, buf, len=4096)");
   580	         329        PERL_UNUSED_VAR(cv); /* -W */
   581			    {
   582	         329    	Compress__Zlib__gzFile	file;
   583	         329    	unsigned	len;
   584	         329    	SV *	buf = ST(1);
   585	         329    	voidp	bufp;
   586	         329    	uLong	bufsize = 0 ;
   587	         329    	int	RETVAL = 0 ;
   588	         329    	dXSTARG;
   589			
   590	         329    	if (sv_derived_from(ST(0), "Compress::Zlib::gzFile")) {
   591	         329    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
   592	         329    	    file = INT2PTR(Compress__Zlib__gzFile,tmp);
   593				}
   594				else
   595	      ######    	    Perl_croak(aTHX_ "file is not of type Compress::Zlib::gzFile");
   596			
   597	         329    	if (items < 3)
   598	          13    	    len = 4096;
   599				else {
   600	         316    	    len = (unsigned long)SvUV(ST(2));
   601				}
   602			#line 423 "Zlib.xs"
   603				if (SvREADONLY(buf) && PL_curcop != &PL_compiling)
   604			            croak("gzread: buffer parameter is read-only");
   605			        SvUPGRADE(buf, SVt_PV);
   606			        SvPOK_only(buf);
   607			        SvCUR_set(buf, 0);
   608				/* any left over from gzreadline ? */
   609				if ((bufsize = SvCUR(file->buffer)) > 0) {
   610				    uLong movesize ;
   611			
   612				    if (bufsize < len) {
   613					movesize = bufsize ;
   614				        len -= movesize ;
   615				    }
   616				    else {
   617				        movesize = len ;
   618				        len = 0 ;
   619				    }
   620				    RETVAL = movesize ;
   621			
   622			       	    sv_catpvn(buf, SvPVX(file->buffer) + file->offset, movesize);
   623			
   624				    file->offset += movesize ;
   625				    SvCUR_set(file->buffer, bufsize - movesize) ;
   626				}
   627			
   628				if (len) {
   629				    bufp = (Byte*)SvGROW(buf, bufsize+len+1);
   630				    RETVAL = gzread(file->gz, ((Bytef*)bufp)+bufsize, len) ;
   631				    SetGzError(file->gz) ; 
   632			            if (RETVAL >= 0) {
   633					RETVAL += bufsize ;
   634			                SvCUR_set(buf, RETVAL) ;
   635			                *SvEND(buf) = '\0';
   636			            }
   637				}
   638			#line 639 "Zlib.c"
   639	         329    	ST(1) = buf;
   640	         329    	SvSETMAGIC(ST(1));
   641	         329    	XSprePUSH; PUSHi((IV)RETVAL);
   642			    }
   643	         329        XSRETURN(1);
   644			}
   645			
   646			
   647			XS(XS_Compress__Zlib__gzFile_gzreadline); /* prototype to pass -Wmissing-prototypes */
   648			XS(XS_Compress__Zlib__gzFile_gzreadline)
   649	          40    {
   650	          40        dXSARGS;
   651	          40        if (items != 2)
   652	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::gzFile::gzreadline(file, buf)");
   653	          40        PERL_UNUSED_VAR(cv); /* -W */
   654			    {
   655	          40    	Compress__Zlib__gzFile	file;
   656	          40    	SV *	buf = ST(1);
   657	          40    	int	RETVAL = 0;
   658	          40    	dXSTARG;
   659			
   660	          40    	if (sv_derived_from(ST(0), "Compress::Zlib::gzFile")) {
   661	          40    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
   662	          40    	    file = INT2PTR(Compress__Zlib__gzFile,tmp);
   663				}
   664				else
   665	      ######    	    Perl_croak(aTHX_ "file is not of type Compress::Zlib::gzFile");
   666			#line 468 "Zlib.xs"
   667				if (SvREADONLY(buf) && PL_curcop != &PL_compiling) 
   668			            croak("gzreadline: buffer parameter is read-only"); 
   669			        SvUPGRADE(buf, SVt_PV);
   670			        SvPOK_only(buf);
   671				/* sv_setpvn(buf, "", SIZE) ; */
   672			        SvGROW(buf, SIZE) ;
   673			        SvCUR_set(buf, 0);
   674				RETVAL = gzreadline(file, buf) ;
   675				SetGzError(file->gz) ; 
   676			#line 677 "Zlib.c"
   677	          40    	ST(1) = buf;
   678	          40    	SvSETMAGIC(ST(1));
   679	          40    	XSprePUSH; PUSHi((IV)RETVAL);
   680			#line 481 "Zlib.xs"
   681			        if (RETVAL >= 0) {
   682			            /* SvCUR(buf) = RETVAL; */
   683			            /* Don't need to explicitly terminate with '\0', because
   684					sv_catpvn aready has */
   685			        }
   686			#line 687 "Zlib.c"
   687			    }
   688	          40        XSRETURN(1);
   689			}
   690			
   691			#define Zip_gzwrite(file, buf) gzwrite(file->gz, buf, (unsigned)len)
   692			
   693			XS(XS_Compress__Zlib__gzFile_gzwrite); /* prototype to pass -Wmissing-prototypes */
   694			XS(XS_Compress__Zlib__gzFile_gzwrite)
   695	          77    {
   696	          77        dXSARGS;
   697	          77        if (items != 2)
   698	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::gzFile::gzwrite(file, buf)");
   699	          77        PERL_UNUSED_VAR(cv); /* -W */
   700			    {
   701	          77    	Compress__Zlib__gzFile	file;
   702	          77    	STRLEN	len;
   703	          77    	voidp	buf = (voidp)SvPV(ST(1), len) ;
   704	          77    	int	RETVAL;
   705	          77    	dXSTARG;
   706			
   707	          77    	if (sv_derived_from(ST(0), "Compress::Zlib::gzFile")) {
   708	          77    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
   709	          77    	    file = INT2PTR(Compress__Zlib__gzFile,tmp);
   710				}
   711				else
   712	      ######    	    Perl_croak(aTHX_ "file is not of type Compress::Zlib::gzFile");
   713			
   714	          77    	RETVAL = Zip_gzwrite(file, buf);
   715	          77    	XSprePUSH; PUSHi((IV)RETVAL);
   716			#line 494 "Zlib.xs"
   717				  SetGzError(file->gz) ;
   718			#line 719 "Zlib.c"
   719			    }
   720	          77        XSRETURN(1);
   721			}
   722			
   723			#define Zip_gzflush(file, flush) gzflush(file->gz, flush) 
   724			
   725			XS(XS_Compress__Zlib__gzFile_gzflush); /* prototype to pass -Wmissing-prototypes */
   726			XS(XS_Compress__Zlib__gzFile_gzflush)
   727	      ######    {
   728	      ######        dXSARGS;
   729	      ######        if (items != 2)
   730	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::gzFile::gzflush(file, flush)");
   731	      ######        PERL_UNUSED_VAR(cv); /* -W */
   732			    {
   733	      ######    	Compress__Zlib__gzFile	file;
   734	      ######    	int	flush = (int)SvIV(ST(1));
   735	      ######    	int	RETVAL;
   736	      ######    	dXSTARG;
   737			
   738	      ######    	if (sv_derived_from(ST(0), "Compress::Zlib::gzFile")) {
   739	      ######    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
   740	      ######    	    file = INT2PTR(Compress__Zlib__gzFile,tmp);
   741				}
   742				else
   743	      ######    	    Perl_croak(aTHX_ "file is not of type Compress::Zlib::gzFile");
   744			
   745	      ######    	RETVAL = Zip_gzflush(file, flush);
   746	      ######    	XSprePUSH; PUSHi((IV)RETVAL);
   747			#line 502 "Zlib.xs"
   748				  SetGzError(file->gz) ;
   749			#line 750 "Zlib.c"
   750			    }
   751	      ######        XSRETURN(1);
   752			}
   753			
   754			#define Zip_gzclose(file) gzclose(file->gz)
   755			
   756			XS(XS_Compress__Zlib__gzFile_gzclose); /* prototype to pass -Wmissing-prototypes */
   757			XS(XS_Compress__Zlib__gzFile_gzclose)
   758	          48    {
   759	          48        dXSARGS;
   760	          48        if (items != 1)
   761	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::gzFile::gzclose(file)");
   762	          48        PERL_UNUSED_VAR(cv); /* -W */
   763			    {
   764	          48    	Compress__Zlib__gzFile	file;
   765	          48    	int	RETVAL;
   766	          48    	dXSTARG;
   767			
   768	          48    	if (sv_derived_from(ST(0), "Compress::Zlib::gzFile")) {
   769	          48    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
   770	          48    	    file = INT2PTR(Compress__Zlib__gzFile,tmp);
   771				}
   772				else
   773	      ######    	    Perl_croak(aTHX_ "file is not of type Compress::Zlib::gzFile");
   774			
   775	          48    	RETVAL = Zip_gzclose(file);
   776	          48    	XSprePUSH; PUSHi((IV)RETVAL);
   777			#line 509 "Zlib.xs"
   778				  file->closed = TRUE ;
   779				  SetGzErrorNo(RETVAL) ;
   780			#line 781 "Zlib.c"
   781			    }
   782	          48        XSRETURN(1);
   783			}
   784			
   785			#define Zip_gzeof(file) gzeof(file->gz)
   786			
   787			XS(XS_Compress__Zlib__gzFile_gzeof); /* prototype to pass -Wmissing-prototypes */
   788			XS(XS_Compress__Zlib__gzFile_gzeof)
   789	      ######    {
   790	      ######        dXSARGS;
   791	      ######        if (items != 1)
   792	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::gzFile::gzeof(file)");
   793	      ######        PERL_UNUSED_VAR(cv); /* -W */
   794			    {
   795	      ######    	Compress__Zlib__gzFile	file;
   796	      ######    	int	RETVAL;
   797	      ######    	dXSTARG;
   798			
   799	      ######    	if (sv_derived_from(ST(0), "Compress::Zlib::gzFile")) {
   800	      ######    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
   801	      ######    	    file = INT2PTR(Compress__Zlib__gzFile,tmp);
   802				}
   803				else
   804	      ######    	    Perl_croak(aTHX_ "file is not of type Compress::Zlib::gzFile");
   805			#line 518 "Zlib.xs"
   806			#ifdef OLD_ZLIB
   807				croak("gzeof needs zlib 1.0.6 or better") ;
   808			#else
   809				RETVAL = gzeof(file->gz);
   810			#endif
   811			#line 812 "Zlib.c"
   812	      ######    	XSprePUSH; PUSHi((IV)RETVAL);
   813			    }
   814	      ######        XSRETURN(1);
   815			}
   816			
   817			#define Zip_gzsetparams(file,l,s) gzsetparams(file->gz,l,s)
   818			
   819			XS(XS_Compress__Zlib__gzFile_gzsetparams); /* prototype to pass -Wmissing-prototypes */
   820			XS(XS_Compress__Zlib__gzFile_gzsetparams)
   821	           2    {
   822	           2        dXSARGS;
   823	           2        if (items != 3)
   824	           1    	Perl_croak(aTHX_ "Usage: Compress::Zlib::gzFile::gzsetparams(file, level, strategy)");
   825	           1        PERL_UNUSED_VAR(cv); /* -W */
   826			    {
   827	           1    	Compress__Zlib__gzFile	file;
   828	           1    	int	level = (int)SvIV(ST(1));
   829	           1    	int	strategy = (int)SvIV(ST(2));
   830	           1    	int	RETVAL;
   831	           1    	dXSTARG;
   832			
   833	           1    	if (sv_derived_from(ST(0), "Compress::Zlib::gzFile")) {
   834	           1    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
   835	           1    	    file = INT2PTR(Compress__Zlib__gzFile,tmp);
   836				}
   837				else
   838	      ######    	    Perl_croak(aTHX_ "file is not of type Compress::Zlib::gzFile");
   839			#line 534 "Zlib.xs"
   840			#ifdef OLD_ZLIB
   841				croak("gzsetparams needs zlib 1.0.6 or better") ;
   842			#else
   843				RETVAL = gzsetparams(file->gz, level, strategy);
   844			#endif
   845			#line 846 "Zlib.c"
   846	           1    	XSprePUSH; PUSHi((IV)RETVAL);
   847			    }
   848	           1        XSRETURN(1);
   849			}
   850			
   851			
   852			XS(XS_Compress__Zlib__gzFile_DESTROY); /* prototype to pass -Wmissing-prototypes */
   853			XS(XS_Compress__Zlib__gzFile_DESTROY)
   854	          78    {
   855	          78        dXSARGS;
   856	          78        if (items != 1)
   857	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::gzFile::DESTROY(file)");
   858	          78        PERL_UNUSED_VAR(cv); /* -W */
   859			    {
   860	          78    	Compress__Zlib__gzFile	file;
   861			
   862	          78    	if (SvROK(ST(0))) {
   863	          78    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
   864	          78    	    file = INT2PTR(Compress__Zlib__gzFile,tmp);
   865				}
   866				else
   867	      ######    	    Perl_croak(aTHX_ "file is not a reference");
   868			#line 546 "Zlib.xs"
   869				    if (! file->closed)
   870				        Zip_gzclose(file) ;
   871				    SvREFCNT_dec(file->buffer) ;
   872				    safefree((char*)file) ;
   873			#line 874 "Zlib.c"
   874			    }
   875	          78        XSRETURN_EMPTY;
   876			}
   877			
   878			#define Zip_gzerror(file) (char*)gzerror(file->gz, &errnum)
   879			
   880			XS(XS_Compress__Zlib__gzFile_gzerror); /* prototype to pass -Wmissing-prototypes */
   881			XS(XS_Compress__Zlib__gzFile_gzerror)
   882	      ######    {
   883	      ######        dXSARGS;
   884	      ######        if (items != 1)
   885	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::gzFile::gzerror(file)");
   886	      ######        PERL_UNUSED_VAR(cv); /* -W */
   887			    {
   888	      ######    	Compress__Zlib__gzFile	file;
   889	      ######    	int	errnum;
   890	      ######    	char *	RETVAL;
   891	      ######    	dXSTARG;
   892			
   893	      ######    	if (sv_derived_from(ST(0), "Compress::Zlib::gzFile")) {
   894	      ######    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
   895	      ######    	    file = INT2PTR(Compress__Zlib__gzFile,tmp);
   896				}
   897				else
   898	      ######    	    Perl_croak(aTHX_ "file is not of type Compress::Zlib::gzFile");
   899			
   900	      ######    	RETVAL = Zip_gzerror(file);
   901	      ######    	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
   902			#line 558 "Zlib.xs"
   903				    sv_setiv(ST(0), errnum) ;
   904			            SvPOK_on(ST(0)) ;
   905			#line 906 "Zlib.c"
   906			    }
   907	      ######        XSRETURN(1);
   908			}
   909			
   910			#define Zip_adler32(buf, adler) adler32(adler, buf, (uInt)len)
   911			
   912			XS(XS_Compress__Zlib_adler32); /* prototype to pass -Wmissing-prototypes */
   913			XS(XS_Compress__Zlib_adler32)
   914	      ######    {
   915	      ######        dXSARGS;
   916	      ######        if (items < 1 || items > 2)
   917	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::adler32(buf, adler=adlerInitial)");
   918	      ######        PERL_UNUSED_VAR(cv); /* -W */
   919			    {
   920	      ######    	uLong	adler;
   921	      ######    	STRLEN	len;
   922	      ######    	Bytef *	buf;
   923	      ######    	SV *	sv = ST(0) ;
   924	      ######    	uLong	RETVAL;
   925	      ######    	dXSTARG;
   926			#line 575 "Zlib.xs"
   927			    	/* If the buffer is a reference, dereference it */
   928				sv = deRef(sv, "adler32") ;
   929				buf = (Byte*)SvPV(sv, len) ;
   930			
   931				if (items < 2)
   932				  adler = adlerInitial;
   933				else if (SvOK(ST(1)))
   934				  adler = SvUV(ST(1)) ;
   935				else
   936				  adler = adlerInitial;
   937			#line 938 "Zlib.c"
   938			
   939	      ######    	RETVAL = Zip_adler32(buf, adler);
   940	      ######    	XSprePUSH; PUSHu((IV)RETVAL);
   941			    }
   942	      ######        XSRETURN(1);
   943			}
   944			
   945			#define Zip_crc32(buf, crc) crc32(crc, buf, (uInt)len)
   946			
   947			XS(XS_Compress__Zlib_crc32); /* prototype to pass -Wmissing-prototypes */
   948			XS(XS_Compress__Zlib_crc32)
   949	           7    {
   950	           7        dXSARGS;
   951	           7        if (items < 1 || items > 2)
   952	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::crc32(buf, crc=crcInitial)");
   953	           7        PERL_UNUSED_VAR(cv); /* -W */
   954			    {
   955	           7    	uLong	crc;
   956	           7    	STRLEN	len;
   957	           7    	Bytef *	buf;
   958	           7    	SV *	sv = ST(0) ;
   959	           7    	uLong	RETVAL;
   960	           7    	dXSTARG;
   961			#line 595 "Zlib.xs"
   962			    	/* If the buffer is a reference, dereference it */
   963				sv = deRef(sv, "crc32") ;
   964				buf = (Byte*)SvPV(sv, len) ;
   965			
   966				if (items < 2)
   967				  crc = crcInitial;
   968				else if (SvOK(ST(1)))
   969				  crc = SvUV(ST(1)) ;
   970				else
   971				  crc = crcInitial;
   972			#line 973 "Zlib.c"
   973			
   974	           7    	RETVAL = Zip_crc32(buf, crc);
   975	           7    	XSprePUSH; PUSHu((IV)RETVAL);
   976			    }
   977	           7        XSRETURN(1);
   978			}
   979			
   980			
   981			XS(XS_Compress__Zlib__deflateInit); /* prototype to pass -Wmissing-prototypes */
   982			XS(XS_Compress__Zlib__deflateInit)
   983	          47    {
   984	          47        dXSARGS;
   985	          47        if (items != 7)
   986	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::_deflateInit(level, method, windowBits, memLevel, strategy, bufsize, dictionary)");
   987	          47        PERL_UNUSED_VAR(cv); /* -W */
   988	          47        PERL_UNUSED_VAR(ax); /* -Wall */
   989	          47        SP -= items;
   990			    {
   991	          47    	int	level = (int)SvIV(ST(0));
   992	          47    	int	method = (int)SvIV(ST(1));
   993	          47    	int	windowBits = (int)SvIV(ST(2));
   994	          47    	int	memLevel = (int)SvIV(ST(3));
   995	          47    	int	strategy = (int)SvIV(ST(4));
   996	          47    	uLong	bufsize = (unsigned long)SvUV(ST(5));
   997	          47    	SV *	dictionary = ST(6);
   998			#line 619 "Zlib.xs"
   999			    int err ;
  1000			    deflateStream s ;
  1001			
  1002			    if (trace)
  1003			        warn("in _deflateInit(level=%d, method=%d, windowBits=%d, memLevel=%d, strategy=%d, bufsize=%d\n",
  1004				level, method, windowBits, memLevel, strategy, bufsize) ;
  1005			    if ((s = InitStream(bufsize)) ) {
  1006			
  1007			        s->Level      = level;
  1008			        s->Method     = method;
  1009			        s->WindowBits = windowBits;
  1010			        s->MemLevel   = memLevel;
  1011			        s->Strategy   = strategy;
  1012			
  1013			        err = deflateInit2(&(s->stream), level, 
  1014						   method, windowBits, memLevel, strategy);
  1015			
  1016				/* Check if a dictionary has been specified */
  1017				if (err == Z_OK && SvCUR(dictionary)) {
  1018				    err = deflateSetDictionary(&(s->stream), (const Bytef*) SvPVX(dictionary), 
  1019								SvCUR(dictionary)) ;
  1020				    s->dict_adler = s->stream.adler ;
  1021				}
  1022			
  1023			        if (err != Z_OK) {
  1024			            Safefree(s) ;
  1025			            s = NULL ;
  1026				}
  1027			
  1028			    }
  1029			    else
  1030			        err = Z_MEM_ERROR ;
  1031			
  1032			    XPUSHs(sv_setref_pv(sv_newmortal(), 
  1033				"Compress::Zlib::deflateStream", (void*)s));
  1034			    if (GIMME == G_ARRAY) 
  1035			        XPUSHs(sv_2mortal(newSViv(err))) ;
  1036			#line 1037 "Zlib.c"
  1037	          47    	PUTBACK;
  1038				return;
  1039			    }
  1040			}
  1041			
  1042			
  1043			XS(XS_Compress__Zlib__inflateInit); /* prototype to pass -Wmissing-prototypes */
  1044			XS(XS_Compress__Zlib__inflateInit)
  1045	          31    {
  1046	          31        dXSARGS;
  1047	          31        if (items != 3)
  1048	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::_inflateInit(windowBits, bufsize, dictionary)");
  1049	          31        PERL_UNUSED_VAR(cv); /* -W */
  1050	          31        PERL_UNUSED_VAR(ax); /* -Wall */
  1051	          31        SP -= items;
  1052			    {
  1053	          31    	int	windowBits = (int)SvIV(ST(0));
  1054	          31    	uLong	bufsize = (unsigned long)SvUV(ST(1));
  1055	          31    	SV *	dictionary = ST(2);
  1056			#line 664 "Zlib.xs"
  1057			    int err = Z_OK ;
  1058			    inflateStream s ;
  1059			
  1060			    if (trace)
  1061			        warn("in _inflateInit(windowBits=%d, bufsize=%d, dictionary=%d\n",
  1062			                windowBits, bufsize, SvCUR(dictionary)) ;
  1063			    if ((s = InitStream(bufsize)) ) {
  1064			
  1065			        s->WindowBits = windowBits;
  1066			
  1067			        err = inflateInit2(&(s->stream), windowBits);
  1068			
  1069			        if (err != Z_OK) {
  1070			            Safefree(s) ;
  1071			            s = NULL ;
  1072				}
  1073				else if (SvCUR(dictionary)) {
  1074			            /* Dictionary specified - take a copy for use in inflate */
  1075				    s->dictionary = newSVsv(dictionary) ;
  1076				}
  1077			    }
  1078			    else
  1079				err = Z_MEM_ERROR ;
  1080			
  1081			    XPUSHs(sv_setref_pv(sv_newmortal(), 
  1082			                   "Compress::Zlib::inflateStream", (void*)s));
  1083			    if (GIMME == G_ARRAY) 
  1084			        XPUSHs(sv_2mortal(newSViv(err))) ;
  1085			#line 1086 "Zlib.c"
  1086	          31    	PUTBACK;
  1087				return;
  1088			    }
  1089			}
  1090			
  1091			
  1092			XS(XS_Compress__Zlib__deflateStream_DispStream); /* prototype to pass -Wmissing-prototypes */
  1093			XS(XS_Compress__Zlib__deflateStream_DispStream)
  1094	      ######    {
  1095	      ######        dXSARGS;
  1096	      ######        if (items < 1 || items > 2)
  1097	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::deflateStream::DispStream(s, message=NULL)");
  1098	      ######        PERL_UNUSED_VAR(cv); /* -W */
  1099			    {
  1100	      ######    	Compress__Zlib__deflateStream	s;
  1101	      ######    	char *	message;
  1102			
  1103	      ######    	if (sv_derived_from(ST(0), "Compress::Zlib::deflateStream")) {
  1104	      ######    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
  1105	      ######    	    s = INT2PTR(Compress__Zlib__deflateStream,tmp);
  1106				}
  1107				else
  1108	      ######    	    Perl_croak(aTHX_ "s is not of type Compress::Zlib::deflateStream");
  1109			
  1110	      ######    	if (items < 2)
  1111	      ######    	    message = NULL;
  1112				else {
  1113	      ######    	    message = (char *)SvPV_nolen(ST(1));
  1114				}
  1115			
  1116	      ######    	DispStream(s, message);
  1117			    }
  1118	      ######        XSRETURN_EMPTY;
  1119			}
  1120			
  1121			
  1122			XS(XS_Compress__Zlib__deflateStream_deflate); /* prototype to pass -Wmissing-prototypes */
  1123			XS(XS_Compress__Zlib__deflateStream_deflate)
  1124	         124    {
  1125	         124        dXSARGS;
  1126	         124        if (items != 2)
  1127	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::deflateStream::deflate(s, buf)");
  1128	         124        PERL_UNUSED_VAR(cv); /* -W */
  1129	         124        PERL_UNUSED_VAR(ax); /* -Wall */
  1130	         124        SP -= items;
  1131			    {
  1132	         124    	Compress__Zlib__deflateStream	s;
  1133	         124    	SV *	buf = ST(1);
  1134	         124    	uLong	outsize;
  1135	         124    	SV *	output;
  1136	         124    	int	err = 0;
  1137			
  1138	         124    	if (sv_derived_from(ST(0), "Compress::Zlib::deflateStream")) {
  1139	         124    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
  1140	         124    	    s = INT2PTR(Compress__Zlib__deflateStream,tmp);
  1141				}
  1142				else
  1143	      ######    	    Perl_croak(aTHX_ "s is not of type Compress::Zlib::deflateStream");
  1144			#line 711 "Zlib.xs"
  1145			    /* If the buffer is a reference, dereference it */
  1146			    buf = deRef(buf, "deflate") ;
  1147			
  1148			    /* initialise the input buffer */
  1149			    s->stream.next_in = (Bytef*)SvPV(buf, *(STRLEN*)&s->stream.avail_in) ;
  1150			    /* s->stream.next_in = (Bytef*)SvPVX(buf); */
  1151			    s->stream.avail_in = SvCUR(buf) ;
  1152			
  1153			    /* and the output buffer */
  1154			    /* output = sv_2mortal(newSVpv("", s->bufinc)) ; */
  1155			    output = sv_2mortal(newSV(s->bufinc)) ;
  1156			    SvPOK_only(output) ;
  1157			    SvCUR_set(output, 0) ; 
  1158			    outsize = s->bufinc ;
  1159			    s->stream.next_out = (Bytef*) SvPVX(output) ;
  1160			    s->stream.avail_out = outsize;
  1161			
  1162			    /* Check for saved output from deflateParams */
  1163			    if (s->deflateParams_out_valid) {
  1164				*(s->stream.next_out) = s->deflateParams_out_byte;
  1165				++ s->stream.next_out;
  1166				-- s->stream.avail_out ;
  1167				s->deflateParams_out_valid = FALSE;
  1168			    }
  1169			
  1170			    while (s->stream.avail_in != 0) {
  1171			
  1172			        if (s->stream.avail_out == 0) {
  1173			            s->bufinc *= 2 ;
  1174			            SvGROW(output, outsize + s->bufinc) ;
  1175			            s->stream.next_out = (Bytef*) SvPVX(output) + outsize ;
  1176			            outsize += s->bufinc ;
  1177			            s->stream.avail_out = s->bufinc ;
  1178			        }
  1179			        err = deflate(&(s->stream), Z_NO_FLUSH);
  1180			        if (err != Z_OK) 
  1181			            break;
  1182			    }
  1183			
  1184			    if (err == Z_OK) {
  1185			        SvPOK_only(output);
  1186			        SvCUR_set(output, outsize - s->stream.avail_out) ;
  1187			    }
  1188			    else
  1189			        output = &PL_sv_undef ;
  1190			    XPUSHs(output) ;
  1191			    if (GIMME == G_ARRAY) 
  1192			        XPUSHs(sv_2mortal(newSViv(err))) ;
  1193			#line 1194 "Zlib.c"
  1194	         124    	PUTBACK;
  1195				return;
  1196			    }
  1197			}
  1198			
  1199			
  1200			XS(XS_Compress__Zlib__deflateStream_flush); /* prototype to pass -Wmissing-prototypes */
  1201			XS(XS_Compress__Zlib__deflateStream_flush)
  1202	          47    {
  1203	          47        dXSARGS;
  1204	          47        if (items < 1 || items > 2)
  1205	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::deflateStream::flush(s, f=Z_FINISH)");
  1206	          47        PERL_UNUSED_VAR(cv); /* -W */
  1207	          47        PERL_UNUSED_VAR(ax); /* -Wall */
  1208	          47        SP -= items;
  1209			    {
  1210	          47    	Compress__Zlib__deflateStream	s;
  1211	          47    	int	f;
  1212	          47    	uLong	outsize;
  1213	          47    	SV *	output;
  1214	          47    	int	err = Z_OK ;
  1215			
  1216	          47    	if (sv_derived_from(ST(0), "Compress::Zlib::deflateStream")) {
  1217	          47    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
  1218	          47    	    s = INT2PTR(Compress__Zlib__deflateStream,tmp);
  1219				}
  1220				else
  1221	      ######    	    Perl_croak(aTHX_ "s is not of type Compress::Zlib::deflateStream");
  1222			
  1223	          47    	if (items < 2)
  1224	          46    	    f = Z_FINISH;
  1225				else {
  1226	           1    	    f = (int)SvIV(ST(1));
  1227				}
  1228			#line 771 "Zlib.xs"
  1229			    s->stream.avail_in = 0; /* should be zero already anyway */
  1230			
  1231			    /* output = sv_2mortal(newSVpv("", s->bufinc)) ; */
  1232			    output = sv_2mortal(newSV(s->bufinc)) ;
  1233			    SvPOK_only(output) ;
  1234			    SvCUR_set(output, 0) ; 
  1235			    outsize = s->bufinc ;
  1236			    s->stream.next_out = (Bytef*) SvPVX(output) ;
  1237			    s->stream.avail_out = outsize;
  1238			
  1239			    /* Check for saved output from deflateParams */
  1240			    if (s->deflateParams_out_valid) {
  1241				*(s->stream.next_out) = s->deflateParams_out_byte;
  1242				++ s->stream.next_out;
  1243				-- s->stream.avail_out ;
  1244				s->deflateParams_out_valid = FALSE;
  1245			    }
  1246			
  1247			    for (;;) {
  1248			        if (s->stream.avail_out == 0) {
  1249				    /* consumed all the available output, so extend it */
  1250			            s->bufinc *= 2 ;
  1251				    SvGROW(output, outsize + s->bufinc) ;
  1252			            s->stream.next_out = (Bytef*)SvPVX(output) + outsize ;
  1253				    outsize += s->bufinc ;
  1254			            s->stream.avail_out = s->bufinc ;
  1255			        }
  1256			        err = deflate(&(s->stream), f);
  1257			
  1258			        /* deflate has finished flushing only when it hasn't used up
  1259			         * all the available space in the output buffer: 
  1260			         */
  1261			        if (s->stream.avail_out != 0 || err != Z_OK )
  1262			            break;
  1263			    }
  1264			
  1265			    err =  (err == Z_STREAM_END ? Z_OK : err) ;
  1266			
  1267			    if (err == Z_OK) {
  1268			        SvPOK_only(output);
  1269			        SvCUR_set(output, outsize - s->stream.avail_out) ;
  1270			    }
  1271			    else
  1272			        output = &PL_sv_undef ;
  1273			    XPUSHs(output) ;
  1274			    if (GIMME == G_ARRAY) 
  1275			        XPUSHs(sv_2mortal(newSViv(err))) ;
  1276			#line 1277 "Zlib.c"
  1277	          47    	PUTBACK;
  1278				return;
  1279			    }
  1280			}
  1281			
  1282			
  1283			XS(XS_Compress__Zlib__deflateStream__deflateParams); /* prototype to pass -Wmissing-prototypes */
  1284			XS(XS_Compress__Zlib__deflateStream__deflateParams)
  1285	           3    {
  1286	           3        dXSARGS;
  1287	           3        if (items != 5)
  1288	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::deflateStream::_deflateParams(s, flags, level, strategy, bufsize)");
  1289	           3        PERL_UNUSED_VAR(cv); /* -W */
  1290			    {
  1291	           3    	Compress__Zlib__deflateStream	s;
  1292	           3    	int	flags = (int)SvIV(ST(1));
  1293	           3    	int	level = (int)SvIV(ST(2));
  1294	           3    	int	strategy = (int)SvIV(ST(3));
  1295	           3    	uLong	bufsize = (unsigned long)SvUV(ST(4));
  1296	           3    	int	RETVAL;
  1297	           3    	dXSTARG;
  1298			
  1299	           3    	if (sv_derived_from(ST(0), "Compress::Zlib::deflateStream")) {
  1300	           3    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
  1301	           3    	    s = INT2PTR(Compress__Zlib__deflateStream,tmp);
  1302				}
  1303				else
  1304	      ######    	    Perl_croak(aTHX_ "s is not of type Compress::Zlib::deflateStream");
  1305			#line 827 "Zlib.xs"
  1306				if (flags & 1)
  1307				    s->Level = level ;
  1308				if (flags & 2)
  1309				    s->Strategy = strategy ;
  1310			        if (bufsize) {
  1311			            s->bufsize = bufsize; 
  1312			            s->bufinc  = bufsize; 
  1313				}
  1314			        s->stream.avail_in = 0; 
  1315			        s->stream.next_out = &(s->deflateParams_out_byte) ;
  1316			        s->stream.avail_out = 1;
  1317				RETVAL = deflateParams(&(s->stream), s->Level, s->Strategy);
  1318				s->deflateParams_out_valid = 
  1319					(RETVAL == Z_OK && s->stream.avail_out == 0) ;
  1320			#line 1321 "Zlib.c"
  1321	           3    	XSprePUSH; PUSHi((IV)RETVAL);
  1322			    }
  1323	           3        XSRETURN(1);
  1324			}
  1325			
  1326			
  1327			XS(XS_Compress__Zlib__deflateStream_get_Level); /* prototype to pass -Wmissing-prototypes */
  1328			XS(XS_Compress__Zlib__deflateStream_get_Level)
  1329	           5    {
  1330	           5        dXSARGS;
  1331	           5        if (items != 1)
  1332	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::deflateStream::get_Level(s)");
  1333	           5        PERL_UNUSED_VAR(cv); /* -W */
  1334			    {
  1335	           5    	Compress__Zlib__deflateStream	s;
  1336	           5    	int	RETVAL;
  1337	           5    	dXSTARG;
  1338			
  1339	           5    	if (sv_derived_from(ST(0), "Compress::Zlib::deflateStream")) {
  1340	           5    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
  1341	           5    	    s = INT2PTR(Compress__Zlib__deflateStream,tmp);
  1342				}
  1343				else
  1344	      ######    	    Perl_croak(aTHX_ "s is not of type Compress::Zlib::deflateStream");
  1345			#line 849 "Zlib.xs"
  1346				RETVAL = s->Level ;
  1347			#line 1348 "Zlib.c"
  1348	           5    	XSprePUSH; PUSHi((IV)RETVAL);
  1349			    }
  1350	           5        XSRETURN(1);
  1351			}
  1352			
  1353			
  1354			XS(XS_Compress__Zlib__deflateStream_get_Strategy); /* prototype to pass -Wmissing-prototypes */
  1355			XS(XS_Compress__Zlib__deflateStream_get_Strategy)
  1356	           5    {
  1357	           5        dXSARGS;
  1358	           5        if (items != 1)
  1359	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::deflateStream::get_Strategy(s)");
  1360	           5        PERL_UNUSED_VAR(cv); /* -W */
  1361			    {
  1362	           5    	Compress__Zlib__deflateStream	s;
  1363	           5    	int	RETVAL;
  1364	           5    	dXSTARG;
  1365			
  1366	           5    	if (sv_derived_from(ST(0), "Compress::Zlib::deflateStream")) {
  1367	           5    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
  1368	           5    	    s = INT2PTR(Compress__Zlib__deflateStream,tmp);
  1369				}
  1370				else
  1371	      ######    	    Perl_croak(aTHX_ "s is not of type Compress::Zlib::deflateStream");
  1372			#line 857 "Zlib.xs"
  1373				RETVAL = s->Strategy ;
  1374			#line 1375 "Zlib.c"
  1375	           5    	XSprePUSH; PUSHi((IV)RETVAL);
  1376			    }
  1377	           5        XSRETURN(1);
  1378			}
  1379			
  1380			
  1381			XS(XS_Compress__Zlib__deflateStream_DESTROY); /* prototype to pass -Wmissing-prototypes */
  1382			XS(XS_Compress__Zlib__deflateStream_DESTROY)
  1383	          46    {
  1384	          46        dXSARGS;
  1385	          46        if (items != 1)
  1386	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::deflateStream::DESTROY(s)");
  1387	          46        PERL_UNUSED_VAR(cv); /* -W */
  1388			    {
  1389	          46    	Compress__Zlib__deflateStream	s;
  1390			
  1391	          46    	if (SvROK(ST(0))) {
  1392	          46    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
  1393	          46    	    s = INT2PTR(Compress__Zlib__deflateStream,tmp);
  1394				}
  1395				else
  1396	      ######    	    Perl_croak(aTHX_ "s is not a reference");
  1397			#line 865 "Zlib.xs"
  1398			    deflateEnd(&s->stream) ;
  1399			    if (s->dictionary)
  1400				SvREFCNT_dec(s->dictionary) ;
  1401			    Safefree(s) ;
  1402			#line 1403 "Zlib.c"
  1403			    }
  1404	          46        XSRETURN_EMPTY;
  1405			}
  1406			
  1407			
  1408			XS(XS_Compress__Zlib__deflateStream_dict_adler); /* prototype to pass -Wmissing-prototypes */
  1409			XS(XS_Compress__Zlib__deflateStream_dict_adler)
  1410	           1    {
  1411	           1        dXSARGS;
  1412	           1        if (items != 1)
  1413	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::deflateStream::dict_adler(s)");
  1414	           1        PERL_UNUSED_VAR(cv); /* -W */
  1415			    {
  1416	           1    	Compress__Zlib__deflateStream	s;
  1417	           1    	uLong	RETVAL;
  1418	           1    	dXSTARG;
  1419			
  1420	           1    	if (sv_derived_from(ST(0), "Compress::Zlib::deflateStream")) {
  1421	           1    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
  1422	           1    	    s = INT2PTR(Compress__Zlib__deflateStream,tmp);
  1423				}
  1424				else
  1425	      ######    	    Perl_croak(aTHX_ "s is not of type Compress::Zlib::deflateStream");
  1426			#line 875 "Zlib.xs"
  1427				RETVAL = s->dict_adler ;
  1428			#line 1429 "Zlib.c"
  1429	           1    	XSprePUSH; PUSHu((IV)RETVAL);
  1430			    }
  1431	           1        XSRETURN(1);
  1432			}
  1433			
  1434			
  1435			XS(XS_Compress__Zlib__deflateStream_total_in); /* prototype to pass -Wmissing-prototypes */
  1436			XS(XS_Compress__Zlib__deflateStream_total_in)
  1437	           4    {
  1438	           4        dXSARGS;
  1439	           4        if (items != 1)
  1440	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::deflateStream::total_in(s)");
  1441	           4        PERL_UNUSED_VAR(cv); /* -W */
  1442			    {
  1443	           4    	Compress__Zlib__deflateStream	s;
  1444	           4    	uLong	RETVAL;
  1445	           4    	dXSTARG;
  1446			
  1447	           4    	if (sv_derived_from(ST(0), "Compress::Zlib::deflateStream")) {
  1448	           4    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
  1449	           4    	    s = INT2PTR(Compress__Zlib__deflateStream,tmp);
  1450				}
  1451				else
  1452	      ######    	    Perl_croak(aTHX_ "s is not of type Compress::Zlib::deflateStream");
  1453			#line 883 "Zlib.xs"
  1454				RETVAL = s->stream.total_in ;
  1455			#line 1456 "Zlib.c"
  1456	           4    	XSprePUSH; PUSHu((IV)RETVAL);
  1457			    }
  1458	           4        XSRETURN(1);
  1459			}
  1460			
  1461			
  1462			XS(XS_Compress__Zlib__deflateStream_total_out); /* prototype to pass -Wmissing-prototypes */
  1463			XS(XS_Compress__Zlib__deflateStream_total_out)
  1464	      ######    {
  1465	      ######        dXSARGS;
  1466	      ######        if (items != 1)
  1467	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::deflateStream::total_out(s)");
  1468	      ######        PERL_UNUSED_VAR(cv); /* -W */
  1469			    {
  1470	      ######    	Compress__Zlib__deflateStream	s;
  1471	      ######    	uLong	RETVAL;
  1472	      ######    	dXSTARG;
  1473			
  1474	      ######    	if (sv_derived_from(ST(0), "Compress::Zlib::deflateStream")) {
  1475	      ######    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
  1476	      ######    	    s = INT2PTR(Compress__Zlib__deflateStream,tmp);
  1477				}
  1478				else
  1479	      ######    	    Perl_croak(aTHX_ "s is not of type Compress::Zlib::deflateStream");
  1480			#line 891 "Zlib.xs"
  1481				RETVAL = s->stream.total_out ;
  1482			#line 1483 "Zlib.c"
  1483	      ######    	XSprePUSH; PUSHu((IV)RETVAL);
  1484			    }
  1485	      ######        XSRETURN(1);
  1486			}
  1487			
  1488			
  1489			XS(XS_Compress__Zlib__deflateStream_msg); /* prototype to pass -Wmissing-prototypes */
  1490			XS(XS_Compress__Zlib__deflateStream_msg)
  1491	      ######    {
  1492	      ######        dXSARGS;
  1493	      ######        if (items != 1)
  1494	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::deflateStream::msg(s)");
  1495	      ######        PERL_UNUSED_VAR(cv); /* -W */
  1496			    {
  1497	      ######    	Compress__Zlib__deflateStream	s;
  1498	      ######    	char *	RETVAL;
  1499	      ######    	dXSTARG;
  1500			
  1501	      ######    	if (sv_derived_from(ST(0), "Compress::Zlib::deflateStream")) {
  1502	      ######    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
  1503	      ######    	    s = INT2PTR(Compress__Zlib__deflateStream,tmp);
  1504				}
  1505				else
  1506	      ######    	    Perl_croak(aTHX_ "s is not of type Compress::Zlib::deflateStream");
  1507			#line 899 "Zlib.xs"
  1508			        RETVAL = s->stream.msg;
  1509			#line 1510 "Zlib.c"
  1510	      ######    	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
  1511			    }
  1512	      ######        XSRETURN(1);
  1513			}
  1514			
  1515			
  1516			XS(XS_Compress__Zlib__inflateStream_DispStream); /* prototype to pass -Wmissing-prototypes */
  1517			XS(XS_Compress__Zlib__inflateStream_DispStream)
  1518	      ######    {
  1519	      ######        dXSARGS;
  1520	      ######        if (items < 1 || items > 2)
  1521	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::inflateStream::DispStream(s, message=NULL)");
  1522	      ######        PERL_UNUSED_VAR(cv); /* -W */
  1523			    {
  1524	      ######    	Compress__Zlib__inflateStream	s;
  1525	      ######    	char *	message;
  1526			
  1527	      ######    	if (sv_derived_from(ST(0), "Compress::Zlib::inflateStream")) {
  1528	      ######    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
  1529	      ######    	    s = INT2PTR(Compress__Zlib__inflateStream,tmp);
  1530				}
  1531				else
  1532	      ######    	    Perl_croak(aTHX_ "s is not of type Compress::Zlib::inflateStream");
  1533			
  1534	      ######    	if (items < 2)
  1535	      ######    	    message = NULL;
  1536				else {
  1537	      ######    	    message = (char *)SvPV_nolen(ST(1));
  1538				}
  1539			
  1540	      ######    	DispStream(s, message);
  1541			    }
  1542	      ######        XSRETURN_EMPTY;
  1543			}
  1544			
  1545			
  1546			XS(XS_Compress__Zlib__inflateStream_inflate); /* prototype to pass -Wmissing-prototypes */
  1547			XS(XS_Compress__Zlib__inflateStream_inflate)
  1548	         173    {
  1549	         173        dXSARGS;
  1550	         173        dXSI32;
  1551	         173        if (items != 2)
  1552	      ######           Perl_croak(aTHX_ "Usage: %s(s, buf)", GvNAME(CvGV(cv)));
  1553	         173        PERL_UNUSED_VAR(cv); /* -W */
  1554	         173        PERL_UNUSED_VAR(ax); /* -Wall */
  1555	         173        SP -= items;
  1556			    {
  1557	         173    	Compress__Zlib__inflateStream	s;
  1558	         173    	SV *	buf = ST(1);
  1559	         173    	uLong	outsize;
  1560	         173    	SV *	output;
  1561	         173    	int	err = Z_OK ;
  1562			
  1563	         173    	if (sv_derived_from(ST(0), "Compress::Zlib::inflateStream")) {
  1564	         173    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
  1565	         173    	    s = INT2PTR(Compress__Zlib__inflateStream,tmp);
  1566				}
  1567				else
  1568	      ######    	    Perl_croak(aTHX_ "s is not of type Compress::Zlib::inflateStream");
  1569			#line 922 "Zlib.xs"
  1570			    /* If the buffer is a reference, dereference it */
  1571			    buf = deRef(buf, "inflate") ;
  1572			
  1573			    /* initialise the input buffer */
  1574			    s->stream.next_in = (Bytef*)SvPVX(buf) ;
  1575			    s->stream.avail_in = SvCUR(buf) ;
  1576			
  1577			    /* and the output buffer */
  1578			    output = sv_2mortal(newSV(s->bufinc+1)) ;
  1579			    SvPOK_only(output) ;
  1580			    SvCUR_set(output, 0) ; 
  1581			    outsize = s->bufinc ;
  1582			    s->stream.next_out = (Bytef*) SvPVX(output)  ;
  1583			    s->stream.avail_out = outsize;
  1584			
  1585			    while (1) {
  1586			
  1587			        if (s->stream.avail_out == 0) {
  1588			            s->bufinc *= 2 ;
  1589			            SvGROW(output, outsize + s->bufinc+1) ;
  1590			            s->stream.next_out = (Bytef*) SvPVX(output) + outsize ;
  1591			            outsize += s->bufinc ;
  1592			            s->stream.avail_out = s->bufinc ;
  1593			        }
  1594			
  1595			        err = inflate(&(s->stream), Z_SYNC_FLUSH);
  1596				if (err == Z_BUF_ERROR) {
  1597				    if (s->stream.avail_out == 0)
  1598				        continue ;
  1599				    if (s->stream.avail_in == 0) {
  1600					err = Z_OK ;
  1601				        break ;
  1602				    }
  1603				}
  1604			
  1605				if (err == Z_NEED_DICT && s->dictionary) {
  1606				    s->dict_adler = s->stream.adler ;
  1607			            err = inflateSetDictionary(&(s->stream), 
  1608				    				(const Bytef*)SvPVX(s->dictionary),
  1609								SvCUR(s->dictionary));
  1610				}
  1611			
  1612			        if (err != Z_OK) 
  1613			            break;
  1614			    }
  1615			
  1616			    if (err == Z_OK || err == Z_STREAM_END || err == Z_DATA_ERROR) {
  1617				unsigned in ;
  1618			
  1619			        SvPOK_only(output);
  1620			        SvCUR_set(output, outsize - s->stream.avail_out) ;
  1621			        *SvEND(output) = '\0';
  1622			
  1623			 	/* fix the input buffer */
  1624				if (ix == 0) {
  1625			 	    in = s->stream.avail_in ;
  1626			 	    SvCUR_set(buf, in) ;
  1627			 	    if (in)
  1628			     	        Move(s->stream.next_in, SvPVX(buf), in, char) ;	
  1629			            *SvEND(buf) = '\0';
  1630			            SvSETMAGIC(buf);
  1631				}
  1632			    }
  1633			    else
  1634			        output = &PL_sv_undef ;
  1635			    XPUSHs(output) ;
  1636			    if (GIMME == G_ARRAY) 
  1637			        XPUSHs(sv_2mortal(newSViv(err))) ;
  1638			#line 1639 "Zlib.c"
  1639	         173    	PUTBACK;
  1640				return;
  1641			    }
  1642			}
  1643			
  1644			
  1645			XS(XS_Compress__Zlib__inflateStream_inflateSync); /* prototype to pass -Wmissing-prototypes */
  1646			XS(XS_Compress__Zlib__inflateStream_inflateSync)
  1647	         169    {
  1648	         169        dXSARGS;
  1649	         169        if (items != 2)
  1650	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::inflateStream::inflateSync(s, buf)");
  1651	         169        PERL_UNUSED_VAR(cv); /* -W */
  1652			    {
  1653	         169    	Compress__Zlib__inflateStream	s;
  1654	         169    	SV *	buf = ST(1);
  1655	         169    	int	RETVAL;
  1656	         169    	dXSTARG;
  1657			
  1658	         169    	if (sv_derived_from(ST(0), "Compress::Zlib::inflateStream")) {
  1659	         169    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
  1660	         169    	    s = INT2PTR(Compress__Zlib__inflateStream,tmp);
  1661				}
  1662				else
  1663	      ######    	    Perl_croak(aTHX_ "s is not of type Compress::Zlib::inflateStream");
  1664			#line 997 "Zlib.xs"
  1665			    /* If the buffer is a reference, dereference it */
  1666			    buf = deRef(buf, "inflateSync") ;
  1667			
  1668			    /* initialise the input buffer */
  1669			    s->stream.next_in = (Bytef*)SvPVX(buf) ;
  1670			    s->stream.avail_in = SvCUR(buf) ;
  1671			
  1672			    /* inflateSync doesn't create any output */
  1673			    s->stream.next_out = (Bytef*) NULL;
  1674			    s->stream.avail_out = 0;
  1675			
  1676			    RETVAL = inflateSync(&(s->stream));
  1677			    {
  1678			 	/* fix the input buffer */
  1679				unsigned in = s->stream.avail_in ;
  1680			
  1681			 	SvCUR_set(buf, in) ;
  1682			 	if (in)
  1683			     	    Move(s->stream.next_in, SvPVX(buf), in, char) ;	
  1684			        *SvEND(buf) = '\0';
  1685			        SvSETMAGIC(buf);
  1686			    }
  1687			#line 1688 "Zlib.c"
  1688	         169    	XSprePUSH; PUSHi((IV)RETVAL);
  1689			    }
  1690	         169        XSRETURN(1);
  1691			}
  1692			
  1693			
  1694			XS(XS_Compress__Zlib__inflateStream_DESTROY); /* prototype to pass -Wmissing-prototypes */
  1695			XS(XS_Compress__Zlib__inflateStream_DESTROY)
  1696	          31    {
  1697	          31        dXSARGS;
  1698	          31        if (items != 1)
  1699	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::inflateStream::DESTROY(s)");
  1700	          31        PERL_UNUSED_VAR(cv); /* -W */
  1701			    {
  1702	          31    	Compress__Zlib__inflateStream	s;
  1703			
  1704	          31    	if (SvROK(ST(0))) {
  1705	          31    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
  1706	          31    	    s = INT2PTR(Compress__Zlib__inflateStream,tmp);
  1707				}
  1708				else
  1709	      ######    	    Perl_croak(aTHX_ "s is not a reference");
  1710			#line 1026 "Zlib.xs"
  1711			    inflateEnd(&s->stream) ;
  1712			    if (s->dictionary)
  1713				SvREFCNT_dec(s->dictionary) ;
  1714			    Safefree(s) ;
  1715			#line 1716 "Zlib.c"
  1716			    }
  1717	          31        XSRETURN_EMPTY;
  1718			}
  1719			
  1720			
  1721			XS(XS_Compress__Zlib__inflateStream_dict_adler); /* prototype to pass -Wmissing-prototypes */
  1722			XS(XS_Compress__Zlib__inflateStream_dict_adler)
  1723	           1    {
  1724	           1        dXSARGS;
  1725	           1        if (items != 1)
  1726	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::inflateStream::dict_adler(s)");
  1727	           1        PERL_UNUSED_VAR(cv); /* -W */
  1728			    {
  1729	           1    	Compress__Zlib__inflateStream	s;
  1730	           1    	uLong	RETVAL;
  1731	           1    	dXSTARG;
  1732			
  1733	           1    	if (sv_derived_from(ST(0), "Compress::Zlib::inflateStream")) {
  1734	           1    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
  1735	           1    	    s = INT2PTR(Compress__Zlib__inflateStream,tmp);
  1736				}
  1737				else
  1738	      ######    	    Perl_croak(aTHX_ "s is not of type Compress::Zlib::inflateStream");
  1739			#line 1036 "Zlib.xs"
  1740				RETVAL = s->dict_adler ;
  1741			#line 1742 "Zlib.c"
  1742	           1    	XSprePUSH; PUSHu((IV)RETVAL);
  1743			    }
  1744	           1        XSRETURN(1);
  1745			}
  1746			
  1747			
  1748			XS(XS_Compress__Zlib__inflateStream_total_in); /* prototype to pass -Wmissing-prototypes */
  1749			XS(XS_Compress__Zlib__inflateStream_total_in)
  1750	      ######    {
  1751	      ######        dXSARGS;
  1752	      ######        if (items != 1)
  1753	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::inflateStream::total_in(s)");
  1754	      ######        PERL_UNUSED_VAR(cv); /* -W */
  1755			    {
  1756	      ######    	Compress__Zlib__inflateStream	s;
  1757	      ######    	uLong	RETVAL;
  1758	      ######    	dXSTARG;
  1759			
  1760	      ######    	if (sv_derived_from(ST(0), "Compress::Zlib::inflateStream")) {
  1761	      ######    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
  1762	      ######    	    s = INT2PTR(Compress__Zlib__inflateStream,tmp);
  1763				}
  1764				else
  1765	      ######    	    Perl_croak(aTHX_ "s is not of type Compress::Zlib::inflateStream");
  1766			#line 1044 "Zlib.xs"
  1767				RETVAL = s->stream.total_in ;
  1768			#line 1769 "Zlib.c"
  1769	      ######    	XSprePUSH; PUSHu((IV)RETVAL);
  1770			    }
  1771	      ######        XSRETURN(1);
  1772			}
  1773			
  1774			
  1775			XS(XS_Compress__Zlib__inflateStream_total_out); /* prototype to pass -Wmissing-prototypes */
  1776			XS(XS_Compress__Zlib__inflateStream_total_out)
  1777	      ######    {
  1778	      ######        dXSARGS;
  1779	      ######        if (items != 1)
  1780	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::inflateStream::total_out(s)");
  1781	      ######        PERL_UNUSED_VAR(cv); /* -W */
  1782			    {
  1783	      ######    	Compress__Zlib__inflateStream	s;
  1784	      ######    	uLong	RETVAL;
  1785	      ######    	dXSTARG;
  1786			
  1787	      ######    	if (sv_derived_from(ST(0), "Compress::Zlib::inflateStream")) {
  1788	      ######    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
  1789	      ######    	    s = INT2PTR(Compress__Zlib__inflateStream,tmp);
  1790				}
  1791				else
  1792	      ######    	    Perl_croak(aTHX_ "s is not of type Compress::Zlib::inflateStream");
  1793			#line 1052 "Zlib.xs"
  1794				RETVAL = s->stream.total_out ;
  1795			#line 1796 "Zlib.c"
  1796	      ######    	XSprePUSH; PUSHu((IV)RETVAL);
  1797			    }
  1798	      ######        XSRETURN(1);
  1799			}
  1800			
  1801			
  1802			XS(XS_Compress__Zlib__inflateStream_msg); /* prototype to pass -Wmissing-prototypes */
  1803			XS(XS_Compress__Zlib__inflateStream_msg)
  1804	      ######    {
  1805	      ######        dXSARGS;
  1806	      ######        if (items != 1)
  1807	      ######    	Perl_croak(aTHX_ "Usage: Compress::Zlib::inflateStream::msg(s)");
  1808	      ######        PERL_UNUSED_VAR(cv); /* -W */
  1809			    {
  1810	      ######    	Compress__Zlib__inflateStream	s;
  1811	      ######    	char *	RETVAL;
  1812	      ######    	dXSTARG;
  1813			
  1814	      ######    	if (sv_derived_from(ST(0), "Compress::Zlib::inflateStream")) {
  1815	      ######    	    IV tmp = SvIV((SV*)SvRV(ST(0)));
  1816	      ######    	    s = INT2PTR(Compress__Zlib__inflateStream,tmp);
  1817				}
  1818				else
  1819	      ######    	    Perl_croak(aTHX_ "s is not of type Compress::Zlib::inflateStream");
  1820			#line 1060 "Zlib.xs"
  1821			        RETVAL = s->stream.msg;
  1822			#line 1823 "Zlib.c"
  1823	      ######    	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
  1824			    }
  1825	      ######        XSRETURN(1);
  1826			}
  1827			
  1828			#ifdef __cplusplus
  1829			extern "C"
  1830			#endif
  1831			XS(boot_Compress__Zlib); /* prototype to pass -Wmissing-prototypes */
  1832			XS(boot_Compress__Zlib)
  1833	          25    {
  1834	          25        dXSARGS;
  1835	          25        char* file = __FILE__;
  1836			
  1837	          25        PERL_UNUSED_VAR(cv); /* -W */
  1838	          25        PERL_UNUSED_VAR(items); /* -W */
  1839	          25        XS_VERSION_BOOTCHECK ;
  1840			
  1841			    {
  1842	          25            CV * cv ;
  1843			
  1844	          25            newXS("Compress::Zlib::constant", XS_Compress__Zlib_constant, file);
  1845	          25            newXS("Compress::Zlib::zlib_version", XS_Compress__Zlib_zlib_version, file);
  1846	          25            newXS("Compress::Zlib::DispStream", XS_Compress__Zlib_DispStream, file);
  1847	          25            newXS("Compress::Zlib::gzopen_", XS_Compress__Zlib_gzopen_, file);
  1848	          25            newXS("Compress::Zlib::gzdopen_", XS_Compress__Zlib_gzdopen_, file);
  1849	          25            newXS("Compress::Zlib::gzFile::gzread", XS_Compress__Zlib__gzFile_gzread, file);
  1850	          25            newXS("Compress::Zlib::gzFile::gzreadline", XS_Compress__Zlib__gzFile_gzreadline, file);
  1851	          25            newXS("Compress::Zlib::gzFile::gzwrite", XS_Compress__Zlib__gzFile_gzwrite, file);
  1852	          25            newXS("Compress::Zlib::gzFile::gzflush", XS_Compress__Zlib__gzFile_gzflush, file);
  1853	          25            newXS("Compress::Zlib::gzFile::gzclose", XS_Compress__Zlib__gzFile_gzclose, file);
  1854	          25            newXS("Compress::Zlib::gzFile::gzeof", XS_Compress__Zlib__gzFile_gzeof, file);
  1855	          25            newXS("Compress::Zlib::gzFile::gzsetparams", XS_Compress__Zlib__gzFile_gzsetparams, file);
  1856	          25            newXS("Compress::Zlib::gzFile::DESTROY", XS_Compress__Zlib__gzFile_DESTROY, file);
  1857	          25            newXS("Compress::Zlib::gzFile::gzerror", XS_Compress__Zlib__gzFile_gzerror, file);
  1858	          25            newXS("Compress::Zlib::adler32", XS_Compress__Zlib_adler32, file);
  1859	          25            newXS("Compress::Zlib::crc32", XS_Compress__Zlib_crc32, file);
  1860	          25            newXS("Compress::Zlib::_deflateInit", XS_Compress__Zlib__deflateInit, file);
  1861	          25            newXS("Compress::Zlib::_inflateInit", XS_Compress__Zlib__inflateInit, file);
  1862	          25            newXS("Compress::Zlib::deflateStream::DispStream", XS_Compress__Zlib__deflateStream_DispStream, file);
  1863	          25            newXS("Compress::Zlib::deflateStream::deflate", XS_Compress__Zlib__deflateStream_deflate, file);
  1864	          25            newXS("Compress::Zlib::deflateStream::flush", XS_Compress__Zlib__deflateStream_flush, file);
  1865	          25            newXS("Compress::Zlib::deflateStream::_deflateParams", XS_Compress__Zlib__deflateStream__deflateParams, file);
  1866	          25            newXS("Compress::Zlib::deflateStream::get_Level", XS_Compress__Zlib__deflateStream_get_Level, file);
  1867	          25            newXS("Compress::Zlib::deflateStream::get_Strategy", XS_Compress__Zlib__deflateStream_get_Strategy, file);
  1868	          25            newXS("Compress::Zlib::deflateStream::DESTROY", XS_Compress__Zlib__deflateStream_DESTROY, file);
  1869	          25            newXS("Compress::Zlib::deflateStream::dict_adler", XS_Compress__Zlib__deflateStream_dict_adler, file);
  1870	          25            newXS("Compress::Zlib::deflateStream::total_in", XS_Compress__Zlib__deflateStream_total_in, file);
  1871	          25            newXS("Compress::Zlib::deflateStream::total_out", XS_Compress__Zlib__deflateStream_total_out, file);
  1872	          25            newXS("Compress::Zlib::deflateStream::msg", XS_Compress__Zlib__deflateStream_msg, file);
  1873	          25            newXS("Compress::Zlib::inflateStream::DispStream", XS_Compress__Zlib__inflateStream_DispStream, file);
  1874	          25            cv = newXS("Compress::Zlib::inflateStream::__unc_inflate", XS_Compress__Zlib__inflateStream_inflate, file);
  1875	          25            XSANY.any_i32 = 1 ;
  1876	          25            cv = newXS("Compress::Zlib::inflateStream::inflate", XS_Compress__Zlib__inflateStream_inflate, file);
  1877	          25            XSANY.any_i32 = 0 ;
  1878	          25            newXS("Compress::Zlib::inflateStream::inflateSync", XS_Compress__Zlib__inflateStream_inflateSync, file);
  1879	          25            newXS("Compress::Zlib::inflateStream::DESTROY", XS_Compress__Zlib__inflateStream_DESTROY, file);
  1880	          25            newXS("Compress::Zlib::inflateStream::dict_adler", XS_Compress__Zlib__inflateStream_dict_adler, file);
  1881	          25            newXS("Compress::Zlib::inflateStream::total_in", XS_Compress__Zlib__inflateStream_total_in, file);
  1882	          25            newXS("Compress::Zlib::inflateStream::total_out", XS_Compress__Zlib__inflateStream_total_out, file);
  1883	          25            newXS("Compress::Zlib::inflateStream::msg", XS_Compress__Zlib__inflateStream_msg, file);
  1884			    }
  1885			
  1886			    /* Initialisation Section */
  1887			
  1888			#line 334 "Zlib.xs"
  1889			    /* Check this version of zlib is == 1 */
  1890			    if (zlibVersion()[0] != '1')
  1891				croak("Compress::Zlib needs zlib version 1.x\n") ;
  1892			
  1893			    {
  1894			        /* Create the $gzerror scalar */
  1895			        SV * gzerror_sv = perl_get_sv(GZERRNO, GV_ADDMULTI) ;
  1896			        sv_setiv(gzerror_sv, 0) ;
  1897			        sv_setpv(gzerror_sv, "") ;
  1898			        SvIOK_on(gzerror_sv) ;
  1899			    }
  1900			
  1901			#line 1902 "Zlib.c"
  1902			
  1903			    /* End of Initialisation Section */
  1904			
  1905	          25        XSRETURN_YES;
  1906			}
  1907			
