crazy fix for zlib

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

crazy fix for zlib

Ted Unangst-2
we get the good interface we want, apache gets the broken api they want.  
i guess it is kinda twisted though.

Index: deflate.c
===================================================================
RCS file: /cvs/src/lib/libz/deflate.c,v
retrieving revision 1.10
diff -u -r1.10 deflate.c
--- deflate.c 2005/07/20 15:56:41 1.10
+++ deflate.c 2005/12/09 06:30:56
@@ -365,6 +365,7 @@
     }
 
     strm->total_in = strm->total_out = 0;
+    strm->xtotal_in = strm->xtotal_out = 0;
     strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */
     strm->data_type = Z_UNKNOWN;
 
@@ -435,7 +436,7 @@
     }
     func = configuration_table[s->level].func;
 
-    if (func != configuration_table[level].func && strm->total_in != 0) {
+    if (func != configuration_table[level].func && strm->xtotal_in != 0) {
         /* Flush the last buffer: */
         err = deflate(strm, Z_PARTIAL_FLUSH);
     }
@@ -541,6 +542,7 @@
     strm->next_out  += len;
     strm->state->pending_out  += len;
     strm->total_out += len;
+    strm->xtotal_out += len;
     strm->avail_out  -= len;
     strm->state->pending -= len;
     if (strm->state->pending == 0) {
@@ -976,6 +978,7 @@
     zmemcpy(buf, strm->next_in, len);
     strm->next_in  += len;
     strm->total_in += len;
+    strm->xtotal_in += len;
 
     return (int)len;
 }
Index: inflate.c
===================================================================
RCS file: /cvs/src/lib/libz/inflate.c,v
retrieving revision 1.9
diff -u -r1.9 inflate.c
--- inflate.c 2005/07/20 15:56:41 1.9
+++ inflate.c 2005/12/09 06:30:57
@@ -109,6 +109,7 @@
     if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
     state = (struct inflate_state FAR *)strm->state;
     strm->total_in = strm->total_out = state->total = 0;
+    strm->xtotal_in = strm->xtotal_out = 0;
     strm->msg = Z_NULL;
     strm->adler = 1;        /* to support ill-conceived Java test suite */
     state->mode = HEAD;
@@ -1150,6 +1151,7 @@
                 NEEDBITS(32);
                 out -= left;
                 strm->total_out += out;
+                strm->xtotal_out += out;
                 state->total += out;
                 if (out)
                     strm->adler = state->check =
@@ -1219,7 +1221,9 @@
     in -= strm->avail_in;
     out -= strm->avail_out;
     strm->total_in += in;
+    strm->xtotal_in += in;
     strm->total_out += out;
+    strm->xtotal_out += out;
     state->total += out;
     if (state->wrap && out)
         strm->adler = state->check =
@@ -1342,7 +1346,7 @@
 z_streamp strm;
 {
     unsigned len;               /* number of bytes to look at or looked at */
-    unsigned long in, out;      /* temporary to save total_in and total_out */
+    z_off_t in, out;      /* temporary to save total_in and total_out */
     unsigned char buf[4];       /* to restore bit buffer to byte string */
     struct inflate_state FAR *state;
 
@@ -1371,12 +1375,14 @@
     strm->avail_in -= len;
     strm->next_in += len;
     strm->total_in += len;
+    strm->xtotal_in += len;
 
     /* return no joy or set up to restart inflate() on a new block */
     if (state->have != 4) return Z_DATA_ERROR;
-    in = strm->total_in;  out = strm->total_out;
+    in = strm->xtotal_in;  out = strm->xtotal_out;
     inflateReset(strm);
     strm->total_in = in;  strm->total_out = out;
+    strm->xtotal_in = in;  strm->xtotal_out = out;
     state->mode = TYPE;
     return Z_OK;
 }
Index: zlib.h
===================================================================
RCS file: /cvs/src/lib/libz/zlib.h,v
retrieving revision 1.9
diff -u -r1.9 zlib.h
--- zlib.h 2005/07/20 15:56:41 1.9
+++ zlib.h 2005/12/09 06:30:58
@@ -83,11 +83,11 @@
 typedef struct z_stream_s {
     Bytef    *next_in;  /* next input byte */
     uInt     avail_in;  /* number of bytes available at next_in */
-    z_off_t  total_in;  /* total nb of input bytes read so far */
+    uLong  total_in;  /* total nb of input bytes read so far */
 
     Bytef    *next_out; /* next output byte should be put there */
     uInt     avail_out; /* remaining free space at next_out */
-    z_off_t  total_out; /* total nb of bytes output so far */
+    uLong  total_out; /* total nb of bytes output so far */
 
     char     *msg;      /* last error message, NULL if no error */
     struct internal_state FAR *state; /* not visible by applications */
@@ -99,6 +99,8 @@
     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 */
+    z_off_t  xtotal_in;  /* total nb of input bytes read so far */
+    z_off_t  xtotal_out; /* total nb of bytes output so far */
 } z_stream;
 
 typedef z_stream FAR *z_streamp;


--
die energie aus fleisch und blut        deine sprache und die ganze wut
deine gefuehle die du lebst             und dein herz fuehl wie es bebt
zeitbombe! sie tickt in dir    zeitbombe! sie explodiert in deinem kopf
                                                    - girls under glass