2 * Author : Paul Marquess, <pmqs@cpan.org>
3 * Created : 22nd January 1996
6 * Copyright (c) 1995-2013 Paul Marquess. All rights reserved.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the same terms as Perl itself.
12 /* Parts of this code are based on the files gzio.c and gzappend.c from
13 * the standard zlib source distribution. Below are the copyright statements
17 /* gzio.c -- IO on .gz files
18 * Copyright (C) 1995 Jean-loup Gailly.
19 * For conditions of distribution and use, see copyright notice in zlib.h
22 /* gzappend -- command to append to a gzip file
24 Copyright (C) 2003 Mark Adler, all rights reserved
25 version 1.1, 4 Nov 2003
29 #define PERL_NO_GET_CONTEXT
36 /* zlib prior to 1.06 doesn't know about z_off_t */
41 #if ! defined(ZLIB_VERNUM) || ZLIB_VERNUM < 0x1200
42 # define NEED_DUMMY_BYTE_AT_END
45 #if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1210
47 # define AT_LEAST_ZLIB_1_2_1
50 #if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1221
51 # define AT_LEAST_ZLIB_1_2_2_1
54 #if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1222
55 # define AT_LEAST_ZLIB_1_2_2_2
58 #if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1223
59 # define AT_LEAST_ZLIB_1_2_2_3
62 #if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1230
63 # define AT_LEAST_ZLIB_1_2_3
66 #if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1252
68 Use Z_SOLO to build source means need own malloc/free
70 # define AT_LEAST_ZLIB_1_2_5_2
73 #if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1280
74 # define AT_LEAST_ZLIB_1_2_8
78 # define NEED_sv_2pvbyte
79 # define NEED_sv_2pv_nolen
80 # define NEED_sv_pvn_force_flags
84 #if PERL_REVISION == 5 && PERL_VERSION == 9
86 # define sv_pvbyte_force(sv,lp) sv_pvbyten_force(sv,lp)
89 #if PERL_REVISION == 5 && (PERL_VERSION < 8 || (PERL_VERSION == 8 && PERL_SUBVERSION < 4 ))
91 # ifdef SvPVbyte_force
92 # undef SvPVbyte_force
95 # define SvPVbyte_force(sv,lp) SvPV_force(sv,lp)
99 #ifndef SvPVbyte_nolen
100 # define SvPVbyte_nolen SvPV_nolen
106 # ifndef SvPVbyte_nolen
107 # define SvPVbyte_nolen SvPV_nolen
110 # ifndef SvPVbyte_force
111 # define SvPVbyte_force(sv,lp) SvPV_force(sv,lp)
115 #if PERL_REVISION == 5 && (PERL_VERSION >= 8 || (PERL_VERSION == 8 && PERL_SUBVERSION < 4 ))
116 # define UTF8_AVAILABLE
119 typedef int DualType ;
120 typedef int int_undef ;
122 typedef struct di_stream {
124 #define FLAG_APPEND 1
126 #define FLAG_ADLER32 4
127 #define FLAG_CONSUME_INPUT 8
128 #define FLAG_LIMIT_OUTPUT 16
139 bool deflateParams_out_valid ;
140 Bytef deflateParams_out_byte;
142 #define deflateParams_BUFFER_SIZE 0x4000
143 uLong deflateParams_out_length;
144 Bytef* deflateParams_out_buffer;
151 uLong bytesInflated ;
152 uLong compressedBytes ;
153 uLong uncompressedBytes ;
156 #define WINDOW_SIZE 32768U
158 bool matchedEndBlock;
160 int window_lastbit, window_left, window_full;
161 unsigned window_have;
162 off_t window_lastoff, window_end;
163 off_t window_endOffset;
165 uLong lastBlockOffset ;
166 unsigned char window_lastByte ;
172 typedef di_stream * deflateStream ;
173 typedef di_stream * Compress__Raw__Zlib__deflateStream ;
174 typedef di_stream * inflateStream ;
175 typedef di_stream * Compress__Raw__Zlib__inflateStream ;
176 typedef di_stream * Compress__Raw__Zlib__inflateScanStream ;
178 #define ZMALLOC(to, typ) ((to = (typ *)safemalloc(sizeof(typ))), \
181 /* Figure out the Operating System */
183 # define OS_CODE 0x00
186 #if defined(AMIGA) || defined(AMIGAOS)
187 # define OS_CODE 0x01
190 #if defined(VAXC) || defined(VMS)
191 # define OS_CODE 0x02
195 # define OS_CODE 0x04
198 #if defined(ATARI) || defined(atarist)
199 # define OS_CODE 0x05
203 # define OS_CODE 0x06
206 #if defined(MACOS) || defined(TARGET_OS_MAC)
207 # define OS_CODE 0x07
211 # define OS_CODE 0x08
215 # define OS_CODE 0x09
219 # define OS_CODE 0x0a
222 #ifdef WIN32 /* Window 95 & Windows NT */
223 # define OS_CODE 0x0b
227 # define OS_CODE 0x0c
230 #if 0 /* Acorn RISCOS */
231 # define OS_CODE 0x0d
235 # define OS_CODE 0x0e
238 #ifdef __50SERIES /* Prime/PRIMOS */
239 # define OS_CODE 0x0F
242 /* Default to UNIX */
244 # define OS_CODE 0x03 /* assume Unix */
248 # define GZIP_OS_CODE OS_CODE
251 #define adlerInitial adler32(0L, Z_NULL, 0)
252 #define crcInitial crc32(0L, Z_NULL, 0)
254 /* static const char * const my_z_errmsg[] = { */
255 static const char my_z_errmsg[][32] = {
256 "need dictionary", /* Z_NEED_DICT 2 */
257 "stream end", /* Z_STREAM_END 1 */
259 "file error", /* Z_ERRNO (-1) */
260 "stream error", /* Z_STREAM_ERROR (-2) */
261 "data error", /* Z_DATA_ERROR (-3) */
262 "insufficient memory", /* Z_MEM_ERROR (-4) */
263 "buffer error", /* Z_BUF_ERROR (-5) */
264 "incompatible version",/* Z_VERSION_ERROR(-6) */
267 #define setDUALstatus(var, err) \
268 sv_setnv(var, (double)err) ; \
269 sv_setpv(var, ((err) ? GetErrorString(err) : "")) ; \
273 #if defined(__SYMBIAN32__)
274 # define NO_WRITEABLE_DATA
277 #define TRACE_DEFAULT 0
279 #ifdef NO_WRITEABLE_DATA
280 # define trace TRACE_DEFAULT
282 static int trace = TRACE_DEFAULT ;
285 /* Dodge PerlIO hiding of these functions. */
290 GetErrorString(int error_no)
292 GetErrorString(error_no)
299 if (error_no == Z_ERRNO) {
300 errstr = Strerror(errno) ;
303 /* errstr = gzerror(fil, &error_no) ; */
304 errstr = (char*) my_z_errmsg[2 - error_no];
313 The following two functions are taken almost directly from
314 examples/gzappend.c. Only cosmetic changes have been made to conform to
315 the coding style of the rest of the code in this file.
319 /* return the greatest common divisor of a and b using Euclid's algorithm,
320 modified to be fast when one argument much greater than the other, and
321 coded to avoid unnecessary swapping */
324 gcd(unsigned a, unsigned b)
349 /* rotate list[0..len-1] left by rot positions, in place */
352 rotate(unsigned char *list, unsigned len, unsigned rot)
354 rotate(list, len, rot)
362 unsigned char *start, *last, *to, *from;
364 /* normalize rot and handle degenerate cases */
366 if (rot >= len) rot %= len;
367 if (rot == 0) return;
369 /* pointer to last entry in list */
370 last = list + (len - 1);
372 /* do simple left shift by one */
375 memcpy(list, list + 1, len - 1);
380 /* do simple right shift by one */
381 if (rot == len - 1) {
383 memmove(list + 1, list, len - 1);
388 /* otherwise do rotate as a set of cycles in place */
389 cycles = gcd(len, rot); /* number of cycles */
391 start = from = list + cycles; /* start index is arbitrary */
392 tmp = *from; /* save entry to be overwritten */
394 to = from; /* next step in cycle */
395 from += rot; /* go right rot positions */
396 if (from > last) from -= len; /* (pointer better not wrap) */
397 if (from == start) break; /* all but one shifted */
398 *to = *from; /* shift left */
400 *to = tmp; /* complete the circle */
404 #endif /* MAGIC_APPEND */
408 DispHex(void * ptr, int length)
415 char * p = (char*)ptr;
417 for (i = 0; i < length; ++i) {
418 printf(" %02x", 0xFF & *(p+i));
425 DispStream(di_stream * s, const char * message)
427 DispStream(s, message)
429 const char * message;
438 #define EnDis(f) (s->flags & f ? "Enabled" : "Disabled")
440 printf("DispStream %p", s) ;
442 printf("- %s \n", message) ;
446 printf(" stream pointer is NULL\n");
449 printf(" stream %p\n", &(s->stream));
450 printf(" zalloc %p\n", s->stream.zalloc);
451 printf(" zfree %p\n", s->stream.zfree);
452 printf(" opaque %p\n", s->stream.opaque);
453 printf(" state %p\n", s->stream.state);
455 printf(" msg %s\n", s->stream.msg);
458 printf(" next_in %p", s->stream.next_in);
459 if (s->stream.next_in){
461 DispHex(s->stream.next_in, 4);
465 printf(" next_out %p", s->stream.next_out);
466 if (s->stream.next_out){
468 DispHex(s->stream.next_out, 4);
472 printf(" avail_in %lu\n", (unsigned long)s->stream.avail_in);
473 printf(" avail_out %lu\n", (unsigned long)s->stream.avail_out);
474 printf(" total_in %ld\n", s->stream.total_in);
475 printf(" total_out %ld\n", s->stream.total_out);
476 printf(" adler %ld\n", s->stream.adler );
477 printf(" bufsize %ld\n", s->bufsize);
478 printf(" dictionary %p\n", s->dictionary);
479 printf(" dict_adler 0x%ld\n",s->dict_adler);
480 printf(" zip_mode %d\n", s->zip_mode);
481 printf(" crc32 0x%x\n", (unsigned)s->crc32);
482 printf(" adler32 0x%x\n", (unsigned)s->adler32);
483 printf(" flags 0x%x\n", s->flags);
484 printf(" APPEND %s\n", EnDis(FLAG_APPEND));
485 printf(" CRC32 %s\n", EnDis(FLAG_CRC32));
486 printf(" ADLER32 %s\n", EnDis(FLAG_ADLER32));
487 printf(" CONSUME %s\n", EnDis(FLAG_CONSUME_INPUT));
488 printf(" LIMIT %s\n", EnDis(FLAG_LIMIT_OUTPUT));
492 printf(" window %p\n", s->window);
499 #ifdef AT_LEAST_ZLIB_1_2_5_2
500 voidpf my_zcalloc (voidpf opaque, unsigned items, unsigned size)
502 return safemalloc(items * size);
506 void my_zcfree (voidpf opaque, voidpf ptr)
523 ZMALLOC(s, di_stream) ;
525 #ifdef AT_LEAST_ZLIB_1_2_5_2
526 s->stream.zalloc = my_zcalloc;
527 s->stream.zfree = my_zcfree;
535 PostInitStream(di_stream * s, int flags, int bufsize, int windowBits)
537 PostInitStream(s, flags, bufsize, windowBits)
544 s->bufsize = bufsize ;
546 s->uncompressedBytes =
549 s->zip_mode = (windowBits < 0) ;
550 if (flags & FLAG_CRC32)
551 s->crc32 = crcInitial ;
552 if (flags & FLAG_ADLER32)
553 s->adler32 = adlerInitial ;
559 deRef(SV * sv, const char * string)
576 croak("%s: buffer parameter is not a SCALAR reference", string);
581 croak("%s: buffer parameter is a reference to a reference", string) ;
585 sv = sv_2mortal(newSVpv("", 0));
592 deRef_l(SV * sv, const char * string)
615 croak("%s: buffer parameter is not a SCALAR reference", string);
620 croak("%s: buffer parameter is a reference to a reference", string) ;
623 if (SvREADONLY(sv) && PL_curcop != &PL_compiling)
624 croak("%s: buffer parameter is read-only", string);
626 SvUPGRADE(sv, SVt_PV);
631 (void)SvPVbyte_force(sv, na) ;
637 #include "constants.h"
639 MODULE = Compress::Raw::Zlib PACKAGE = Compress::Raw::Zlib PREFIX = Zip_
644 INCLUDE: constants.xs
647 /* Check this version of zlib is == 1 */
648 if (zlibVersion()[0] != '1')
649 croak("Compress::Raw::Zlib needs zlib version 1.x\n") ;
652 /* Create the $os_code scalar */
653 SV * os_code_sv = perl_get_sv("Compress::Raw::Zlib::gzip_os_code", GV_ADDMULTI) ;
654 sv_setiv(os_code_sv, GZIP_OS_CODE) ;
658 #define Zip_zlib_version() (const char*)zlib_version
666 RETVAL = ZLIB_VERNUM ;
668 /* 1.1.4 => 0x1140 */
669 RETVAL = (ZLIB_VERSION[0] - '0') << 12 ;
670 RETVAL += (ZLIB_VERSION[2] - '0') << 8 ;
671 RETVAL += (ZLIB_VERSION[4] - '0') << 4 ;
672 if (strlen(ZLIB_VERSION) > 5)
673 RETVAL += (ZLIB_VERSION[6] - '0') ;
679 #ifndef AT_LEAST_ZLIB_1_2_1
680 #define zlibCompileFlags() 0
685 MODULE = Compress::Raw::Zlib PACKAGE = Compress::Raw::Zlib PREFIX = Zip_
687 #define Zip_adler32(buf, adler) adler32(adler, buf, (uInt)len)
690 Zip_adler32(buf, adler=adlerInitial)
691 uLong adler = NO_INIT
693 Bytef * buf = NO_INIT
696 /* If the buffer is a reference, dereference it */
697 sv = deRef(sv, "adler32") ;
698 #ifdef UTF8_AVAILABLE
699 if (DO_UTF8(sv) && !sv_utf8_downgrade(sv, 1))
700 croak("Wide character in Compress::Raw::Zlib::adler32");
702 buf = (Byte*)SvPVbyte(sv, len) ;
705 adler = adlerInitial;
706 else if (SvOK(ST(1)))
707 adler = SvUV(ST(1)) ;
709 adler = adlerInitial;
713 #define Zip_crc32(buf, crc, offset) crc32(crc, buf+offset, (uInt)len-offset)
716 Zip_crc32(buf, crc=crcInitial, offset=0)
719 Bytef * buf = NO_INIT
723 /* If the buffer is a reference, dereference it */
724 sv = deRef(sv, "crc32") ;
725 #ifdef UTF8_AVAILABLE
726 if (DO_UTF8(sv) && !sv_utf8_downgrade(sv, 1))
727 croak("Wide character in Compress::Raw::Zlib::crc32");
729 buf = (Byte*)SvPVbyte(sv, len) ;
733 else if (SvOK(ST(1)))
739 crc32_combine(crc1, crc2, len2)
744 #ifndef AT_LEAST_ZLIB_1_2_2_1
745 crc1 = crc1; crc2 = crc2 ; len2 = len2; /* Silence -Wall */
746 croak("crc32_combine needs zlib 1.2.3 or better");
748 RETVAL = crc32_combine(crc1, crc2, len2);
755 adler32_combine(adler1, adler2, len2)
760 #ifndef AT_LEAST_ZLIB_1_2_2_1
761 adler1 = adler1; adler2 = adler2 ; len2 = len2; /* Silence -Wall */
762 croak("adler32_combine needs zlib 1.2.3 or better");
764 RETVAL = adler32_combine(adler1, adler2, len2);
770 MODULE = Compress::Raw::Zlib PACKAGE = Compress::Raw::Zlib
773 _deflateInit(flags,level, method, windowBits, memLevel, strategy, bufsize, dictionary)
787 warn("in _deflateInit(level=%d, method=%d, windowBits=%d, memLevel=%d, strategy=%d, bufsize=%ld dictionary=%p)\n",
788 level, method, windowBits, memLevel, strategy, bufsize, dictionary) ;
789 if ((s = InitStream() )) {
793 s->WindowBits = windowBits;
794 s->MemLevel = memLevel;
795 s->Strategy = strategy;
797 err = deflateInit2(&(s->stream), level,
798 method, windowBits, memLevel, strategy);
801 warn(" _deflateInit2 returned %d (state %p)\n", err, s);
802 DispStream(s, "INIT");
805 /* Check if a dictionary has been specified */
806 SvGETMAGIC(dictionary);
807 if (err == Z_OK && SvPOK(dictionary) && SvCUR(dictionary)) {
808 #ifdef UTF8_AVAILABLE
809 if (DO_UTF8(dictionary) && !sv_utf8_downgrade(dictionary, 1))
810 croak("Wide character in Compress::Raw::Zlib::Deflate::new dicrionary parameter");
812 err = deflateSetDictionary(&(s->stream), (const Bytef*) SvPVX(dictionary), SvCUR(dictionary)) ;
814 warn("deflateSetDictionary returned %d\n", err);
815 s->dict_adler = s->stream.adler ;
823 PostInitStream(s, flags, bufsize, windowBits) ;
830 SV* obj = sv_setref_pv(sv_newmortal(),
831 "Compress::Raw::Zlib::deflateStream", (void*)s);
834 if (GIMME == G_ARRAY) {
835 SV * sv = sv_2mortal(newSViv(err)) ;
836 setDUALstatus(sv, err);
841 _inflateInit(flags, windowBits, bufsize, dictionary)
854 croak("inflateScanInit needs zlib 1.2.1 or better");
857 warn("in _inflateInit(windowBits=%d, bufsize=%lu, dictionary=%lu\n",
858 windowBits, bufsize, (unsigned long)SvCUR(dictionary)) ;
859 if ((s = InitStream() )) {
861 s->WindowBits = windowBits;
863 err = inflateInit2(&(s->stream), windowBits);
868 else if (sv_len(dictionary)) {
869 #ifdef AT_LEAST_ZLIB_1_2_2_1
870 /* Zlib 1.2.2.1 or better allows a dictionary with raw inflate */
871 if (s->WindowBits < 0) {
873 const Bytef* b = (const Bytef*)SvPVbyte(dictionary, dlen);
874 err = inflateSetDictionary(&(s->stream),
883 /* Dictionary specified - take a copy for use in inflate */
884 s->dictionary = newSVsv(dictionary) ;
887 PostInitStream(s, flags, bufsize, windowBits) ;
891 s->window = (unsigned char *)safemalloc(WINDOW_SIZE);
900 SV* obj = sv_setref_pv(sv_newmortal(),
902 ? "Compress::Raw::Zlib::inflateScanStream"
903 : "Compress::Raw::Zlib::inflateStream",
907 if (GIMME == G_ARRAY) {
908 SV * sv = sv_2mortal(newSViv(err)) ;
909 setDUALstatus(sv, err);
915 MODULE = Compress::Raw::Zlib PACKAGE = Compress::Raw::Zlib::deflateStream
918 DispStream(s, message=NULL)
919 Compress::Raw::Zlib::deflateStream s
924 Compress::Raw::Zlib::deflateStream s
926 RETVAL = deflateReset(&(s->stream)) ;
927 if (RETVAL == Z_OK) {
928 PostInitStream(s, s->flags, s->bufsize, s->WindowBits) ;
934 deflate (s, buf, output)
935 Compress::Raw::Zlib::deflateStream s
938 uInt cur_length = NO_INIT
939 uInt increment = NO_INIT
940 uInt prefix = NO_INIT
942 uLong bufinc = NO_INIT
943 STRLEN origlen = NO_INIT
947 /* If the input buffer is a reference, dereference it */
948 buf = deRef(buf, "deflate") ;
950 /* initialise the input buffer */
951 #ifdef UTF8_AVAILABLE
952 if (DO_UTF8(buf) && !sv_utf8_downgrade(buf, 1))
953 croak("Wide character in Compress::Raw::Zlib::Deflate::deflate input parameter");
955 s->stream.next_in = (Bytef*)SvPV_nomg(buf, origlen) ;
956 s->stream.avail_in = origlen;
958 if (s->flags & FLAG_CRC32)
959 s->crc32 = crc32(s->crc32, s->stream.next_in, s->stream.avail_in) ;
961 if (s->flags & FLAG_ADLER32)
962 s->adler32 = adler32(s->adler32, s->stream.next_in, s->stream.avail_in) ;
964 /* and retrieve the output buffer */
965 output = deRef_l(output, "deflate") ;
966 #ifdef UTF8_AVAILABLE
967 if (DO_UTF8(output) && !sv_utf8_downgrade(output, 1))
968 croak("Wide character in Compress::Raw::Zlib::Deflate::deflate output parameter");
971 if((s->flags & FLAG_APPEND) != FLAG_APPEND) {
972 SvCUR_set(output, 0);
973 /* sv_setpvn(output, "", 0); */
975 prefix = cur_length = SvCUR(output) ;
976 s->stream.next_out = (Bytef*) SvPVX(output) + cur_length;
977 increment = SvLEN(output) - cur_length;
978 s->stream.avail_out = increment;
980 /* Check for saved output from deflateParams */
981 if (s->deflateParams_out_valid) {
982 *(s->stream.next_out) = s->deflateParams_out_byte;
983 ++ s->stream.next_out;
984 -- s->stream.avail_out ;
985 s->deflateParams_out_valid = FALSE;
988 /* Check for saved output from deflateParams */
989 if (s->deflateParams_out_length) {
990 uLong plen = s->deflateParams_out_length ;
991 /* printf("Copy %d bytes saved data\n", plen);*/
992 if (s->stream.avail_out < plen) {
993 /*printf("GROW from %d to %d\n", s->stream.avail_out,
994 SvLEN(output) + plen - s->stream.avail_out); */
995 Sv_Grow(output, SvLEN(output) + plen - s->stream.avail_out) ;
998 Copy(s->stream.next_out, s->deflateParams_out_buffer, plen, Bytef) ;
999 cur_length = cur_length + plen;
1000 SvCUR_set(output, cur_length);
1001 s->stream.next_out += plen ;
1002 s->stream.avail_out = SvLEN(output) - cur_length ;
1003 increment = s->stream.avail_out;
1004 s->deflateParams_out_length = 0;
1008 while (s->stream.avail_in != 0) {
1010 if (s->stream.avail_out == 0) {
1011 /* out of space in the output buffer so make it bigger */
1012 s->stream.next_out = (Bytef*) Sv_Grow(output, SvLEN(output) + bufinc) ;
1013 cur_length += increment ;
1014 s->stream.next_out += cur_length ;
1015 increment = bufinc ;
1016 s->stream.avail_out = increment;
1021 printf("DEFLATE Avail In %d, Out %d\n", s->stream.avail_in, s->stream.avail_out);
1022 DispStream(s, "BEFORE");
1023 /* Perl_sv_dump(output); */
1026 RETVAL = deflate(&(s->stream), Z_NO_FLUSH);
1029 printf("DEFLATE returned %d %s, avail in %d, out %d\n", RETVAL,
1030 GetErrorString(RETVAL), s->stream.avail_in, s->stream.avail_out);
1031 DispStream(s, "AFTER");
1038 s->compressedBytes += cur_length + increment - prefix - s->stream.avail_out ;
1039 s->uncompressedBytes += origlen - s->stream.avail_in ;
1041 s->last_error = RETVAL ;
1042 if (RETVAL == Z_OK) {
1044 SvCUR_set(output, cur_length + increment - s->stream.avail_out) ;
1053 Compress::Raw::Zlib::deflateStream s
1056 printf("Compress::Raw::Zlib::deflateStream::DESTROY %p\n", s);
1057 deflateEnd(&s->stream) ;
1059 SvREFCNT_dec(s->dictionary) ;
1061 if (s->deflateParams_out_buffer)
1062 Safefree(s->deflateParams_out_buffer);
1068 flush(s, output, f=Z_FINISH)
1069 Compress::Raw::Zlib::deflateStream s
1072 uInt cur_length = NO_INIT
1073 uInt increment = NO_INIT
1074 uInt prefix = NO_INIT
1075 uLong bufinc = NO_INIT
1076 uLong availableout = NO_INIT
1078 bufinc = s->bufsize;
1080 s->stream.avail_in = 0; /* should be zero already anyway */
1082 /* retrieve the output buffer */
1083 output = deRef_l(output, "flush") ;
1084 #ifdef UTF8_AVAILABLE
1085 if (DO_UTF8(output) && !sv_utf8_downgrade(output, 1))
1086 croak("Wide character in Compress::Raw::Zlib::Deflate::flush input parameter");
1088 if(! s->flags & FLAG_APPEND) {
1089 SvCUR_set(output, 0);
1090 /* sv_setpvn(output, "", 0); */
1092 prefix = cur_length = SvCUR(output) ;
1093 s->stream.next_out = (Bytef*) SvPVX(output) + cur_length;
1094 increment = SvLEN(output) - cur_length;
1095 s->stream.avail_out = increment;
1097 /* Check for saved output from deflateParams */
1098 if (s->deflateParams_out_valid) {
1099 *(s->stream.next_out) = s->deflateParams_out_byte;
1100 ++ s->stream.next_out;
1101 -- s->stream.avail_out ;
1102 s->deflateParams_out_valid = FALSE;
1105 /* Check for saved output from deflateParams */
1106 if (s->deflateParams_out_length) {
1107 uLong plen = s->deflateParams_out_length ;
1108 /* printf("Copy %d bytes saved data\n", plen); */
1109 if (s->stream.avail_out < plen) {
1110 /* printf("GROW from %d to %d\n", s->stream.avail_out,
1111 SvLEN(output) + plen - s->stream.avail_out); */
1112 Sv_Grow(output, SvLEN(output) + plen - s->stream.avail_out) ;
1115 Copy(s->stream.next_out, s->deflateParams_out_buffer, plen, Bytef) ;
1116 cur_length = cur_length + plen;
1117 SvCUR_set(output, cur_length);
1118 s->stream.next_out += plen ;
1119 s->stream.avail_out = SvLEN(output) - cur_length ;
1120 increment = s->stream.avail_out;
1121 s->deflateParams_out_length = 0;
1126 if (s->stream.avail_out == 0) {
1127 /* consumed all the available output, so extend it */
1128 s->stream.next_out = (Bytef*) Sv_Grow(output, SvLEN(output) + bufinc) ;
1129 cur_length += increment ;
1130 s->stream.next_out += cur_length ;
1131 increment = bufinc ;
1132 s->stream.avail_out = increment;
1136 availableout = s->stream.avail_out ;
1139 printf("flush (%d) DEFLATE Avail In %d, Out %d\n", f, s->stream.avail_in, s->stream.avail_out);
1140 DispStream(s, "BEFORE");
1141 /* Perl_sv_dump(output); */
1144 RETVAL = deflate(&(s->stream), f);
1147 printf("flush DEFLATE returned %d %s, avail in %d, out %d\n", RETVAL,
1148 GetErrorString(RETVAL), s->stream.avail_in, s->stream.avail_out);
1149 DispStream(s, "AFTER");
1152 /* Ignore the second of two consecutive flushes: */
1153 if (availableout == s->stream.avail_out && RETVAL == Z_BUF_ERROR)
1156 /* deflate has finished flushing only when it hasn't used up
1157 * all the available space in the output buffer:
1159 if (s->stream.avail_out != 0 || RETVAL != Z_OK )
1163 RETVAL = (RETVAL == Z_STREAM_END ? Z_OK : RETVAL) ;
1164 s->last_error = RETVAL ;
1166 s->compressedBytes += cur_length + increment - prefix - s->stream.avail_out ;
1168 if (RETVAL == Z_OK) {
1170 SvCUR_set(output, cur_length + increment - s->stream.avail_out) ;
1178 _deflateParams(s, flags, level, strategy, bufsize)
1179 Compress::Raw::Zlib::deflateStream s
1185 /* printf("_deflateParams(Flags %d Level %d Strategy %d Bufsize %d)\n", flags, level, strategy, bufsize);
1186 printf("Before -- Level %d, Strategy %d, Bufsize %d\n", s->Level, s->Strategy, s->bufsize); */
1190 s->Strategy = strategy ;
1192 s->bufsize = bufsize;
1194 /* printf("After -- Level %d, Strategy %d, Bufsize %d\n", s->Level, s->Strategy, s->bufsize);*/
1196 s->stream.avail_in = 0;
1197 s->stream.next_out = &(s->deflateParams_out_byte) ;
1198 s->stream.avail_out = 1;
1199 RETVAL = deflateParams(&(s->stream), s->Level, s->Strategy);
1200 s->deflateParams_out_valid =
1201 (RETVAL == Z_OK && s->stream.avail_out == 0) ;
1202 /* printf("RETVAL %d, avail out %d, byte %c\n", RETVAL, s->stream.avail_out, s->deflateParams_out_byte); */
1204 /* printf("Level %d Strategy %d, Prev Len %d\n",
1205 s->Level, s->Strategy, s->deflateParams_out_length); */
1206 s->stream.avail_in = 0;
1207 if (s->deflateParams_out_buffer == NULL)
1208 s->deflateParams_out_buffer = safemalloc(deflateParams_BUFFER_SIZE);
1209 s->stream.next_out = s->deflateParams_out_buffer ;
1210 s->stream.avail_out = deflateParams_BUFFER_SIZE;
1212 RETVAL = deflateParams(&(s->stream), s->Level, s->Strategy);
1213 s->deflateParams_out_length = deflateParams_BUFFER_SIZE - s->stream.avail_out;
1214 /* printf("RETVAL %d, length out %d, avail %d\n",
1215 RETVAL, s->deflateParams_out_length, s->stream.avail_out ); */
1223 Compress::Raw::Zlib::deflateStream s
1231 Compress::Raw::Zlib::deflateStream s
1233 RETVAL = s->Strategy ;
1240 Compress::Raw::Zlib::deflateStream s
1242 RETVAL = s->bufsize ;
1249 Compress::Raw::Zlib::deflateStream s
1251 RETVAL = s->last_error ;
1257 Compress::Raw::Zlib::deflateStream s
1265 Compress::Raw::Zlib::deflateStream s
1267 RETVAL = s->dict_adler ;
1273 Compress::Raw::Zlib::deflateStream s
1275 RETVAL = s->adler32 ;
1281 Compress::Raw::Zlib::deflateStream s
1283 RETVAL = s->compressedBytes;
1288 uncompressedBytes(s)
1289 Compress::Raw::Zlib::deflateStream s
1291 RETVAL = s->uncompressedBytes;
1297 Compress::Raw::Zlib::deflateStream s
1299 RETVAL = s->stream.total_in ;
1305 Compress::Raw::Zlib::deflateStream s
1307 RETVAL = s->stream.total_out ;
1313 Compress::Raw::Zlib::deflateStream s
1315 RETVAL = s->stream.msg;
1320 deflateTune(s, good_length, max_lazy, nice_length, max_chain)
1321 Compress::Raw::Zlib::deflateStream s
1327 #ifndef AT_LEAST_ZLIB_1_2_2_3
1328 good_length = good_length; max_lazy = max_lazy ; /* Silence -Wall */
1329 nice_length = nice_length; max_chain = max_chain; /* Silence -Wall */
1330 croak("deflateTune needs zlib 1.2.2.3 or better");
1332 RETVAL = deflateTune(&(s->stream), good_length, max_lazy, nice_length, max_chain);
1338 MODULE = Compress::Raw::Zlib PACKAGE = Compress::Raw::Zlib::inflateStream
1341 DispStream(s, message=NULL)
1342 Compress::Raw::Zlib::inflateStream s
1343 const char * message
1347 Compress::Raw::Zlib::inflateStream s
1349 RETVAL = inflateReset(&(s->stream)) ;
1350 if (RETVAL == Z_OK) {
1351 PostInitStream(s, s->flags, s->bufsize, s->WindowBits) ;
1357 inflate (s, buf, output, eof=FALSE)
1358 Compress::Raw::Zlib::inflateStream s
1362 uInt cur_length = 0;
1363 uInt prefix_length = 0;
1365 uLong bufinc = NO_INIT
1366 STRLEN na = NO_INIT ;
1368 #ifdef UTF8_AVAILABLE
1369 bool out_utf8 = FALSE;
1373 bufinc = s->bufsize;
1374 /* If the buffer is a reference, dereference it */
1375 buf = deRef(buf, "inflate") ;
1377 if (s->flags & FLAG_CONSUME_INPUT) {
1378 if (SvREADONLY(buf))
1379 croak("Compress::Raw::Zlib::Inflate::inflate input parameter cannot be read-only when ConsumeInput is specified");
1380 SvPV_force(buf, na);
1382 #ifdef UTF8_AVAILABLE
1383 if (DO_UTF8(buf) && !sv_utf8_downgrade(buf, 1))
1384 croak("Wide character in Compress::Raw::Zlib::Inflate::inflate input parameter");
1387 /* initialise the input buffer */
1388 s->stream.next_in = (Bytef*)SvPV_nomg(buf, origlen) ;
1389 s->stream.avail_in = origlen ;
1391 /* and retrieve the output buffer */
1392 output = deRef_l(output, "inflate") ;
1393 #ifdef UTF8_AVAILABLE
1394 if (DO_UTF8(output))
1396 if (DO_UTF8(output) && !sv_utf8_downgrade(output, 1))
1397 croak("Wide character in Compress::Raw::Zlib::Inflate::inflate output parameter");
1399 if((s->flags & FLAG_APPEND) != FLAG_APPEND) {
1400 SvCUR_set(output, 0);
1403 /* Assume no output buffer - the code below will update if there is any available */
1404 s->stream.avail_out = 0;
1407 if (SvLEN(output)) {
1408 prefix_length = cur_length = SvCUR(output) ;
1410 if (s->flags & FLAG_LIMIT_OUTPUT && SvLEN(output) - cur_length - 1 < bufinc)
1412 Sv_Grow(output, bufinc + cur_length + 1) ;
1415 /* Only setup the stream output pointers if there is spare
1416 capacity in the outout SV
1418 if (SvLEN(output) > cur_length + 1)
1420 s->stream.next_out = (Bytef*) SvPV_nomg_nolen(output) + cur_length;
1421 increment = SvLEN(output) - cur_length - 1;
1422 s->stream.avail_out = increment;
1427 s->bytesInflated = 0;
1431 while (RETVAL == Z_OK) {
1432 if (s->stream.avail_out == 0) {
1433 /* out of space in the output buffer so make it bigger */
1434 s->stream.next_out = (Bytef*) Sv_Grow(output, SvLEN(output) + bufinc +1) ;
1435 cur_length += increment ;
1436 s->stream.next_out += cur_length ;
1437 increment = bufinc ;
1438 s->stream.avail_out = increment;
1442 /* printf("INFLATE Availl In %d, Out %d\n", s->stream.avail_in,
1443 s->stream.avail_out);
1444 DispStream(s, "BEFORE");
1445 Perl_sv_dump(output); */
1446 RETVAL = inflate(&(s->stream), Z_SYNC_FLUSH);
1447 /* printf("INFLATE returned %d %s, avail in %d, out %d\n", RETVAL,
1448 GetErrorString(RETVAL), s->stream.avail_in, s->stream.avail_out); */
1451 if (RETVAL == Z_NEED_DICT && s->dictionary) {
1453 const Bytef* b = (const Bytef*)SvPV(s->dictionary, dlen) ;
1454 s->dict_adler = s->stream.adler ;
1455 RETVAL = inflateSetDictionary(&(s->stream),
1461 if (s->flags & FLAG_LIMIT_OUTPUT &&
1462 (RETVAL == Z_OK || RETVAL == Z_BUF_ERROR )) {
1463 if (s->stream.avail_out == 0)
1464 RETVAL = Z_BUF_ERROR;
1467 if (s->flags & FLAG_LIMIT_OUTPUT &&
1468 (RETVAL == Z_OK || RETVAL == Z_BUF_ERROR ))
1471 if (RETVAL == Z_STREAM_ERROR || RETVAL == Z_MEM_ERROR ||
1472 RETVAL == Z_DATA_ERROR || RETVAL == Z_STREAM_END )
1475 if (RETVAL == Z_BUF_ERROR) {
1476 if (s->stream.avail_out == 0)
1478 if (s->stream.avail_in == 0) {
1484 #ifdef NEED_DUMMY_BYTE_AT_END
1485 if (eof && RETVAL == Z_OK && s->flags & FLAG_LIMIT_OUTPUT == 0) {
1486 Bytef* nextIn = s->stream.next_in;
1487 uInt availIn = s->stream.avail_in;
1488 s->stream.next_in = (Bytef*) " ";
1489 s->stream.avail_in = 1;
1490 if (s->stream.avail_out == 0) {
1491 /* out of space in the output buffer so make it bigger */
1492 s->stream.next_out = Sv_Grow(output, SvLEN(output) + bufinc) ;
1493 cur_length += increment ;
1494 s->stream.next_out += cur_length ;
1495 increment = bufinc ;
1496 s->stream.avail_out = increment;
1499 RETVAL = inflate(&(s->stream), Z_SYNC_FLUSH);
1500 s->stream.next_in = nextIn ;
1501 s->stream.avail_in = availIn ;
1505 s->last_error = RETVAL ;
1506 if (RETVAL == Z_OK || RETVAL == Z_STREAM_END || RETVAL == Z_BUF_ERROR || RETVAL == Z_DATA_ERROR) {
1509 s->bytesInflated = cur_length + increment - s->stream.avail_out - prefix_length;
1510 s->uncompressedBytes += s->bytesInflated ;
1511 s->compressedBytes += origlen - s->stream.avail_in ;
1514 SvCUR_set(output, prefix_length + s->bytesInflated) ;
1515 *SvEND(output) = '\0';
1516 #ifdef UTF8_AVAILABLE
1518 sv_utf8_upgrade(output);
1522 if (s->flags & FLAG_CRC32 )
1523 s->crc32 = crc32(s->crc32,
1524 (const Bytef*)SvPVX(output)+prefix_length,
1525 SvCUR(output)-prefix_length) ;
1527 if (s->flags & FLAG_ADLER32)
1528 s->adler32 = adler32(s->adler32,
1529 (const Bytef*)SvPVX(output)+prefix_length,
1530 SvCUR(output)-prefix_length) ;
1532 /* fix the input buffer */
1533 if (s->flags & FLAG_CONSUME_INPUT || s->flags & FLAG_LIMIT_OUTPUT) {
1534 in = s->stream.avail_in ;
1535 SvCUR_set(buf, in) ;
1537 Move(s->stream.next_in, SvPVX(buf), in, char) ;
1548 Compress::Raw::Zlib::inflateStream s
1550 RETVAL = s->bytesInflated;
1556 Compress::Raw::Zlib::inflateStream s
1558 RETVAL = s->compressedBytes;
1563 uncompressedBytes(s)
1564 Compress::Raw::Zlib::inflateStream s
1566 RETVAL = s->uncompressedBytes;
1572 inflateSync (s, buf)
1573 Compress::Raw::Zlib::inflateStream s
1577 /* If the buffer is a reference, dereference it */
1578 buf = deRef(buf, "inflateSync") ;
1579 #ifdef UTF8_AVAILABLE
1580 if (DO_UTF8(buf) && !sv_utf8_downgrade(buf, 1))
1581 croak("Wide character in Compress::Raw::Zlib::Inflate::inflateSync");
1584 /* initialise the input buffer */
1585 s->stream.next_in = (Bytef*)SvPV_force_nomg_nolen(buf) ;
1586 s->stream.avail_in = SvCUR(buf) ;
1588 /* inflateSync doesn't create any output */
1589 s->stream.next_out = (Bytef*) NULL;
1590 s->stream.avail_out = 0;
1592 RETVAL = inflateSync(&(s->stream));
1593 s->last_error = RETVAL ;
1595 /* fix the input buffer */
1597 unsigned in = s->stream.avail_in ;
1598 SvCUR_set(buf, in) ;
1600 Move(s->stream.next_in, SvPVX(buf), in, char) ;
1609 Compress::Raw::Zlib::inflateStream s
1611 inflateEnd(&s->stream) ;
1613 SvREFCNT_dec(s->dictionary) ;
1615 if (s->deflateParams_out_buffer)
1616 Safefree(s->deflateParams_out_buffer);
1620 Safefree(s->window);
1627 Compress::Raw::Zlib::inflateStream s
1629 RETVAL = s->last_error ;
1635 Compress::Raw::Zlib::inflateStream s
1643 Compress::Raw::Zlib::inflateStream s
1645 RETVAL = s->dict_adler ;
1651 Compress::Raw::Zlib::inflateStream s
1653 RETVAL = s->stream.total_in ;
1659 Compress::Raw::Zlib::inflateStream s
1661 RETVAL = s->adler32 ;
1667 Compress::Raw::Zlib::inflateStream s
1669 RETVAL = s->stream.total_out ;
1675 Compress::Raw::Zlib::inflateStream s
1677 RETVAL = s->stream.msg;
1684 Compress::Raw::Zlib::inflateStream s
1686 RETVAL = s->bufsize ;
1692 Compress::Raw::Zlib::inflateStream s
1695 RETVAL = ((s->flags & FLAG_APPEND) == FLAG_APPEND);
1697 s->flags |= FLAG_APPEND ;
1699 s->flags &= ~FLAG_APPEND ;
1703 MODULE = Compress::Raw::Zlib PACKAGE = Compress::Raw::Zlib::inflateScanStream
1707 Compress::Raw::Zlib::inflateScanStream s
1709 inflateEnd(&s->stream) ;
1711 SvREFCNT_dec(s->dictionary) ;
1713 if (s->deflateParams_out_buffer)
1714 Safefree(s->deflateParams_out_buffer);
1718 Safefree(s->window);
1723 DispStream(s, message=NULL)
1724 Compress::Raw::Zlib::inflateScanStream s
1725 const char * message
1729 Compress::Raw::Zlib::inflateScanStream s
1731 RETVAL = inflateReset(&(s->stream)) ;
1732 if (RETVAL == Z_OK) {
1733 PostInitStream(s, s->flags, s->bufsize, s->WindowBits) ;
1739 scan(s, buf, out=NULL, eof=FALSE)
1740 Compress::Raw::Zlib::inflateScanStream s
1744 bool eof_mode = FALSE;
1745 int start_len = NO_INIT
1747 /* If the input buffer is a reference, dereference it */
1748 #ifndef MAGIC_APPEND
1750 croak("scan needs zlib 1.2.1 or better");
1752 buf = deRef(buf, "inflateScan") ;
1753 #ifdef UTF8_AVAILABLE
1754 if (DO_UTF8(buf) && !sv_utf8_downgrade(buf, 1))
1755 croak("Wide character in Compress::Raw::Zlib::InflateScan::scan input parameter");
1757 /* initialise the input buffer */
1758 s->stream.next_in = (Bytef*)SvPV_nomg_nolen(buf) ;
1759 s->stream.avail_in = SvCUR(buf) ;
1760 start_len = s->stream.avail_in ;
1761 s->bytesInflated = 0 ;
1764 if (s->stream.avail_in == 0) {
1769 /* set up output to next available section of sliding window */
1770 s->stream.avail_out = WINDOW_SIZE - s->window_have;
1771 s->stream.next_out = s->window + s->window_have;
1773 /* DispStream(s, "before inflate\n"); */
1775 /* inflate and check for errors */
1776 RETVAL = inflate(&(s->stream), Z_BLOCK);
1778 if (start_len > 1 && ! eof_mode)
1779 s->window_lastByte = *(s->stream.next_in - 1 ) ;
1781 if (RETVAL == Z_STREAM_ERROR || RETVAL == Z_MEM_ERROR ||
1782 RETVAL == Z_DATA_ERROR )
1785 if (s->flags & FLAG_CRC32 )
1786 s->crc32 = crc32(s->crc32, s->window + s->window_have,
1787 WINDOW_SIZE - s->window_have - s->stream.avail_out);
1789 if (s->flags & FLAG_ADLER32)
1790 s->adler32 = adler32(s->adler32, s->window + s->window_have,
1791 WINDOW_SIZE - s->window_have - s->stream.avail_out);
1793 s->uncompressedBytes =
1794 s->bytesInflated += WINDOW_SIZE - s->window_have - s->stream.avail_out;
1796 if (s->stream.avail_out)
1797 s->window_have = WINDOW_SIZE - s->stream.avail_out;
1803 /* process end of block */
1804 if (s->stream.data_type & 128) {
1805 if (s->stream.data_type & 64) {
1806 s->window_left = s->stream.data_type & 0x1f;
1809 s->window_lastbit = s->stream.data_type & 0x1f;
1810 s->lastBlockOffset = s->stream.total_in;
1814 } while (RETVAL != Z_STREAM_END);
1816 s->last_error = RETVAL ;
1817 s->window_lastoff = s->stream.total_in ;
1818 s->compressedBytes += SvCUR(buf) - s->stream.avail_in ;
1820 if (RETVAL == Z_STREAM_END)
1822 s->matchedEndBlock = 1 ;
1824 /* save the location of the end of the compressed data */
1825 s->window_end = SvCUR(buf) - s->stream.avail_in - 1 ;
1826 s->window_endOffset = s->stream.total_in ;
1829 -- s->window_endOffset ;
1832 /* if window wrapped, build dictionary from window by rotating */
1833 if (s->window_full) {
1834 rotate(s->window, WINDOW_SIZE, s->window_have);
1835 s->window_have = WINDOW_SIZE;
1838 /* if (s->flags & FLAG_CONSUME_INPUT) { */
1840 unsigned in = s->stream.avail_in ;
1841 SvCUR_set(buf, in) ;
1843 Move(s->stream.next_in, SvPVX(buf), in, char) ;
1855 Compress::Raw::Zlib::inflateScanStream s
1857 #ifndef MAGIC_APPEND
1858 croak("getEndOffset needs zlib 1.2.1 or better");
1860 RETVAL = s->window_endOffset;
1867 Compress::Raw::Zlib::inflateScanStream s
1869 #ifndef MAGIC_APPEND
1870 croak("inflateCount needs zlib 1.2.1 or better");
1872 RETVAL = s->bytesInflated;
1879 Compress::Raw::Zlib::inflateScanStream s
1881 RETVAL = s->compressedBytes;
1886 uncompressedBytes(s)
1887 Compress::Raw::Zlib::inflateScanStream s
1889 RETVAL = s->uncompressedBytes;
1895 getLastBlockOffset(s)
1896 Compress::Raw::Zlib::inflateScanStream s
1898 #ifndef MAGIC_APPEND
1899 croak("getLastBlockOffset needs zlib 1.2.1 or better");
1901 RETVAL = s->lastBlockOffset - (s->window_lastbit != 0);
1907 getLastBufferOffset(s)
1908 Compress::Raw::Zlib::inflateScanStream s
1910 #ifndef MAGIC_APPEND
1911 croak("getLastBufferOffset needs zlib 1.2.1 or better");
1913 RETVAL = s->window_lastoff;
1919 resetLastBlockByte(s, byte)
1920 Compress::Raw::Zlib::inflateScanStream s
1923 #ifndef MAGIC_APPEND
1924 croak("resetLastBlockByte needs zlib 1.2.1 or better");
1927 *byte = *byte ^ (1 << ((8 - s->window_lastbit) & 7));
1932 _createDeflateStream(inf_s, flags,level, method, windowBits, memLevel, strategy, bufsize)
1933 Compress::Raw::Zlib::inflateScanStream inf_s
1943 #ifndef MAGIC_APPEND
1947 windowBits = windowBits;
1948 memLevel = memLevel;
1949 strategy = strategy;
1951 croak("_createDeflateStream needs zlib 1.2.1 or better");
1957 warn("in _createDeflateStream(level=%d, method=%d, windowBits=%d, memLevel=%d, strategy=%d, bufsize=%lu\n",
1958 level, method, windowBits, memLevel, strategy, bufsize) ;
1959 if ((s = InitStream() )) {
1963 s->WindowBits = windowBits;
1964 s->MemLevel = memLevel;
1965 s->Strategy = strategy;
1967 err = deflateInit2(&(s->stream), level,
1968 method, windowBits, memLevel, strategy);
1971 err = deflateSetDictionary(&(s->stream), inf_s->window, inf_s->window_have);
1972 s->dict_adler = s->stream.adler ;
1980 PostInitStream(s, flags, bufsize, windowBits) ;
1981 s->crc32 = inf_s->crc32;
1982 s->adler32 = inf_s->adler32;
1983 s->stream.adler = inf_s->stream.adler ;
1984 /* s->stream.total_out = inf_s->bytesInflated ; */
1985 s->stream.total_in = inf_s->stream.total_out ;
1986 if (inf_s->window_left) {
1987 /* printf("** window_left %d, window_lastByte %d\n", inf_s->window_left, inf_s->window_lastByte); */
1988 deflatePrime(&(s->stream), 8 - inf_s->window_left, inf_s->window_lastByte);
1995 XPUSHs(sv_setref_pv(sv_newmortal(),
1996 "Compress::Raw::Zlib::deflateStream", (void*)s));
1997 if (GIMME == G_ARRAY) {
1998 SV * sv = sv_2mortal(newSViv(err)) ;
1999 setDUALstatus(sv, err);
2007 Compress::Raw::Zlib::inflateScanStream s
2009 RETVAL = s->last_error ;
2015 Compress::Raw::Zlib::inflateScanStream s
2024 Compress::Raw::Zlib::inflateScanStream s
2026 RETVAL = s->adler32 ;