* void ct_tally (int dist, int lc);
* Save the match info and tally the frequency counts.
*
- * long flush_block (char *buf, ulg stored_len, int eof)
+ * off_t flush_block (char *buf, ulg stored_len, int eof)
* Determine the best encoding for the current block: dynamic trees,
* static trees or store, and output the encoded block to the zip
* file. Returns the total compressed length for the file so far.
*
*/
+#include <config.h>
#include <ctype.h>
#include "tailor.h"
local ulg opt_len; /* bit length of current block with optimal trees */
local ulg static_len; /* bit length of current block with static trees */
-local ulg compressed_len; /* total bit length of compressed file */
+local off_t compressed_len; /* total bit length of compressed file */
-local ulg input_len; /* total byte length of input file */
+local off_t input_len; /* total byte length of input file */
/* input_len is for debugging only since we can get it by other means. */
ush *file_type; /* pointer to UNKNOWN, BINARY or ASCII */
int *file_method; /* pointer to DEFLATE or STORE */
#ifdef DEBUG
-extern ulg bits_sent; /* bit length of the compressed data */
-extern long isize; /* byte length of input file */
+extern off_t bits_sent; /* bit length of the compressed data */
#endif
extern long block_start; /* window offset of current block */
}
/* Update opt_len to include the bit length tree and counts */
opt_len += 3*(max_blindex+1) + 5+5+4;
- Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", opt_len, static_len));
+ Tracev((stderr, "\ndyn trees: dyn %lu, stat %lu", opt_len, static_len));
return max_blindex;
}
Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
send_bits(bl_tree[bl_order[rank]].Len, 3);
}
- Tracev((stderr, "\nbl tree: sent %ld", bits_sent));
send_tree((ct_data near *)dyn_ltree, lcodes-1); /* send the literal tree */
- Tracev((stderr, "\nlit tree: sent %ld", bits_sent));
send_tree((ct_data near *)dyn_dtree, dcodes-1); /* send the distance tree */
- Tracev((stderr, "\ndist tree: sent %ld", bits_sent));
}
/* ===========================================================================
* trees or store, and output the encoded block to the zip file. This function
* returns the total compressed length for the file so far.
*/
-ulg flush_block(buf, stored_len, eof)
+off_t flush_block(buf, stored_len, eof)
char *buf; /* input block, or NULL if too old */
ulg stored_len; /* length of input block */
int eof; /* true if this is the last block for a file */
/* Construct the literal and distance trees */
build_tree((tree_desc near *)(&l_desc));
- Tracev((stderr, "\nlit data: dyn %ld, stat %ld", opt_len, static_len));
+ Tracev((stderr, "\nlit data: dyn %lu, stat %lu", opt_len, static_len));
build_tree((tree_desc near *)(&d_desc));
- Tracev((stderr, "\ndist data: dyn %ld, stat %ld", opt_len, static_len));
+ Tracev((stderr, "\ndist data: dyn %lu, stat %lu", opt_len, static_len));
/* At this point, opt_len and static_len are the total bit lengths of
* the compressed block data, excluding the tree representations.
*/
init_block();
if (eof) {
- Assert (input_len == isize, "bad input size");
+ Assert (input_len == bytes_in, "bad input size");
bi_windup();
compressed_len += 7; /* align on byte boundary */
}
- Tracev((stderr,"\ncomprlen %lu(%lu) ", compressed_len>>3,
- compressed_len-7*eof));
return compressed_len >> 3;
}
while (n < LITERALS) bin_freq += dyn_ltree[n++].Freq;
*file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII;
if (*file_type == BINARY && translate_eol) {
- warn("-l used on binary file", "");
+ warning ("-l used on binary file");
}
}
static char rcsid[] = "$Id$";
#endif
+#include <config.h>
#include "tailor.h"
#include "gzip.h"
#include "crypt.h"
#define LOCEXT 28 /* offset of extra field length */
#define LOCHDR 30 /* size of local header, including sig */
#define EXTHDR 16 /* size of extended local header, inc sig */
+#define RAND_HEAD_LEN 12 /* length of encryption random header */
/* Globals */
ulg orig_len = 0; /* original uncompressed length */
int n;
uch buf[EXTHDR]; /* extended local header */
+ int err = OK;
ifd = in;
ofd = out;
}
while (n--) {
uch c = (uch)get_byte();
-#ifdef CRYPT
- if (decrypt) zdecode(c);
-#endif
put_ubyte(c);
}
flush_window();
/* Validate decompression */
if (orig_crc != updcrc(outbuf, 0)) {
- error("invalid compressed data--crc error");
+ fprintf(stderr, "\n%s: %s: invalid compressed data--crc error\n",
+ progname, ifname);
+ err = ERROR;
}
- if (orig_len != (ulg)bytes_out) {
- error("invalid compressed data--length error");
+ if (orig_len != (ulg)(bytes_out & 0xffffffff)) {
+ fprintf(stderr, "\n%s: %s: invalid compressed data--length error\n",
+ progname, ifname);
+ err = ERROR;
}
/* Check if there are more entries in a pkzip file */
fprintf(stderr,
"%s: %s has more than one entry -- unchanged\n",
progname, ifname);
- exit_code = ERROR;
- ext_header = pkzip = 0;
- return ERROR;
+ err = ERROR;
}
}
ext_header = pkzip = 0; /* for next file */
- return OK;
+ if (err == OK) return OK;
+ exit_code = ERROR;
+ if (!test) abort_gzip();
+ return err;
}