r5692 - trunk/varnish-cache/lib/libvgz

phk at varnish-cache.org phk at varnish-cache.org
Thu Jan 6 15:55:05 CET 2011


Author: phk
Date: 2011-01-06 15:55:05 +0100 (Thu, 06 Jan 2011)
New Revision: 5692

Modified:
   trunk/varnish-cache/lib/libvgz/README
   trunk/varnish-cache/lib/libvgz/inflate.c
   trunk/varnish-cache/lib/libvgz/zlib.h
Log:
Modify libvgz's inflate() function to record for us the bit positions of
the first deflate block, the 'last' bit and the first (padding) bit after
the laste deflate block.

We need to know these in order to do the multi-evil gzip surgery for
ESI compression.



Modified: trunk/varnish-cache/lib/libvgz/README
===================================================================
--- trunk/varnish-cache/lib/libvgz/README	2011-01-05 14:28:16 UTC (rev 5691)
+++ trunk/varnish-cache/lib/libvgz/README	2011-01-06 14:55:05 UTC (rev 5692)
@@ -1,7 +1,16 @@
-This is a cut down version of the ZLIB data compression library.
+This is a modified version of the ZLIB 1.2.5 data compression library.
 
 For the original and complete version of the library please visit:
 
 	http://www.zlib.net/
 
 For copyright and licensing information, please see the zlib.h file.
+
+Modifications include:
+
+* Unnecessary files not imported.
+
+* Extension to inflate() to record the bit positions of:
+	A) The first deflate block
+	B) The 'last' bit
+	C) The first (padding) bit after the last deflate block

Modified: trunk/varnish-cache/lib/libvgz/inflate.c
===================================================================
--- trunk/varnish-cache/lib/libvgz/inflate.c	2011-01-05 14:28:16 UTC (rev 5691)
+++ trunk/varnish-cache/lib/libvgz/inflate.c	2011-01-06 14:55:05 UTC (rev 5692)
@@ -810,13 +810,18 @@
         case TYPE:
             if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
         case TYPEDO:
+            if (strm->start_bit == 0) 
+                strm->start_bit = 8 * (strm->total_in + in - have) - bits;
             if (state->last) {
+                strm->stop_bit = 8 * (strm->total_in + in - have) - bits;
                 BYTEBITS();
                 state->mode = CHECK;
                 break;
             }
             NEEDBITS(3);
             state->last = BITS(1);
+            if (state->last)
+                strm->last_bit = 8 * (strm->total_in + in - have) - bits;
             DROPBITS(1);
             switch (BITS(2)) {
             case 0:                             /* stored block */

Modified: trunk/varnish-cache/lib/libvgz/zlib.h
===================================================================
--- trunk/varnish-cache/lib/libvgz/zlib.h	2011-01-05 14:28:16 UTC (rev 5691)
+++ trunk/varnish-cache/lib/libvgz/zlib.h	2011-01-06 14:55:05 UTC (rev 5692)
@@ -101,6 +101,10 @@
     int     data_type;  /* best guess about the data type: binary or text */
     uLong   adler;      /* adler32 value of the uncompressed data */
     uLong   reserved;   /* reserved for future use */
+
+    uLong   start_bit;	/* Bit pos of first deflate block */
+    uLong   stop_bit;	/* Bit pos after last deflate block */
+    uLong   last_bit;	/* Bit pos of 'last' bit */
 } z_stream;
 
 typedef z_stream FAR *z_streamp;




More information about the varnish-commit mailing list