64 #define WINSIZE 32768U
109 else if (index->
have == index->
gzip) {
159 totin = totout = last = 0;
167 goto deflate_index_build_error;
171 goto deflate_index_build_error;
198 goto deflate_index_build_error;
204 goto deflate_index_build_error;
219 if ((
strm.data_type & 128) && !(
strm.data_type & 64) &&
220 (totout == 0 || totout - last > span)) {
225 goto deflate_index_build_error;
241 deflate_index_build_error:
249 unsigned char *
buf,
int len)
255 unsigned char discard[
WINSIZE];
278 goto deflate_index_extract_ret;
283 goto deflate_index_extract_ret;
317 goto deflate_index_extract_ret;
321 goto deflate_index_extract_ret;
329 goto deflate_index_extract_ret;
332 if (index->
gzip == 0)
355 goto deflate_index_extract_ret;
361 goto deflate_index_extract_ret;
365 goto deflate_index_extract_ret;
371 goto deflate_index_extract_ret;
372 }
while ((
strm.data_type & 128) == 0);
378 goto deflate_index_extract_ret;
396 deflate_index_extract_ret:
403 #define SPAN 1048576L
420 if (argc < 2 || argc > 3) {
421 fprintf(stderr,
"usage: zran file.gz [offset]\n");
424 in = fopen(
argv[1],
"rb");
426 fprintf(stderr,
"zran: could not open %s for reading\n",
argv[1]);
435 fprintf(stderr,
"zran: %s is not a valid offset\n",
argv[2]);
446 fprintf(stderr,
"zran: out of memory\n");
449 fprintf(stderr,
"zran: compressed data error in %s\n",
argv[1]);
452 fprintf(stderr,
"zran: read error on %s\n",
argv[1]);
455 fprintf(stderr,
"zran: error %d while building index\n",
len);
459 fprintf(stderr,
"zran: built index with %d access points\n",
len);
466 fprintf(stderr,
"zran: extraction failed: %s error\n",
469 fwrite(
buf, 1,
len, stdout);
470 fprintf(stderr,
"zran: extracted %d bytes at %llu\n",
len,
offset);
int bits(struct state *s, int need)
const lzma_allocator const uint8_t * in
const lzma_allocator const uint8_t size_t uint8_t * out
void skip(file *in, unsigned n)
RZ_API void Ht_() free(HtName_(Ht) *ht)
int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary, uInt dictLength)
int ZEXPORT inflatePrime(z_streamp strm, int bits, int value)
int ZEXPORT inflate(z_streamp strm, int flush)
int ZEXPORT inflateReset(z_streamp strm)
int ZEXPORT inflateEnd(z_streamp strm)
int ZEXPORT inflateReset2(z_streamp strm, int windowBits)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
void * realloc(void *ptr, size_t size)
void * malloc(size_t size)
static static fork const void static count static fd const char const char static newpath char char argv
static void struct sockaddr socklen_t static fromlen static backlog static fork char char char static envp int struct rusage static rusage struct utsname static buf struct sembuf unsigned
int main(int argc, char **argv)
unsigned char window[WINSIZE]
static bool input(void *ud, zip_uint8_t *data, zip_uint64_t length)
#define inflateInit2(strm, windowBits)
void deflate_index_free(struct deflate_index *index)
int deflate_index_extract(FILE *in, struct deflate_index *index, off_t offset, unsigned char *buf, int len)
static struct deflate_index * addpoint(struct deflate_index *index, int bits, off_t in, off_t out, unsigned left, unsigned char *window)
int deflate_index_build(FILE *in, off_t span, struct deflate_index **built)