ndr_compression: use deflateReset() together with defalteSetDictionary()
authorStefan Metzmacher <metze@samba.org>
Sat, 6 Sep 2008 14:16:00 +0000 (16:16 +0200)
committerStefan Metzmacher <metze@samba.org>
Sat, 6 Sep 2008 14:16:00 +0000 (16:16 +0200)
metze

source/librpc/ndr/ndr_compression.c

index 0b33d40c24293ec826aee017153d41c61c04549b..a92877ccc205420b4296eb182d3b270d671a05dc 100644 (file)
@@ -219,14 +219,6 @@ static enum ndr_err_code ndr_push_compression_mszip_chunk(struct ndr_push *ndrpu
                                              zError(z_ret), z_ret);
 
                }
-       } else {
-               /* TODO: keep the window */
-               z_ret = deflateReset(z);
-               if (z_ret != Z_OK) {
-                       return ndr_push_error(ndrpush, NDR_ERR_COMPRESSION,
-                                             "Bad delateReset2 error %s(%d) (PUSH)",
-                                             zError(z_ret), z_ret);
-               }
        }
 
        /* call deflate untill we get Z_STREAM_END or an error */
@@ -248,11 +240,28 @@ static enum ndr_err_code ndr_push_compression_mszip_chunk(struct ndr_push *ndrpu
 
        comp_chunk_size = 2 + z->total_out;
 
+       z_ret = deflateReset(z);
+       if (z_ret != Z_OK) {
+               return ndr_pull_error(ndrpull, NDR_ERR_COMPRESSION,
+                                     "Bad deflateReset error %s(%d) (PULL)",
+                                     zError(z_ret), z_ret);
+       }
+
+       z_ret = deflateSetDictionary(z, plain_chunk.data, plain_chunk.length);
+       if (z_ret != Z_OK) {
+               return ndr_pull_error(ndrpull, NDR_ERR_COMPRESSION,
+                                     "Bad deflateSetDictionary error %s(%d) (PULL)",
+                                     zError(z_ret), z_ret);
+       }
+
        tmp_offset = ndrpush->offset;
        ndrpush->offset = comp_chunk_size_offset;
        NDR_CHECK(ndr_push_uint32(ndrpush, NDR_SCALARS, comp_chunk_size));
        ndrpush->offset = tmp_offset;
 
+       DEBUG(10,("MSZIP comp plain_chunk_size: %08X (%u) comp_chunk_size: %08X (%u)\n",
+                 plain_chunk.length, plain_chunk.length, comp_chunk_size, comp_chunk_size));
+
        ndrpush->offset += comp_chunk_size;
        return NDR_ERR_SUCCESS;
 }