Lines Matching defs:self

108     compobject *self;

109 self = PyObject_New(compobject, type);
110 if (self == NULL)
112 self->is_initialised = 0;
113 self->unused_data = PyString_FromString("");
114 if (self->unused_data == NULL) {
115 Py_DECREF(self);
118 self->unconsumed_tail = PyString_FromString("");
119 if (self->unconsumed_tail == NULL) {
120 Py_DECREF(self);
123 return self;
132 PyZlib_compress(PyObject *self, PyObject *args)
209 PyZlib_decompress(PyObject *self, PyObject *args)
305 compobject *self;
313 self = newcompobject(&Comptype);
314 if (self==NULL)
316 self->zst.zalloc = (alloc_func)NULL;
317 self->zst.zfree = (free_func)Z_NULL;
318 self->zst.next_in = NULL;
319 self->zst.avail_in = 0;
320 err = deflateInit2(&self->zst, level, method, wbits, memLevel, strategy);
323 self->is_initialised = 1;
324 return (PyObject*)self;
326 Py_DECREF(self);
331 Py_DECREF(self);
335 zlib_error(self->zst, err, "while creating compression object");
336 Py_DECREF(self);
345 compobject *self;
349 self = newcompobject(&Decomptype);
350 if (self == NULL)
352 self->zst.zalloc = (alloc_func)NULL;
353 self->zst.zfree = (free_func)Z_NULL;
354 self->zst.next_in = NULL;
355 self->zst.avail_in = 0;
356 err = inflateInit2(&self->zst, wbits);
359 self->is_initialised = 1;
360 return (PyObject*)self;
362 Py_DECREF(self);
366 Py_DECREF(self);
371 zlib_error(self->zst, err, "while creating decompression object");
372 Py_DECREF(self);
378 Comp_dealloc(compobject *self)
380 if (self->is_initialised)
381 deflateEnd(&self->zst);
382 Py_XDECREF(self->unused_data);
383 Py_XDECREF(self->unconsumed_tail);
384 PyObject_Del(self);
388 Decomp_dealloc(compobject *self)
390 if (self->is_initialised)
391 inflateEnd(&self->zst);
392 Py_XDECREF(self->unused_data);
393 Py_XDECREF(self->unconsumed_tail);
394 PyObject_Del(self);
406 PyZlib_objcompress(compobject *self, PyObject *args)
422 start_total_out = self->zst.total_out;
423 self->zst.avail_in = inplen;
424 self->zst.next_in = input;
425 self->zst.avail_out = length;
426 self->zst.next_out = (unsigned char *)PyString_AS_STRING(RetVal);
429 err = deflate(&(self->zst), Z_NO_FLUSH);
434 while (err == Z_OK && self->zst.avail_out == 0) {
437 self->zst.next_out = (unsigned char *)PyString_AS_STRING(RetVal) \
439 self->zst.avail_out = length;
443 err = deflate(&(self->zst), Z_NO_FLUSH);
452 zlib_error(self->zst, err, "while compressing");
457 _PyString_Resize(&RetVal, self->zst.total_out - start_total_out);
476 PyZlib_objdecompress(compobject *self, PyObject *args)
501 start_total_out = self->zst.total_out;
502 self->zst.avail_in = inplen;
503 self->zst.next_in = input;
504 self->zst.avail_out = length;
505 self->zst.next_out = (unsigned char *)PyString_AS_STRING(RetVal);
508 err = inflate(&(self->zst), Z_SYNC_FLUSH);
514 while (err == Z_OK && self->zst.avail_out == 0) {
529 self->zst.next_out = (unsigned char *)PyString_AS_STRING(RetVal) \
531 self->zst.avail_out = length - old_length;
534 err = inflate(&(self->zst), Z_SYNC_FLUSH);
541 Py_DECREF(self->unconsumed_tail);
542 self->unconsumed_tail = PyString_FromStringAndSize((char *)self->zst.next_in,
543 self->zst.avail_in);
545 else if (PyString_GET_SIZE(self->unconsumed_tail) > 0) {
547 Py_DECREF(self->unconsumed_tail);
548 self->unconsumed_tail = PyString_FromStringAndSize("", 0);
550 if(!self->unconsumed_tail) {
563 Py_XDECREF(self->unused_data); /* Free original empty string */
564 self->unused_data = PyString_FromStringAndSize(
565 (char *)self->zst.next_in, self->zst.avail_in);
566 if (self->unused_data == NULL) {
575 zlib_error(self->zst, err, "while decompressing");
581 _PyString_Resize(&RetVal, self->zst.total_out - start_total_out);
598 PyZlib_flush(compobject *self, PyObject *args)
619 start_total_out = self->zst.total_out;
620 self->zst.avail_in = 0;
621 self->zst.avail_out = length;
622 self->zst.next_out = (unsigned char *)PyString_AS_STRING(RetVal);
625 err = deflate(&(self->zst), flushmode);
630 while (err == Z_OK && self->zst.avail_out == 0) {
633 self->zst.next_out = (unsigned char *)PyString_AS_STRING(RetVal) \
635 self->zst.avail_out = length;
639 err = deflate(&(self->zst), flushmode);
647 err = deflateEnd(&(self->zst));
649 zlib_error(self->zst, err, "from deflateEnd()");
655 self->is_initialised = 0;
662 zlib_error(self->zst, err, "while flushing");
668 _PyString_Resize(&RetVal, self->zst.total_out - start_total_out);
681 PyZlib_copy(compobject *self)
693 err = deflateCopy(&retval->zst, &self->zst);
705 zlib_error(self->zst, err, "while copying compression object");
709 Py_INCREF(self->unused_data);
710 Py_INCREF(self->unconsumed_tail);
713 retval->unused_data = self->unused_data;
714 retval->unconsumed_tail = self->unconsumed_tail;
732 PyZlib_uncopy(compobject *self)
744 err = inflateCopy(&retval->zst, &self->zst);
756 zlib_error(self->zst, err, "while copying decompression object");
760 Py_INCREF(self->unused_data);
761 Py_INCREF(self->unconsumed_tail);
764 retval->unused_data = self->unused_data;
765 retval->unconsumed_tail = self->unconsumed_tail;
788 PyZlib_unflush(compobject *self, PyObject *args)
806 start_total_out = self->zst.total_out;
807 self->zst.avail_out = length;
808 self->zst.next_out = (Byte *)PyString_AS_STRING(retval);
811 err = inflate(&(self->zst), Z_FINISH);
816 while ((err == Z_OK || err == Z_BUF_ERROR) && self->zst.avail_out == 0) {
819 self->zst.next_out = (Byte *)PyString_AS_STRING(retval) + length;
820 self->zst.avail_out = length;
824 err = inflate(&(self->zst), Z_FINISH);
832 err = inflateEnd(&(self->zst));
833 self->is_initialised = 0;
835 zlib_error(self->zst, err, "from inflateEnd()");
841 _PyString_Resize(&retval, self->zst.total_out - start_total_out);
877 Comp_getattr(compobject *self, char *name)
882 return Py_FindMethod(comp_methods, (PyObject *)self, name);
886 Decomp_getattr(compobject *self, char *name)
893 Py_INCREF(self->unused_data);
894 retval = self->unused_data;
896 Py_INCREF(self->unconsumed_tail);
897 retval = self->unconsumed_tail;
899 retval = Py_FindMethod(Decomp_methods, (PyObject *)self, name);
913 PyZlib_adler32(PyObject *self, PyObject *args)
936 PyZlib_crc32(PyObject *self, PyObject *args)