A. Arpi A. Arpi - 1 year ago 114
C Question

how to get <distance, length> pairs from ZLIB compressor

I am compressing several long strings using ZLIB, which uses LZ77 representations of repeated substrings prior to encoding these representations using a Huffman tree. I am interested in studying the sequence of integer tuple representations themselves, and have been looking in the code to figure out where these are generated and how I could print them out one after another. Unfortunately, I am not very strong in C, and it seems that the compressor handles distances as pointers, and not as ints. Could somebody please tell me if there is a simple way to print out the sequence of tuples as the algorithm runs, and point me to the appropriate location in the code.

Answer Source

You can use infgen to disassemble a deflate stream. It will print the decoded symbols in a readable form, e.g. match 41 105 indicating a string to copy of length 41, from a distance back of 105.