1 /* zlibmodule.c -- gzip-compatible data compression */
2 /* See http://www.cdrom.com/pub/infozip/zlib/ */
3 /* See http://www.winimage.com/zLibDll for Windows */
11 /* The following parameters are copied from zutil.h, version 0.95 */
13 #if MAX_MEM_LEVEL >= 8
14 # define DEF_MEM_LEVEL 8
16 # define DEF_MEM_LEVEL MAX_MEM_LEVEL
18 #define DEF_WBITS MAX_WBITS
20 /* The output buffer will be increased in chunks of DEFAULTALLOC bytes. */
21 #define DEFAULTALLOC (16*1024)
22 #define PyInit_zlib initzlib
24 staticforward PyTypeObject Comptype
;
25 staticforward PyTypeObject Decomptype
;
27 static PyObject
*ZlibError
;
33 PyObject
*unused_data
;
37 static char compressobj__doc__
[] =
38 "compressobj() -- Return a compressor object.\n"
39 "compressobj(level) -- Return a compressor object, using the given compression level.\n"
42 static char decompressobj__doc__
[] =
43 "decompressobj() -- Return a decompressor object.\n"
44 "decompressobj(wbits) -- Return a decompressor object, setting the window buffer size to wbits.\n"
52 self
= PyObject_NEW(compobject
, type
);
55 self
->is_initialised
= 0;
56 self
->unused_data
= PyString_FromString("");
60 static char compress__doc__
[] =
61 "compress(string) -- Compress string using the default compression level, "
62 "returning a string containing compressed data.\n"
63 "compress(string, level) -- Compress string, using the chosen compression "
64 "level (from 1 to 9). Return a string containing the compressed data.\n"
68 PyZlib_compress(self
, args
)
74 int length
, level
=Z_DEFAULT_COMPRESSION
, err
;
77 if (!PyArg_ParseTuple(args
, "s#|i", &input
, &length
, &level
))
79 zst
.avail_out
= length
+ length
/1000 + 12 + 1;
80 output
=(Byte
*)malloc(zst
.avail_out
);
83 PyErr_SetString(PyExc_MemoryError
,
84 "Can't allocate memory to compress data");
88 zst
.zalloc
=(alloc_func
)NULL
;
89 zst
.zfree
=(free_func
)Z_NULL
;
90 zst
.next_out
=(Byte
*)output
;
91 zst
.next_in
=(Byte
*)input
;
93 err
=deflateInit(&zst
, level
);
99 PyErr_SetString(PyExc_MemoryError
,
100 "Out of memory while compressing data");
103 case(Z_STREAM_ERROR
):
104 PyErr_SetString(ZlibError
,
105 "Bad compression level");
110 if (zst
.msg
== Z_NULL
)
111 PyErr_Format(ZlibError
, "Error %i while compressing data",
114 PyErr_Format(ZlibError
, "Error %i while compressing data: %.200s",
122 err
=deflate(&zst
, Z_FINISH
);
127 /* Are there other errors to be trapped here? */
130 if (zst
.msg
== Z_NULL
)
131 PyErr_Format(ZlibError
, "Error %i while compressing data",
134 PyErr_Format(ZlibError
, "Error %i while compressing data: %.200s",
141 err
=deflateEnd(&zst
);
144 if (zst
.msg
== Z_NULL
)
145 PyErr_Format(ZlibError
, "Error %i while finishing compression",
148 PyErr_Format(ZlibError
,
149 "Error %i while finishing compression: %.200s",
154 ReturnVal
=PyString_FromStringAndSize((char *)output
, zst
.total_out
);
159 static char decompress__doc__
[] =
160 "decompress(string) -- Decompress the data in string, returning a string containing the decompressed data.\n"
161 "decompress(string, wbits) -- Decompress the data in string with a window buffer size of wbits.\n"
162 "decompress(string, wbits, bufsize) -- Decompress the data in string with a window buffer size of wbits and an initial output buffer size of bufsize.\n"
166 PyZlib_decompress(self
, args
)
170 PyObject
*result_str
;
173 int wsize
=DEF_WBITS
, r_strlen
=DEFAULTALLOC
;
175 if (!PyArg_ParseTuple(args
, "s#|ii", &input
, &length
, &wsize
, &r_strlen
))
182 zst
.avail_out
=r_strlen
;
183 if (!(result_str
= PyString_FromStringAndSize(NULL
, r_strlen
)))
185 PyErr_SetString(PyExc_MemoryError
,
186 "Can't allocate memory to decompress data");
189 zst
.zalloc
=(alloc_func
)NULL
;
190 zst
.zfree
=(free_func
)Z_NULL
;
191 zst
.next_out
=(Byte
*)PyString_AsString(result_str
);
192 zst
.next_in
=(Byte
*)input
;
193 err
=inflateInit2(&zst
, wsize
);
199 PyErr_SetString(PyExc_MemoryError
,
200 "Out of memory while decompressing data");
201 Py_DECREF(result_str
);
205 if (zst
.msg
== Z_NULL
)
206 PyErr_Format(ZlibError
, "Error %i preparing to decompress data",
209 PyErr_Format(ZlibError
,
210 "Error %i while preparing to decompress data: %.200s",
213 Py_DECREF(result_str
);
219 err
=inflate(&zst
, Z_FINISH
);
226 /* need more memory */
227 if (_PyString_Resize(&result_str
, r_strlen
<< 1) == -1)
229 PyErr_SetString(PyExc_MemoryError
,
230 "Out of memory while decompressing data");
234 zst
.next_out
= (unsigned char *)PyString_AsString(result_str
) + r_strlen
;
235 zst
.avail_out
=r_strlen
;
236 r_strlen
= r_strlen
<< 1;
240 if (zst
.msg
== Z_NULL
)
241 PyErr_Format(ZlibError
, "Error %i while decompressing data",
244 PyErr_Format(ZlibError
,
245 "Error %i while decompressing data: %.200s",
248 Py_DECREF(result_str
);
252 } while(err
!=Z_STREAM_END
);
254 err
=inflateEnd(&zst
);
257 if (zst
.msg
== Z_NULL
)
258 PyErr_Format(ZlibError
,
259 "Error %i while finishing data decompression",
262 PyErr_Format(ZlibError
,
263 "Error %i while finishing data decompression: %.200s",
265 Py_DECREF(result_str
);
268 _PyString_Resize(&result_str
, zst
.total_out
);
273 PyZlib_compressobj(selfptr
, args
)
278 int level
=Z_DEFAULT_COMPRESSION
, method
=DEFLATED
;
279 int wbits
=MAX_WBITS
, memLevel
=DEF_MEM_LEVEL
, strategy
=0, err
;
281 if (!PyArg_ParseTuple(args
, "|iiiii", &level
, &method
, &wbits
,
282 &memLevel
, &strategy
))
285 self
= newcompobject(&Comptype
);
286 if (self
==NULL
) return(NULL
);
287 self
->zst
.zalloc
= (alloc_func
)NULL
;
288 self
->zst
.zfree
= (free_func
)Z_NULL
;
289 err
= deflateInit2(&self
->zst
, level
, method
, wbits
, memLevel
, strategy
);
293 self
->is_initialised
= 1;
294 return (PyObject
*)self
;
297 PyErr_SetString(PyExc_MemoryError
,
298 "Can't allocate memory for compression object");
300 case(Z_STREAM_ERROR
):
302 PyErr_SetString(PyExc_ValueError
,
303 "Invalid initialization option");
307 if (self
->zst
.msg
== Z_NULL
)
308 PyErr_Format(ZlibError
,
309 "Error %i while creating compression object",
312 PyErr_Format(ZlibError
,
313 "Error %i while creating compression object: %.200s",
322 PyZlib_decompressobj(selfptr
, args
)
326 int wbits
=DEF_WBITS
, err
;
328 if (!PyArg_ParseTuple(args
, "|i", &wbits
))
332 self
=newcompobject(&Decomptype
);
333 if (self
==NULL
) return(NULL
);
334 self
->zst
.zalloc
=(alloc_func
)NULL
;
335 self
->zst
.zfree
=(free_func
)Z_NULL
;
336 err
=inflateInit2(&self
->zst
, wbits
);
340 self
->is_initialised
= 1;
341 return (PyObject
*)self
;
342 case(Z_STREAM_ERROR
):
344 PyErr_SetString(PyExc_ValueError
,
345 "Invalid initialization option");
349 PyErr_SetString(PyExc_MemoryError
,
350 "Can't allocate memory for decompression object");
354 if (self
->zst
.msg
== Z_NULL
)
355 PyErr_Format(ZlibError
,
356 "Error %i while creating decompression object",
359 PyErr_Format(ZlibError
,
360 "Error %i while creating decompression object: %.200s",
372 if (self
->is_initialised
)
373 deflateEnd(&self
->zst
);
374 Py_XDECREF(self
->unused_data
);
382 inflateEnd(&self
->zst
);
383 Py_XDECREF(self
->unused_data
);
387 static char comp_compress__doc__
[] =
388 "compress(data) -- Return a string containing a compressed version of the data.\n\n"
389 "After calling this function, some of the input data may still\n"
390 "be stored in internal buffers for later processing.\n"
391 "Call the flush() method to clear these buffers."
396 PyZlib_objcompress(self
, args
)
400 int err
= Z_OK
, inplen
;
401 int length
= DEFAULTALLOC
;
404 unsigned long start_total_out
;
406 if (!PyArg_ParseTuple(args
, "s#", &input
, &inplen
))
408 self
->zst
.avail_in
= inplen
;
409 self
->zst
.next_in
= input
;
410 if (!(RetVal
= PyString_FromStringAndSize(NULL
, length
))) {
411 PyErr_SetString(PyExc_MemoryError
,
412 "Can't allocate memory to compress data");
415 start_total_out
= self
->zst
.total_out
;
416 self
->zst
.next_out
= (unsigned char *)PyString_AsString(RetVal
);
417 self
->zst
.avail_out
= length
;
418 while (self
->zst
.avail_in
!= 0 && err
== Z_OK
)
420 err
= deflate(&(self
->zst
), Z_NO_FLUSH
);
421 if (self
->zst
.avail_out
<= 0) {
422 if (_PyString_Resize(&RetVal
, length
<< 1) == -1) {
423 PyErr_SetString(PyExc_MemoryError
,
424 "Can't allocate memory to compress data");
427 self
->zst
.next_out
= (unsigned char *)PyString_AsString(RetVal
) + length
;
428 self
->zst
.avail_out
= length
;
429 length
= length
<< 1;
434 if (self
->zst
.msg
== Z_NULL
)
435 PyErr_Format(ZlibError
, "Error %i while compressing",
438 PyErr_Format(ZlibError
, "Error %i while compressing: %.200s",
443 _PyString_Resize(&RetVal
, self
->zst
.total_out
- start_total_out
);
447 static char decomp_decompress__doc__
[] =
448 "decompress(data) -- Return a string containing the decompressed version of the data.\n\n"
449 "After calling this function, some of the input data may still\n"
450 "be stored in internal buffers for later processing.\n"
451 "Call the flush() method to clear these buffers."
455 PyZlib_objdecompress(self
, args
)
459 int length
, err
, inplen
;
462 unsigned long start_total_out
;
464 if (!PyArg_ParseTuple(args
, "s#", &input
, &inplen
))
466 start_total_out
= self
->zst
.total_out
;
467 RetVal
= PyString_FromStringAndSize(NULL
, DEFAULTALLOC
);
468 self
->zst
.avail_in
= inplen
;
469 self
->zst
.next_in
= input
;
470 self
->zst
.avail_out
= length
= DEFAULTALLOC
;
471 self
->zst
.next_out
= (unsigned char *)PyString_AsString(RetVal
);
474 while (self
->zst
.avail_in
!= 0 && err
== Z_OK
)
476 err
= inflate(&(self
->zst
), Z_NO_FLUSH
);
477 if (err
== Z_OK
&& self
->zst
.avail_out
<= 0)
479 if (_PyString_Resize(&RetVal
, length
<< 1) == -1)
481 PyErr_SetString(PyExc_MemoryError
,
482 "Can't allocate memory to compress data");
485 self
->zst
.next_out
= (unsigned char *)PyString_AsString(RetVal
) + length
;
486 self
->zst
.avail_out
= length
;
487 length
= length
<< 1;
491 if (err
!= Z_OK
&& err
!= Z_STREAM_END
)
493 if (self
->zst
.msg
== Z_NULL
)
494 PyErr_Format(ZlibError
, "Error %i while decompressing",
497 PyErr_Format(ZlibError
, "Error %i while decompressing: %.200s",
503 if (err
== Z_STREAM_END
)
505 /* The end of the compressed data has been reached, so set
506 the unused_data attribute to a string containing the
507 remainder of the data in the string. */
508 int pos
= self
->zst
.next_in
- input
; /* Position in the string */
509 Py_XDECREF(self
->unused_data
); /* Free the original, empty string */
511 self
->unused_data
= PyString_FromStringAndSize((char *)input
+pos
,
513 if (self
->unused_data
== NULL
) return NULL
;
516 _PyString_Resize(&RetVal
, self
->zst
.total_out
- start_total_out
);
520 static char comp_flush__doc__
[] =
521 "flush( [mode] ) -- Return a string containing any remaining compressed data.\n"
522 "mode can be one of the constants Z_SYNC_FLUSH, Z_FULL_FLUSH, Z_FINISH; the \n"
523 "default value used when mode is not specified is Z_FINISH.\n"
524 "If mode == Z_FINISH, the compressor object can no longer be used after\n"
525 "calling the flush() method. Otherwise, more data can still be compressed.\n"
529 PyZlib_flush(self
, args
)
533 int length
=DEFAULTALLOC
, err
= Z_OK
;
535 int flushmode
= Z_FINISH
;
536 unsigned long start_total_out
;
538 if (!PyArg_ParseTuple(args
, "|i", &flushmode
))
541 /* Flushing with Z_NO_FLUSH is a no-op, so there's no point in
542 doing any work at all; just return an empty string. */
543 if (flushmode
== Z_NO_FLUSH
)
545 return PyString_FromStringAndSize(NULL
, 0);
548 self
->zst
.avail_in
= 0;
549 self
->zst
.next_in
= Z_NULL
;
550 if (!(RetVal
= PyString_FromStringAndSize(NULL
, length
))) {
551 PyErr_SetString(PyExc_MemoryError
,
552 "Can't allocate memory to compress data");
555 start_total_out
= self
->zst
.total_out
;
556 self
->zst
.next_out
= (unsigned char *)PyString_AsString(RetVal
);
557 self
->zst
.avail_out
= length
;
559 /* When flushing the zstream, there's no input data.
560 If zst.avail_out == 0, that means that more output space is
561 needed to complete the flush operation. */
563 err
= deflate(&(self
->zst
), flushmode
);
565 /* If the output is Z_OK, and there's still room in the output
566 buffer, then the flush is complete. */
567 if ( (err
== Z_OK
) && self
->zst
.avail_out
> 0) break;
569 /* A nonzero return indicates some sort of error (but see
570 the comment for the error handler below) */
571 if ( err
!= Z_OK
) break;
573 /* There's no space left for output, so increase the buffer and loop
575 if (_PyString_Resize(&RetVal
, length
<< 1) == -1) {
576 PyErr_SetString(PyExc_MemoryError
,
577 "Can't allocate memory to compress data");
580 self
->zst
.next_out
= (unsigned char *)PyString_AsString(RetVal
) + length
;
581 self
->zst
.avail_out
= length
;
582 length
= length
<< 1;
585 /* Raise an exception indicating an error. The condition for
586 detecting a error is kind of complicated; Z_OK indicates no
587 error, but if the flushmode is Z_FINISH, then Z_STREAM_END is
588 also not an error. */
589 if (err
!=Z_OK
&& !(flushmode
== Z_FINISH
&& err
== Z_STREAM_END
) )
591 if (self
->zst
.msg
== Z_NULL
)
592 PyErr_Format(ZlibError
, "Error %i while flushing",
595 PyErr_Format(ZlibError
, "Error %i while flushing: %.200s",
601 /* If flushmode is Z_FINISH, we also have to call deflateEnd() to
602 free various data structures */
604 if (flushmode
== Z_FINISH
) {
605 err
=deflateEnd(&(self
->zst
));
607 if (self
->zst
.msg
== Z_NULL
)
608 PyErr_Format(ZlibError
, "Error %i from deflateEnd()",
611 PyErr_Format(ZlibError
,
612 "Error %i from deflateEnd(): %.200s",
618 _PyString_Resize(&RetVal
, self
->zst
.total_out
- start_total_out
);
622 static char decomp_flush__doc__
[] =
623 "flush() -- Return a string containing any remaining decompressed data. "
624 "The decompressor object can no longer be used after this call."
628 PyZlib_unflush(self
, args
)
635 if (!PyArg_NoArgs(args
))
637 if (!(RetVal
= PyString_FromStringAndSize(NULL
, DEFAULTALLOC
)))
639 PyErr_SetString(PyExc_MemoryError
,
640 "Can't allocate memory to decompress data");
643 self
->zst
.avail_in
=0;
644 self
->zst
.next_out
= (unsigned char *)PyString_AsString(RetVal
);
645 length
= self
->zst
.avail_out
= DEFAULTALLOC
;
647 /* I suspect that Z_BUF_ERROR is the only error code we need to check for
648 in the following loop, but will leave the Z_OK in for now to avoid
649 destabilizing this function. --amk */
651 while ( err
== Z_OK
)
653 err
= inflate(&(self
->zst
), Z_FINISH
);
654 if ( ( err
== Z_OK
|| err
== Z_BUF_ERROR
) && self
->zst
.avail_out
== 0)
656 if (_PyString_Resize(&RetVal
, length
<< 1) == -1)
658 PyErr_SetString(PyExc_MemoryError
,
659 "Can't allocate memory to decompress data");
662 self
->zst
.next_out
= (unsigned char *)PyString_AsString(RetVal
) + length
;
663 self
->zst
.avail_out
= length
;
664 length
= length
<< 1;
668 if (err
!=Z_STREAM_END
)
670 if (self
->zst
.msg
== Z_NULL
)
671 PyErr_Format(ZlibError
, "Error %i while decompressing",
674 PyErr_Format(ZlibError
, "Error %i while decompressing: %.200s",
679 err
=inflateEnd(&(self
->zst
));
682 if (self
->zst
.msg
== Z_NULL
)
683 PyErr_Format(ZlibError
,
684 "Error %i while flushing decompression object",
687 PyErr_Format(ZlibError
,
688 "Error %i while flushing decompression object: %.200s",
693 _PyString_Resize(&RetVal
,
694 (char *)self
->zst
.next_out
- PyString_AsString(RetVal
));
698 static PyMethodDef comp_methods
[] =
700 {"compress", (binaryfunc
)PyZlib_objcompress
, 1, comp_compress__doc__
},
701 {"flush", (binaryfunc
)PyZlib_flush
, 1, comp_flush__doc__
},
705 static PyMethodDef Decomp_methods
[] =
707 {"decompress", (binaryfunc
)PyZlib_objdecompress
, 1, decomp_decompress__doc__
},
708 {"flush", (binaryfunc
)PyZlib_unflush
, 0, decomp_flush__doc__
},
713 Comp_getattr(self
, name
)
717 return Py_FindMethod(comp_methods
, (PyObject
*)self
, name
);
721 Decomp_getattr(self
, name
)
725 if (strcmp(name
, "unused_data") == 0)
727 Py_INCREF(self
->unused_data
);
728 return self
->unused_data
;
730 return Py_FindMethod(Decomp_methods
, (PyObject
*)self
, name
);
733 static char adler32__doc__
[] =
734 "adler32(string) -- Compute an Adler-32 checksum of string, using "
735 "a default starting value, and returning an integer value.\n"
736 "adler32(string, value) -- Compute an Adler-32 checksum of string, using "
737 "the starting value provided, and returning an integer value\n"
741 PyZlib_adler32(self
, args
)
742 PyObject
*self
, *args
;
744 uLong adler32val
=adler32(0L, Z_NULL
, 0);
748 if (!PyArg_ParseTuple(args
, "s#|l", &buf
, &len
, &adler32val
))
752 adler32val
= adler32(adler32val
, buf
, len
);
753 return PyInt_FromLong(adler32val
);
756 static char crc32__doc__
[] =
757 "crc32(string) -- Compute a CRC-32 checksum of string, using "
758 "a default starting value, and returning an integer value.\n"
759 "crc32(string, value) -- Compute a CRC-32 checksum of string, using "
760 "the starting value provided, and returning an integer value.\n"
764 PyZlib_crc32(self
, args
)
765 PyObject
*self
, *args
;
767 uLong crc32val
=crc32(0L, Z_NULL
, 0);
770 if (!PyArg_ParseTuple(args
, "s#|l", &buf
, &len
, &crc32val
))
774 crc32val
= crc32(crc32val
, buf
, len
);
775 return PyInt_FromLong(crc32val
);
779 static PyMethodDef zlib_methods
[] =
781 {"adler32", (PyCFunction
)PyZlib_adler32
, 1, adler32__doc__
},
782 {"compress", (PyCFunction
)PyZlib_compress
, 1, compress__doc__
},
783 {"compressobj", (PyCFunction
)PyZlib_compressobj
, 1, compressobj__doc__
},
784 {"crc32", (PyCFunction
)PyZlib_crc32
, 1, crc32__doc__
},
785 {"decompress", (PyCFunction
)PyZlib_decompress
, 1, decompress__doc__
},
786 {"decompressobj", (PyCFunction
)PyZlib_decompressobj
, 1, decompressobj__doc__
},
790 statichere PyTypeObject Comptype
= {
791 PyObject_HEAD_INIT(0)
796 (destructor
)Comp_dealloc
, /*tp_dealloc*/
798 (getattrfunc
)Comp_getattr
, /*tp_getattr*/
803 0, /*tp_as_sequence*/
807 statichere PyTypeObject Decomptype
= {
808 PyObject_HEAD_INIT(0)
813 (destructor
)Decomp_dealloc
, /*tp_dealloc*/
815 (getattrfunc
)Decomp_getattr
, /*tp_getattr*/
820 0, /*tp_as_sequence*/
824 /* The following insint() routine was blatantly ripped off from
827 /* Convenience routine to export an integer value.
828 For simplicity, errors (which are unlikely anyway) are ignored. */
830 insint(d
, name
, value
)
835 PyObject
*v
= PyInt_FromLong((long) value
);
837 /* Don't bother reporting this error */
841 PyDict_SetItemString(d
, name
, v
);
846 static char zlib_module_documentation
[]=
847 "The functions in this module allow compression and decompression "
848 "using the zlib library, which is based on GNU zip. \n\n"
849 "adler32(string) -- Compute an Adler-32 checksum.\n"
850 "adler32(string, start) -- Compute an Adler-32 checksum using a given starting value.\n"
851 "compress(string) -- Compress a string.\n"
852 "compress(string, level) -- Compress a string with the given level of compression (1--9).\n"
853 "compressobj([level]) -- Return a compressor object.\n"
854 "crc32(string) -- Compute a CRC-32 checksum.\n"
855 "crc32(string, start) -- Compute a CRC-32 checksum using a given starting value.\n"
856 "decompress(string,[wbits],[bufsize]) -- Decompresses a compressed string.\n"
857 "decompressobj([wbits]) -- Return a decompressor object (wbits=window buffer size).\n\n"
858 "Compressor objects support compress() and flush() methods; decompressor \n"
859 "objects support decompress() and flush()."
865 PyObject
*m
, *d
, *ver
;
866 Comptype
.ob_type
= &PyType_Type
;
867 Decomptype
.ob_type
= &PyType_Type
;
868 m
= Py_InitModule4("zlib", zlib_methods
,
869 zlib_module_documentation
,
870 (PyObject
*)NULL
,PYTHON_API_VERSION
);
871 d
= PyModule_GetDict(m
);
872 ZlibError
= PyErr_NewException("zlib.error", NULL
, NULL
);
873 if (ZlibError
!= NULL
)
874 PyDict_SetItemString(d
, "error", ZlibError
);
876 insint(d
, "MAX_WBITS", MAX_WBITS
);
877 insint(d
, "DEFLATED", DEFLATED
);
878 insint(d
, "DEF_MEM_LEVEL", DEF_MEM_LEVEL
);
879 insint(d
, "Z_BEST_SPEED", Z_BEST_SPEED
);
880 insint(d
, "Z_BEST_COMPRESSION", Z_BEST_COMPRESSION
);
881 insint(d
, "Z_DEFAULT_COMPRESSION", Z_DEFAULT_COMPRESSION
);
882 insint(d
, "Z_FILTERED", Z_FILTERED
);
883 insint(d
, "Z_HUFFMAN_ONLY", Z_HUFFMAN_ONLY
);
884 insint(d
, "Z_DEFAULT_STRATEGY", Z_DEFAULT_STRATEGY
);
886 insint(d
, "Z_FINISH", Z_FINISH
);
887 insint(d
, "Z_NO_FLUSH", Z_NO_FLUSH
);
888 insint(d
, "Z_SYNC_FLUSH", Z_SYNC_FLUSH
);
889 insint(d
, "Z_FULL_FLUSH", Z_FULL_FLUSH
);
891 ver
= PyString_FromString(ZLIB_VERSION
);
893 PyDict_SetItemString(d
, "ZLIB_VERSION", ver
);