summaryrefslogtreecommitdiff
path: root/trees.c
diff options
context:
space:
mode:
Diffstat (limited to 'trees.c')
-rw-r--r--trees.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/trees.c b/trees.c
index 9234add..eb69d49 100644
--- a/trees.c
+++ b/trees.c
@@ -29,7 +29,7 @@
29 * Addison-Wesley, 1983. ISBN 0-201-06672-6. 29 * Addison-Wesley, 1983. ISBN 0-201-06672-6.
30 */ 30 */
31 31
32/* $Id: trees.c,v 1.3 1995/04/29 13:49:46 jloup Exp $ */ 32/* $Id: trees.c,v 1.4 1995/05/01 16:53:44 jloup Exp $ */
33 33
34#include "deflate.h" 34#include "deflate.h"
35 35
@@ -723,6 +723,22 @@ local void send_all_trees(s, lcodes, dcodes, blcodes)
723} 723}
724 724
725/* =========================================================================== 725/* ===========================================================================
726 * Send a stored block
727 */
728void ct_stored_block(s, buf, stored_len, eof)
729 deflate_state *s;
730 char *buf; /* input block */
731 ulg stored_len; /* length of input block */
732 int eof; /* true if this is the last block for a file */
733{
734 send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */
735 s->compressed_len = (s->compressed_len + 3 + 7) & ~7L;
736 s->compressed_len += (stored_len + 4) << 3;
737
738 copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
739}
740
741/* ===========================================================================
726 * Determine the best encoding for the current block: dynamic trees, static 742 * Determine the best encoding for the current block: dynamic trees, static
727 * trees or store, and output the encoded block to the zip file. This function 743 * trees or store, and output the encoded block to the zip file. This function
728 * returns the total compressed length for the file so far. 744 * returns the total compressed length for the file so far.
@@ -771,8 +787,8 @@ ulg ct_flush_block(s, buf, stored_len, eof)
771 * the whole file is transformed into a stored file: 787 * the whole file is transformed into a stored file:
772 */ 788 */
773#ifdef STORED_FILE_OK 789#ifdef STORED_FILE_OK
774# ifdef FORCE_METHOD 790# ifdef FORCE_STORED_FILE
775 if (level == 1 && eof && compressed_len == 0L) { /* force stored file */ 791 if (eof && compressed_len == 0L) { /* force stored file */
776# else 792# else
777 if (stored_len <= opt_lenb && eof && s->compressed_len==0L && seekable()) { 793 if (stored_len <= opt_lenb && eof && s->compressed_len==0L && seekable()) {
778# endif 794# endif
@@ -785,8 +801,8 @@ ulg ct_flush_block(s, buf, stored_len, eof)
785 } else 801 } else
786#endif /* STORED_FILE_OK */ 802#endif /* STORED_FILE_OK */
787 803
788#ifdef FORCE_METHOD 804#ifdef FORCE_STORED
789 if (level == 2 && buf != (char*)0) { /* force stored block */ 805 if (buf != (char*)0) { /* force stored block */
790#else 806#else
791 if (stored_len+4 <= opt_lenb && buf != (char*)0) { 807 if (stored_len+4 <= opt_lenb && buf != (char*)0) {
792 /* 4: two words for the lengths */ 808 /* 4: two words for the lengths */
@@ -797,14 +813,10 @@ ulg ct_flush_block(s, buf, stored_len, eof)
797 * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to 813 * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
798 * transform a block into a stored block. 814 * transform a block into a stored block.
799 */ 815 */
800 send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */ 816 ct_stored_block(s, buf, stored_len, eof);
801 s->compressed_len = (s->compressed_len + 3 + 7) & ~7L;
802 s->compressed_len += (stored_len + 4) << 3;
803
804 copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
805 817
806#ifdef FORCE_METHOD 818#ifdef FORCE_STATIC
807 } else if (level == 3) { /* force static trees */ 819 } else if (static_lenb >= 0) { /* force static trees */
808#else 820#else
809 } else if (static_lenb == opt_lenb) { 821 } else if (static_lenb == opt_lenb) {
810#endif 822#endif