I am able to read the created index files using a jdk client and to prime the window as needed and set up the streams to the needed positions.
the wall i run into is the inflatePrime zlib function being absent from non-c libraries which is true among at least 3 ports including the official Oracle one.
the occurrence of non-zero bits in the index is roughly... 7 in 8
in gzindex the indexes are not stored to disk, it's just a minimum unit test of what gztool does. the point struct stores the first 2 offsets in bits, not bytes.
i modified the loop conditionals of gzindex as shown below to change the input window to 1 and keep iterating the loop until arriving at byte aligned block boundary. i'm guessing this makes the block boundary slightly stochastic, up to an average of 4 bytes variance. with gztool this isn't a simple modification.
diff --git a/gzindex.c b/gzindex.c
--- a/gzindex.c (revision f1b7696c1e4757a7201009a2f3e02ed9e3536a56)
+++ b/gzindex.c (revision 662eb8434ed5c3d18e4673621aafd9e0feb415bf)
@@ -207,6 +207,7 @@
unsigned char *out, *out2;
z_stream strm;
unsigned char in[16384];
+size_t input_stride = sizeof(in);
/* position input file */
ret = fseeko(gz, offset, SEEK_SET);
@@ -273,7 +274,7 @@
do {
/* if needed, get more input data */
if (strm.avail_in == 0) {
- strm.avail_in = fread(in, 1, sizeof(in), gz);
+ strm.avail_in = fread(in, 1, input_stride, gz);
if (ferror(gz)) {
(void)inflateEnd(&strm);
free(list);
@@ -304,6 +305,12 @@
/* if at a block boundary, note the location of the header */
if (strm.data_type & 128) {
+ out_alignment = (pos - strm.avail_in) & 7;
+ if (out_alignment) {
+ input_stride = 1;
+ } else {
+ input_stride = sizeof(in);
+ }
head = ((pos - strm.avail_in) << 3) - (strm.data_type & 63);
last = strm.data_type & 64; /* true at end of last block */
}
...
} while (strm.avail_out != 0 && !last &&out_alignment ); //keeps reading 1 byte at end of block-read until alignment