aboutsummaryrefslogtreecommitdiff
path: root/examples/zran.h
diff options
context:
space:
mode:
Diffstat (limited to 'examples/zran.h')
-rw-r--r--examples/zran.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/examples/zran.h b/examples/zran.h
index ebf780d0c1f1..16a84feb9fc0 100644
--- a/examples/zran.h
+++ b/examples/zran.h
@@ -1,7 +1,7 @@
-/* zran.h -- example of deflated stream indexing and random access
- * Copyright (C) 2005, 2012, 2018, 2023 Mark Adler
+/* zran.h -- example of deflate stream indexing and random access
+ * Copyright (C) 2005, 2012, 2018, 2023, 2024, 2025 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
- * Version 1.3 18 Feb 2023 Mark Adler */
+ * Version 1.7 16 May 2025 Mark Adler */
#include <stdio.h>
#include "zlib.h"
@@ -11,7 +11,8 @@ typedef struct point {
off_t out; // offset in uncompressed data
off_t in; // offset in compressed file of first full byte
int bits; // 0, or number of bits (1-7) from byte at in-1
- unsigned char window[32768]; // preceding 32K of uncompressed data
+ unsigned dict; // number of bytes in window to use as a dictionary
+ unsigned char *window; // preceding 32K (or less) of uncompressed data
} point_t;
// Access point list.
@@ -20,6 +21,7 @@ struct deflate_index {
int mode; // -15 for raw, 15 for zlib, or 31 for gzip
off_t length; // total length of uncompressed data
point_t *list; // allocated list of access points
+ z_stream strm; // re-usable inflate engine for extraction
};
// Make one pass through a zlib, gzip, or raw deflate compressed stream and
@@ -30,7 +32,7 @@ struct deflate_index {
// the number of access points on success (>= 1), Z_MEM_ERROR for out of
// memory, Z_BUF_ERROR for a premature end of input, Z_DATA_ERROR for a format
// or verification error in the input file, or Z_ERRNO for a file read error.
-// On success, *built points to the resulting index.
+// On success, *built points to the resulting index, otherwise it's NULL.
int deflate_index_build(FILE *in, off_t span, struct deflate_index **built);
// Use the index to read len bytes from offset into buf. Return the number of