MCPcopy Index your code
hub / github.com/RsyncProject/rsync / deflate

Function deflate

zlib/deflate.c:669–978  ·  view source on GitHub ↗

========================================================================= */

Source from the content-addressed store, hash-verified

667
668/* ========================================================================= */
669int ZEXPORT deflate (z_streamp strm, int flush)
670{
671 int old_flush; /* value of flush param for previous deflate call */
672 deflate_state *s;
673
674 if (strm == Z_NULL || strm->state == Z_NULL ||
675 (flush > Z_BLOCK && flush != Z_INSERT_ONLY) || flush < 0) {
676 return Z_STREAM_ERROR;
677 }
678 s = strm->state;
679
680 if (strm->next_out == Z_NULL ||
681 (strm->next_in == Z_NULL && strm->avail_in != 0) ||
682 (s->status == FINISH_STATE && flush != Z_FINISH)) {
683 ERR_RETURN(strm, Z_STREAM_ERROR);
684 }
685 if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
686
687 s->strm = strm; /* just in case */
688 old_flush = s->last_flush;
689 s->last_flush = flush;
690
691 /* Write the header */
692 if (s->status == INIT_STATE) {
693#ifdef GZIP
694 if (s->wrap == 2) {
695 strm->adler = crc32(0L, Z_NULL, 0);
696 put_byte(s, 31);
697 put_byte(s, 139);
698 put_byte(s, 8);
699 if (s->gzhead == Z_NULL) {
700 put_byte(s, 0);
701 put_byte(s, 0);
702 put_byte(s, 0);
703 put_byte(s, 0);
704 put_byte(s, 0);
705 put_byte(s, s->level == 9 ? 2 :
706 (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
707 4 : 0));
708 put_byte(s, OS_CODE);
709 s->status = BUSY_STATE;
710 }
711 else {
712 put_byte(s, (s->gzhead->text ? 1 : 0) +
713 (s->gzhead->hcrc ? 2 : 0) +
714 (s->gzhead->extra == Z_NULL ? 0 : 4) +
715 (s->gzhead->name == Z_NULL ? 0 : 8) +
716 (s->gzhead->comment == Z_NULL ? 0 : 16)
717 );
718 put_byte(s, (Byte)(s->gzhead->time & 0xff));
719 put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));
720 put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));
721 put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));
722 put_byte(s, s->level == 9 ? 2 :
723 (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
724 4 : 0));
725 put_byte(s, s->gzhead->os & 0xff);
726 if (s->gzhead->extra != Z_NULL) {

Callers 3

send_deflated_tokenFunction · 0.85
compress2Function · 0.85
deflateParamsFunction · 0.85

Calls 8

crc32Function · 0.85
putShortMSBFunction · 0.85
adler32Function · 0.85
flush_pendingFunction · 0.85
deflate_huffFunction · 0.85
deflate_rleFunction · 0.85
_tr_alignFunction · 0.85
_tr_stored_blockFunction · 0.85

Tested by

no test coverage detected