summaryrefslogtreecommitdiff
path: root/archivers/xmill/patches/patch-ab
blob: 4e8076eba29ecb55f096e9cfe9d04f5cb182f72d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
$NetBSD: patch-ab,v 1.1.1.1 2003/02/17 09:20:26 grant Exp $

--- src/ZLib.cpp.orig	Sat Feb 15 02:54:15 2003
+++ src/ZLib.cpp
@@ -125,7 +125,7 @@ Compressor::~Compressor()
       // We finish compression, if there has been some data in the queue
    {
 #ifdef USE_BZIP
-      bzCompressEnd(&state);
+      BZ2_bzCompressEnd(&state);
 #else
       deflateEnd(&state);
 #endif
@@ -175,7 +175,7 @@ void Compressor::CompressMemStream(MemSt
    if(isinitialized==0)
    {
 #ifdef USE_BZIP
-      if(bzCompressInit(&state,7,0,0)!=BZ_OK)
+      if(BZ2_bzCompressInit(&state,7,0,0)!=BZ_OK)
 #else
       if(deflateInit(&state,zlib_compressidx)!=Z_OK)
 #endif
@@ -183,8 +183,15 @@ void Compressor::CompressMemStream(MemSt
          Error("Error while compressing container!");
          Exit();
       }
+#ifdef USE_BZIP
+      state.total_out_lo32=0;
+      state.total_out_hi32=0;
+      state.total_in_lo32=0;
+      state.total_in_hi32=0;
+#else
       state.total_out=0;
       state.total_in=0;
+#endif
 
       isinitialized=1;
    }
@@ -205,7 +212,7 @@ void Compressor::CompressMemStream(MemSt
          saveavail=state.avail_out;
 
 #ifdef USE_BZIP
-         if(bzCompress(&state,BZ_RUN)!=BZ_RUN_OK)
+         if(BZ2_bzCompress(&state,BZ_RUN)!=BZ_RUN_OK)
 #else
          if(deflate(&state,Z_NO_FLUSH)!=Z_OK)
 #endif
@@ -259,7 +266,7 @@ void Compressor::CompressData(unsigned c
    if(isinitialized==0)
    {
 #ifdef USE_BZIP
-      if(bzCompressInit(&state,7,0,0)!=BZ_OK)
+      if(BZ2_bzCompressInit(&state,7,0,0)!=BZ_OK)
 #else
       if(deflateInit(&state,zlib_compressidx)!=Z_OK)
 #endif
@@ -267,8 +274,15 @@ void Compressor::CompressData(unsigned c
          Error("Error while compressing container!");
          Exit();
       }
+#ifdef USE_BZIP
+      state.total_out_lo32=0;
+      state.total_out_hi32=0;
+      state.total_in_lo32=0;
+      state.total_in_hi32=0;
+#else
       state.total_out=0;
       state.total_in=0;
+#endif
       isinitialized=1;
    }
 
@@ -278,7 +292,7 @@ void Compressor::CompressData(unsigned c
 
       // The actual compression
 #ifdef USE_BZIP
-      if(bzCompress(&state,BZ_RUN)!=BZ_RUN_OK)
+      if(BZ2_bzCompress(&state,BZ_RUN)!=BZ_RUN_OK)
 #else
       if(deflate(&state,Z_NO_FLUSH)!=Z_OK)
 #endif
@@ -326,7 +340,7 @@ void Compressor::FinishCompress(unsigned
       saveavail=state.avail_out;
 
 #ifdef USE_BZIP
-      err=bzCompress(&state,BZ_FINISH);
+      err=BZ2_bzCompress(&state,BZ_FINISH);
 #else
       err=deflate(&state,Z_FINISH);
 #endif
@@ -353,15 +367,25 @@ void Compressor::FinishCompress(unsigned
    while(1);
 
    // Let's store the input and output size
+#ifdef USE_BZIP
+   if(uncompressedsize!=NULL) *uncompressedsize =state.total_in_lo32;
+   if(compressedsize!=NULL)   *compressedsize   =state.total_out_lo32;
+
+   state.total_out_lo32=0;
+   state.total_out_hi32=0;
+   state.total_in_lo32=0;
+   state.total_in_hi32=0;
+#else
    if(uncompressedsize!=NULL) *uncompressedsize =state.total_in;
    if(compressedsize!=NULL)   *compressedsize   =state.total_out;
 
    state.total_out=0;
    state.total_in=0;
+#endif
 
    // Finally, we release the internal memory
 #ifdef USE_BZIP
-   if(bzCompressEnd(&state)!=BZ_OK)
+   if(BZ2_bzCompressEnd(&state)!=BZ_OK)
 #else
    if(deflateReset(&state)!=Z_OK)
 #endif
@@ -404,7 +428,7 @@ char Uncompressor::Uncompress(Input *inp
 #endif
 
 #ifdef USE_BZIP
-      if(bzDecompressInit(&state,0,0)!=BZ_OK)
+      if(BZ2_bzDecompressInit(&state,0,0)!=BZ_OK)
 #else
       if(inflateInit(&state)!=Z_OK)
 #endif
@@ -439,7 +463,7 @@ char Uncompressor::Uncompress(Input *inp
 
       // The actual decompression
 #ifdef USE_BZIP
-      switch(bzDecompress(&state))
+      switch(BZ2_bzDecompress(&state))
 #else
       switch(inflate(&state,Z_NO_FLUSH))
 #endif
@@ -454,11 +478,15 @@ char Uncompressor::Uncompress(Input *inp
          input->SkipData(save_in-state.avail_in);
 
          // Let's store the overall amount of "decompressed" data.
+#ifdef USE_BZIP
+         *len=state.total_out_lo32;
+#else
          *len=state.total_out;
+#endif
 
          // Let's finish the decompression entirely
 #ifdef USE_BZIP
-         if(bzDecompressEnd(&state)!=BZ_OK)
+         if(BZ2_bzDecompressEnd(&state)!=BZ_OK)
 #else
          if(inflateReset(&state)!=Z_OK)
 #endif