diff options
Diffstat (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/bzip2')
46 files changed, 11763 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/CHANGES b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/CHANGES new file mode 100644 index 0000000..81e97ca --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/CHANGES | |||
@@ -0,0 +1,327 @@ | |||
1 | ------------------------------------------------------------------ | ||
2 | This file is part of bzip2/libbzip2, a program and library for | ||
3 | lossless, block-sorting data compression. | ||
4 | |||
5 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | ||
6 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | ||
7 | |||
8 | Please read the WARNING, DISCLAIMER and PATENTS sections in the | ||
9 | README file. | ||
10 | |||
11 | This program is released under the terms of the license contained | ||
12 | in the file LICENSE. | ||
13 | ------------------------------------------------------------------ | ||
14 | |||
15 | |||
16 | 0.9.0 | ||
17 | ~~~~~ | ||
18 | First version. | ||
19 | |||
20 | |||
21 | 0.9.0a | ||
22 | ~~~~~~ | ||
23 | Removed 'ranlib' from Makefile, since most modern Unix-es | ||
24 | don't need it, or even know about it. | ||
25 | |||
26 | |||
27 | 0.9.0b | ||
28 | ~~~~~~ | ||
29 | Fixed a problem with error reporting in bzip2.c. This does not effect | ||
30 | the library in any way. Problem is: versions 0.9.0 and 0.9.0a (of the | ||
31 | program proper) compress and decompress correctly, but give misleading | ||
32 | error messages (internal panics) when an I/O error occurs, instead of | ||
33 | reporting the problem correctly. This shouldn't give any data loss | ||
34 | (as far as I can see), but is confusing. | ||
35 | |||
36 | Made the inline declarations disappear for non-GCC compilers. | ||
37 | |||
38 | |||
39 | 0.9.0c | ||
40 | ~~~~~~ | ||
41 | Fixed some problems in the library pertaining to some boundary cases. | ||
42 | This makes the library behave more correctly in those situations. The | ||
43 | fixes apply only to features (calls and parameters) not used by | ||
44 | bzip2.c, so the non-fixedness of them in previous versions has no | ||
45 | effect on reliability of bzip2.c. | ||
46 | |||
47 | In bzlib.c: | ||
48 | * made zero-length BZ_FLUSH work correctly in bzCompress(). | ||
49 | * fixed bzWrite/bzRead to ignore zero-length requests. | ||
50 | * fixed bzread to correctly handle read requests after EOF. | ||
51 | * wrong parameter order in call to bzDecompressInit in | ||
52 | bzBuffToBuffDecompress. Fixed. | ||
53 | |||
54 | In compress.c: | ||
55 | * changed setting of nGroups in sendMTFValues() so as to | ||
56 | do a bit better on small files. This _does_ effect | ||
57 | bzip2.c. | ||
58 | |||
59 | |||
60 | 0.9.5a | ||
61 | ~~~~~~ | ||
62 | Major change: add a fallback sorting algorithm (blocksort.c) | ||
63 | to give reasonable behaviour even for very repetitive inputs. | ||
64 | Nuked --repetitive-best and --repetitive-fast since they are | ||
65 | no longer useful. | ||
66 | |||
67 | Minor changes: mostly a whole bunch of small changes/ | ||
68 | bugfixes in the driver (bzip2.c). Changes pertaining to the | ||
69 | user interface are: | ||
70 | |||
71 | allow decompression of symlink'd files to stdout | ||
72 | decompress/test files even without .bz2 extension | ||
73 | give more accurate error messages for I/O errors | ||
74 | when compressing/decompressing to stdout, don't catch control-C | ||
75 | read flags from BZIP2 and BZIP environment variables | ||
76 | decline to break hard links to a file unless forced with -f | ||
77 | allow -c flag even with no filenames | ||
78 | preserve file ownerships as far as possible | ||
79 | make -s -1 give the expected block size (100k) | ||
80 | add a flag -q --quiet to suppress nonessential warnings | ||
81 | stop decoding flags after --, so files beginning in - can be handled | ||
82 | resolved inconsistent naming: bzcat or bz2cat ? | ||
83 | bzip2 --help now returns 0 | ||
84 | |||
85 | Programming-level changes are: | ||
86 | |||
87 | fixed syntax error in GET_LL4 for Borland C++ 5.02 | ||
88 | let bzBuffToBuffDecompress return BZ_DATA_ERROR{_MAGIC} | ||
89 | fix overshoot of mode-string end in bzopen_or_bzdopen | ||
90 | wrapped bzlib.h in #ifdef __cplusplus ... extern "C" { ... } | ||
91 | close file handles under all error conditions | ||
92 | added minor mods so it compiles with DJGPP out of the box | ||
93 | fixed Makefile so it doesn't give problems with BSD make | ||
94 | fix uninitialised memory reads in dlltest.c | ||
95 | |||
96 | 0.9.5b | ||
97 | ~~~~~~ | ||
98 | Open stdin/stdout in binary mode for DJGPP. | ||
99 | |||
100 | 0.9.5c | ||
101 | ~~~~~~ | ||
102 | Changed BZ_N_OVERSHOOT to be ... + 2 instead of ... + 1. The + 1 | ||
103 | version could cause the sorted order to be wrong in some extremely | ||
104 | obscure cases. Also changed setting of quadrant in blocksort.c. | ||
105 | |||
106 | 0.9.5d | ||
107 | ~~~~~~ | ||
108 | The only functional change is to make bzlibVersion() in the library | ||
109 | return the correct string. This has no effect whatsoever on the | ||
110 | functioning of the bzip2 program or library. Added a couple of casts | ||
111 | so the library compiles without warnings at level 3 in MS Visual | ||
112 | Studio 6.0. Included a Y2K statement in the file Y2K_INFO. All other | ||
113 | changes are minor documentation changes. | ||
114 | |||
115 | 1.0 | ||
116 | ~~~ | ||
117 | Several minor bugfixes and enhancements: | ||
118 | |||
119 | * Large file support. The library uses 64-bit counters to | ||
120 | count the volume of data passing through it. bzip2.c | ||
121 | is now compiled with -D_FILE_OFFSET_BITS=64 to get large | ||
122 | file support from the C library. -v correctly prints out | ||
123 | file sizes greater than 4 gigabytes. All these changes have | ||
124 | been made without assuming a 64-bit platform or a C compiler | ||
125 | which supports 64-bit ints, so, except for the C library | ||
126 | aspect, they are fully portable. | ||
127 | |||
128 | * Decompression robustness. The library/program should be | ||
129 | robust to any corruption of compressed data, detecting and | ||
130 | handling _all_ corruption, instead of merely relying on | ||
131 | the CRCs. What this means is that the program should | ||
132 | never crash, given corrupted data, and the library should | ||
133 | always return BZ_DATA_ERROR. | ||
134 | |||
135 | * Fixed an obscure race-condition bug only ever observed on | ||
136 | Solaris, in which, if you were very unlucky and issued | ||
137 | control-C at exactly the wrong time, both input and output | ||
138 | files would be deleted. | ||
139 | |||
140 | * Don't run out of file handles on test/decompression when | ||
141 | large numbers of files have invalid magic numbers. | ||
142 | |||
143 | * Avoid library namespace pollution. Prefix all exported | ||
144 | symbols with BZ2_. | ||
145 | |||
146 | * Minor sorting enhancements from my DCC2000 paper. | ||
147 | |||
148 | * Advance the version number to 1.0, so as to counteract the | ||
149 | (false-in-this-case) impression some people have that programs | ||
150 | with version numbers less than 1.0 are in some way, experimental, | ||
151 | pre-release versions. | ||
152 | |||
153 | * Create an initial Makefile-libbz2_so to build a shared library. | ||
154 | Yes, I know I should really use libtool et al ... | ||
155 | |||
156 | * Make the program exit with 2 instead of 0 when decompression | ||
157 | fails due to a bad magic number (ie, an invalid bzip2 header). | ||
158 | Also exit with 1 (as the manual claims :-) whenever a diagnostic | ||
159 | message would have been printed AND the corresponding operation | ||
160 | is aborted, for example | ||
161 | bzip2: Output file xx already exists. | ||
162 | When a diagnostic message is printed but the operation is not | ||
163 | aborted, for example | ||
164 | bzip2: Can't guess original name for wurble -- using wurble.out | ||
165 | then the exit value 0 is returned, unless some other problem is | ||
166 | also detected. | ||
167 | |||
168 | I think it corresponds more closely to what the manual claims now. | ||
169 | |||
170 | |||
171 | 1.0.1 | ||
172 | ~~~~~ | ||
173 | * Modified dlltest.c so it uses the new BZ2_ naming scheme. | ||
174 | * Modified makefile-msc to fix minor build probs on Win2k. | ||
175 | * Updated README.COMPILATION.PROBLEMS. | ||
176 | |||
177 | There are no functionality changes or bug fixes relative to version | ||
178 | 1.0.0. This is just a documentation update + a fix for minor Win32 | ||
179 | build problems. For almost everyone, upgrading from 1.0.0 to 1.0.1 is | ||
180 | utterly pointless. Don't bother. | ||
181 | |||
182 | |||
183 | 1.0.2 | ||
184 | ~~~~~ | ||
185 | A bug fix release, addressing various minor issues which have appeared | ||
186 | in the 18 or so months since 1.0.1 was released. Most of the fixes | ||
187 | are to do with file-handling or documentation bugs. To the best of my | ||
188 | knowledge, there have been no data-loss-causing bugs reported in the | ||
189 | compression/decompression engine of 1.0.0 or 1.0.1. | ||
190 | |||
191 | Note that this release does not improve the rather crude build system | ||
192 | for Unix platforms. The general plan here is to autoconfiscate/ | ||
193 | libtoolise 1.0.2 soon after release, and release the result as 1.1.0 | ||
194 | or perhaps 1.2.0. That, however, is still just a plan at this point. | ||
195 | |||
196 | Here are the changes in 1.0.2. Bug-reporters and/or patch-senders in | ||
197 | parentheses. | ||
198 | |||
199 | * Fix an infinite segfault loop in 1.0.1 when a directory is | ||
200 | encountered in -f (force) mode. | ||
201 | (Trond Eivind Glomsrod, Nicholas Nethercote, Volker Schmidt) | ||
202 | |||
203 | * Avoid double fclose() of output file on certain I/O error paths. | ||
204 | (Solar Designer) | ||
205 | |||
206 | * Don't fail with internal error 1007 when fed a long stream (> 48MB) | ||
207 | of byte 251. Also print useful message suggesting that 1007s may be | ||
208 | caused by bad memory. | ||
209 | (noticed by Juan Pedro Vallejo, fixed by me) | ||
210 | |||
211 | * Fix uninitialised variable silly bug in demo prog dlltest.c. | ||
212 | (Jorj Bauer) | ||
213 | |||
214 | * Remove 512-MB limitation on recovered file size for bzip2recover | ||
215 | on selected platforms which support 64-bit ints. At the moment | ||
216 | all GCC supported platforms, and Win32. | ||
217 | (me, Alson van der Meulen) | ||
218 | |||
219 | * Hard-code header byte values, to give correct operation on platforms | ||
220 | using EBCDIC as their native character set (IBM's OS/390). | ||
221 | (Leland Lucius) | ||
222 | |||
223 | * Copy file access times correctly. | ||
224 | (Marty Leisner) | ||
225 | |||
226 | * Add distclean and check targets to Makefile. | ||
227 | (Michael Carmack) | ||
228 | |||
229 | * Parameterise use of ar and ranlib in Makefile. Also add $(LDFLAGS). | ||
230 | (Rich Ireland, Bo Thorsen) | ||
231 | |||
232 | * Pass -p (create parent dirs as needed) to mkdir during make install. | ||
233 | (Jeremy Fusco) | ||
234 | |||
235 | * Dereference symlinks when copying file permissions in -f mode. | ||
236 | (Volker Schmidt) | ||
237 | |||
238 | * Majorly simplify implementation of uInt64_qrm10. | ||
239 | (Bo Lindbergh) | ||
240 | |||
241 | * Check the input file still exists before deleting the output one, | ||
242 | when aborting in cleanUpAndFail(). | ||
243 | (Joerg Prante, Robert Linden, Matthias Krings) | ||
244 | |||
245 | Also a bunch of patches courtesy of Philippe Troin, the Debian maintainer | ||
246 | of bzip2: | ||
247 | |||
248 | * Wrapper scripts (with manpages): bzdiff, bzgrep, bzmore. | ||
249 | |||
250 | * Spelling changes and minor enhancements in bzip2.1. | ||
251 | |||
252 | * Avoid race condition between creating the output file and setting its | ||
253 | interim permissions safely, by using fopen_output_safely(). | ||
254 | No changes to bzip2recover since there is no issue with file | ||
255 | permissions there. | ||
256 | |||
257 | * do not print senseless report with -v when compressing an empty | ||
258 | file. | ||
259 | |||
260 | * bzcat -f works on non-bzip2 files. | ||
261 | |||
262 | * do not try to escape shell meta-characters on unix (the shell takes | ||
263 | care of these). | ||
264 | |||
265 | * added --fast and --best aliases for -1 -9 for gzip compatibility. | ||
266 | |||
267 | |||
268 | 1.0.3 (15 Feb 05) | ||
269 | ~~~~~~~~~~~~~~~~~ | ||
270 | Fixes some minor bugs since the last version, 1.0.2. | ||
271 | |||
272 | * Further robustification against corrupted compressed data. | ||
273 | There are currently no known bitstreams which can cause the | ||
274 | decompressor to crash, loop or access memory which does not | ||
275 | belong to it. If you are using bzip2 or the library to | ||
276 | decompress bitstreams from untrusted sources, an upgrade | ||
277 | to 1.0.3 is recommended. This fixes CAN-2005-1260. | ||
278 | |||
279 | * The documentation has been converted to XML, from which html | ||
280 | and pdf can be derived. | ||
281 | |||
282 | * Various minor bugs in the documentation have been fixed. | ||
283 | |||
284 | * Fixes for various compilation warnings with newer versions of | ||
285 | gcc, and on 64-bit platforms. | ||
286 | |||
287 | * The BZ_NO_STDIO cpp symbol was not properly observed in 1.0.2. | ||
288 | This has been fixed. | ||
289 | |||
290 | |||
291 | 1.0.4 (20 Dec 06) | ||
292 | ~~~~~~~~~~~~~~~~~ | ||
293 | Fixes some minor bugs since the last version, 1.0.3. | ||
294 | |||
295 | * Fix file permissions race problem (CAN-2005-0953). | ||
296 | |||
297 | * Avoid possible segfault in BZ2_bzclose. From Coverity's NetBSD | ||
298 | scan. | ||
299 | |||
300 | * 'const'/prototype cleanups in the C code. | ||
301 | |||
302 | * Change default install location to /usr/local, and handle multiple | ||
303 | 'make install's without error. | ||
304 | |||
305 | * Sanitise file names more carefully in bzgrep. Fixes CAN-2005-0758 | ||
306 | to the extent that applies to bzgrep. | ||
307 | |||
308 | * Use 'mktemp' rather than 'tempfile' in bzdiff. | ||
309 | |||
310 | * Tighten up a couple of assertions in blocksort.c following automated | ||
311 | analysis. | ||
312 | |||
313 | * Fix minor doc/comment bugs. | ||
314 | |||
315 | |||
316 | 1.0.5 (10 Dec 07) | ||
317 | ~~~~~~~~~~~~~~~~~ | ||
318 | Security fix only. Fixes CERT-FI 20469 as it applies to bzip2. | ||
319 | |||
320 | |||
321 | 1.0.6 (6 Sept 10) | ||
322 | ~~~~~~~~~~~~~~~~~ | ||
323 | |||
324 | * Security fix for CVE-2010-0405. This was reported by Mikolaj | ||
325 | Izdebski. | ||
326 | |||
327 | * Make the documentation build on Ubuntu 10.04 | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/LICENSE b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/LICENSE new file mode 100644 index 0000000..cc61417 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/LICENSE | |||
@@ -0,0 +1,42 @@ | |||
1 | |||
2 | -------------------------------------------------------------------------- | ||
3 | |||
4 | This program, "bzip2", the associated library "libbzip2", and all | ||
5 | documentation, are copyright (C) 1996-2010 Julian R Seward. All | ||
6 | rights reserved. | ||
7 | |||
8 | Redistribution and use in source and binary forms, with or without | ||
9 | modification, are permitted provided that the following conditions | ||
10 | are met: | ||
11 | |||
12 | 1. Redistributions of source code must retain the above copyright | ||
13 | notice, this list of conditions and the following disclaimer. | ||
14 | |||
15 | 2. The origin of this software must not be misrepresented; you must | ||
16 | not claim that you wrote the original software. If you use this | ||
17 | software in a product, an acknowledgment in the product | ||
18 | documentation would be appreciated but is not required. | ||
19 | |||
20 | 3. Altered source versions must be plainly marked as such, and must | ||
21 | not be misrepresented as being the original software. | ||
22 | |||
23 | 4. The name of the author may not be used to endorse or promote | ||
24 | products derived from this software without specific prior written | ||
25 | permission. | ||
26 | |||
27 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS | ||
28 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
29 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
30 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | ||
31 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
32 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | ||
33 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
34 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
35 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
36 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
37 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
38 | |||
39 | Julian Seward, jseward@bzip.org | ||
40 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | ||
41 | |||
42 | -------------------------------------------------------------------------- | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/Makefile b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/Makefile new file mode 100644 index 0000000..9754ddf --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/Makefile | |||
@@ -0,0 +1,217 @@ | |||
1 | # ------------------------------------------------------------------ | ||
2 | # This file is part of bzip2/libbzip2, a program and library for | ||
3 | # lossless, block-sorting data compression. | ||
4 | # | ||
5 | # bzip2/libbzip2 version 1.0.6 of 6 September 2010 | ||
6 | # Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | ||
7 | # | ||
8 | # Please read the WARNING, DISCLAIMER and PATENTS sections in the | ||
9 | # README file. | ||
10 | # | ||
11 | # This program is released under the terms of the license contained | ||
12 | # in the file LICENSE. | ||
13 | # ------------------------------------------------------------------ | ||
14 | |||
15 | SHELL=/bin/sh | ||
16 | |||
17 | # To assist in cross-compiling | ||
18 | CC=gcc | ||
19 | AR=ar | ||
20 | RANLIB=ranlib | ||
21 | LDFLAGS= | ||
22 | |||
23 | BIGFILES=-D_FILE_OFFSET_BITS=64 | ||
24 | CFLAGS=-Wall -Winline -O2 -g $(BIGFILES) | ||
25 | |||
26 | # Where you want it installed when you do 'make install' | ||
27 | PREFIX=/usr/local | ||
28 | |||
29 | |||
30 | OBJS= blocksort.o \ | ||
31 | huffman.o \ | ||
32 | crctable.o \ | ||
33 | randtable.o \ | ||
34 | compress.o \ | ||
35 | decompress.o \ | ||
36 | bzlib.o | ||
37 | |||
38 | all: libbz2.a bzip2 bzip2recover test | ||
39 | |||
40 | bzip2: libbz2.a bzip2.o | ||
41 | $(CC) $(CFLAGS) $(LDFLAGS) -o bzip2 bzip2.o -L. -lbz2 | ||
42 | |||
43 | bzip2recover: bzip2recover.o | ||
44 | $(CC) $(CFLAGS) $(LDFLAGS) -o bzip2recover bzip2recover.o | ||
45 | |||
46 | libbz2.a: $(OBJS) | ||
47 | rm -f libbz2.a | ||
48 | $(AR) cq libbz2.a $(OBJS) | ||
49 | @if ( test -f $(RANLIB) -o -f /usr/bin/ranlib -o \ | ||
50 | -f /bin/ranlib -o -f /usr/ccs/bin/ranlib ) ; then \ | ||
51 | echo $(RANLIB) libbz2.a ; \ | ||
52 | $(RANLIB) libbz2.a ; \ | ||
53 | fi | ||
54 | |||
55 | check: test | ||
56 | test: bzip2 | ||
57 | @cat words1 | ||
58 | ./bzip2 -1 < sample1.ref > sample1.rb2 | ||
59 | ./bzip2 -2 < sample2.ref > sample2.rb2 | ||
60 | ./bzip2 -3 < sample3.ref > sample3.rb2 | ||
61 | ./bzip2 -d < sample1.bz2 > sample1.tst | ||
62 | ./bzip2 -d < sample2.bz2 > sample2.tst | ||
63 | ./bzip2 -ds < sample3.bz2 > sample3.tst | ||
64 | cmp sample1.bz2 sample1.rb2 | ||
65 | cmp sample2.bz2 sample2.rb2 | ||
66 | cmp sample3.bz2 sample3.rb2 | ||
67 | cmp sample1.tst sample1.ref | ||
68 | cmp sample2.tst sample2.ref | ||
69 | cmp sample3.tst sample3.ref | ||
70 | @cat words3 | ||
71 | |||
72 | install: bzip2 bzip2recover | ||
73 | if ( test ! -d $(PREFIX)/bin ) ; then mkdir -p $(PREFIX)/bin ; fi | ||
74 | if ( test ! -d $(PREFIX)/lib ) ; then mkdir -p $(PREFIX)/lib ; fi | ||
75 | if ( test ! -d $(PREFIX)/man ) ; then mkdir -p $(PREFIX)/man ; fi | ||
76 | if ( test ! -d $(PREFIX)/man/man1 ) ; then mkdir -p $(PREFIX)/man/man1 ; fi | ||
77 | if ( test ! -d $(PREFIX)/include ) ; then mkdir -p $(PREFIX)/include ; fi | ||
78 | cp -f bzip2 $(PREFIX)/bin/bzip2 | ||
79 | cp -f bzip2 $(PREFIX)/bin/bunzip2 | ||
80 | cp -f bzip2 $(PREFIX)/bin/bzcat | ||
81 | cp -f bzip2recover $(PREFIX)/bin/bzip2recover | ||
82 | chmod a+x $(PREFIX)/bin/bzip2 | ||
83 | chmod a+x $(PREFIX)/bin/bunzip2 | ||
84 | chmod a+x $(PREFIX)/bin/bzcat | ||
85 | chmod a+x $(PREFIX)/bin/bzip2recover | ||
86 | cp -f bzip2.1 $(PREFIX)/man/man1 | ||
87 | chmod a+r $(PREFIX)/man/man1/bzip2.1 | ||
88 | cp -f bzlib.h $(PREFIX)/include | ||
89 | chmod a+r $(PREFIX)/include/bzlib.h | ||
90 | cp -f libbz2.a $(PREFIX)/lib | ||
91 | chmod a+r $(PREFIX)/lib/libbz2.a | ||
92 | cp -f bzgrep $(PREFIX)/bin/bzgrep | ||
93 | ln -s -f $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzegrep | ||
94 | ln -s -f $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzfgrep | ||
95 | chmod a+x $(PREFIX)/bin/bzgrep | ||
96 | cp -f bzmore $(PREFIX)/bin/bzmore | ||
97 | ln -s -f $(PREFIX)/bin/bzmore $(PREFIX)/bin/bzless | ||
98 | chmod a+x $(PREFIX)/bin/bzmore | ||
99 | cp -f bzdiff $(PREFIX)/bin/bzdiff | ||
100 | ln -s -f $(PREFIX)/bin/bzdiff $(PREFIX)/bin/bzcmp | ||
101 | chmod a+x $(PREFIX)/bin/bzdiff | ||
102 | cp -f bzgrep.1 bzmore.1 bzdiff.1 $(PREFIX)/man/man1 | ||
103 | chmod a+r $(PREFIX)/man/man1/bzgrep.1 | ||
104 | chmod a+r $(PREFIX)/man/man1/bzmore.1 | ||
105 | chmod a+r $(PREFIX)/man/man1/bzdiff.1 | ||
106 | echo ".so man1/bzgrep.1" > $(PREFIX)/man/man1/bzegrep.1 | ||
107 | echo ".so man1/bzgrep.1" > $(PREFIX)/man/man1/bzfgrep.1 | ||
108 | echo ".so man1/bzmore.1" > $(PREFIX)/man/man1/bzless.1 | ||
109 | echo ".so man1/bzdiff.1" > $(PREFIX)/man/man1/bzcmp.1 | ||
110 | |||
111 | clean: | ||
112 | rm -f *.o libbz2.a bzip2 bzip2recover \ | ||
113 | sample1.rb2 sample2.rb2 sample3.rb2 \ | ||
114 | sample1.tst sample2.tst sample3.tst | ||
115 | |||
116 | blocksort.o: blocksort.c | ||
117 | @cat words0 | ||
118 | $(CC) $(CFLAGS) -c blocksort.c | ||
119 | huffman.o: huffman.c | ||
120 | $(CC) $(CFLAGS) -c huffman.c | ||
121 | crctable.o: crctable.c | ||
122 | $(CC) $(CFLAGS) -c crctable.c | ||
123 | randtable.o: randtable.c | ||
124 | $(CC) $(CFLAGS) -c randtable.c | ||
125 | compress.o: compress.c | ||
126 | $(CC) $(CFLAGS) -c compress.c | ||
127 | decompress.o: decompress.c | ||
128 | $(CC) $(CFLAGS) -c decompress.c | ||
129 | bzlib.o: bzlib.c | ||
130 | $(CC) $(CFLAGS) -c bzlib.c | ||
131 | bzip2.o: bzip2.c | ||
132 | $(CC) $(CFLAGS) -c bzip2.c | ||
133 | bzip2recover.o: bzip2recover.c | ||
134 | $(CC) $(CFLAGS) -c bzip2recover.c | ||
135 | |||
136 | |||
137 | distclean: clean | ||
138 | rm -f manual.ps manual.html manual.pdf | ||
139 | |||
140 | DISTNAME=bzip2-1.0.6 | ||
141 | dist: check manual | ||
142 | rm -f $(DISTNAME) | ||
143 | ln -s -f . $(DISTNAME) | ||
144 | tar cvf $(DISTNAME).tar \ | ||
145 | $(DISTNAME)/blocksort.c \ | ||
146 | $(DISTNAME)/huffman.c \ | ||
147 | $(DISTNAME)/crctable.c \ | ||
148 | $(DISTNAME)/randtable.c \ | ||
149 | $(DISTNAME)/compress.c \ | ||
150 | $(DISTNAME)/decompress.c \ | ||
151 | $(DISTNAME)/bzlib.c \ | ||
152 | $(DISTNAME)/bzip2.c \ | ||
153 | $(DISTNAME)/bzip2recover.c \ | ||
154 | $(DISTNAME)/bzlib.h \ | ||
155 | $(DISTNAME)/bzlib_private.h \ | ||
156 | $(DISTNAME)/Makefile \ | ||
157 | $(DISTNAME)/LICENSE \ | ||
158 | $(DISTNAME)/bzip2.1 \ | ||
159 | $(DISTNAME)/bzip2.1.preformatted \ | ||
160 | $(DISTNAME)/bzip2.txt \ | ||
161 | $(DISTNAME)/words0 \ | ||
162 | $(DISTNAME)/words1 \ | ||
163 | $(DISTNAME)/words2 \ | ||
164 | $(DISTNAME)/words3 \ | ||
165 | $(DISTNAME)/sample1.ref \ | ||
166 | $(DISTNAME)/sample2.ref \ | ||
167 | $(DISTNAME)/sample3.ref \ | ||
168 | $(DISTNAME)/sample1.bz2 \ | ||
169 | $(DISTNAME)/sample2.bz2 \ | ||
170 | $(DISTNAME)/sample3.bz2 \ | ||
171 | $(DISTNAME)/dlltest.c \ | ||
172 | $(DISTNAME)/manual.html \ | ||
173 | $(DISTNAME)/manual.pdf \ | ||
174 | $(DISTNAME)/manual.ps \ | ||
175 | $(DISTNAME)/README \ | ||
176 | $(DISTNAME)/README.COMPILATION.PROBLEMS \ | ||
177 | $(DISTNAME)/README.XML.STUFF \ | ||
178 | $(DISTNAME)/CHANGES \ | ||
179 | $(DISTNAME)/libbz2.def \ | ||
180 | $(DISTNAME)/libbz2.dsp \ | ||
181 | $(DISTNAME)/dlltest.dsp \ | ||
182 | $(DISTNAME)/makefile.msc \ | ||
183 | $(DISTNAME)/unzcrash.c \ | ||
184 | $(DISTNAME)/spewG.c \ | ||
185 | $(DISTNAME)/mk251.c \ | ||
186 | $(DISTNAME)/bzdiff \ | ||
187 | $(DISTNAME)/bzdiff.1 \ | ||
188 | $(DISTNAME)/bzmore \ | ||
189 | $(DISTNAME)/bzmore.1 \ | ||
190 | $(DISTNAME)/bzgrep \ | ||
191 | $(DISTNAME)/bzgrep.1 \ | ||
192 | $(DISTNAME)/Makefile-libbz2_so \ | ||
193 | $(DISTNAME)/bz-common.xsl \ | ||
194 | $(DISTNAME)/bz-fo.xsl \ | ||
195 | $(DISTNAME)/bz-html.xsl \ | ||
196 | $(DISTNAME)/bzip.css \ | ||
197 | $(DISTNAME)/entities.xml \ | ||
198 | $(DISTNAME)/manual.xml \ | ||
199 | $(DISTNAME)/format.pl \ | ||
200 | $(DISTNAME)/xmlproc.sh | ||
201 | gzip -v $(DISTNAME).tar | ||
202 | |||
203 | # For rebuilding the manual from sources on my SuSE 9.1 box | ||
204 | |||
205 | MANUAL_SRCS= bz-common.xsl bz-fo.xsl bz-html.xsl bzip.css \ | ||
206 | entities.xml manual.xml | ||
207 | |||
208 | manual: manual.html manual.ps manual.pdf | ||
209 | |||
210 | manual.ps: $(MANUAL_SRCS) | ||
211 | ./xmlproc.sh -ps manual.xml | ||
212 | |||
213 | manual.pdf: $(MANUAL_SRCS) | ||
214 | ./xmlproc.sh -pdf manual.xml | ||
215 | |||
216 | manual.html: $(MANUAL_SRCS) | ||
217 | ./xmlproc.sh -html manual.xml | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/Makefile-libbz2_so b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/Makefile-libbz2_so new file mode 100644 index 0000000..e58791b --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/Makefile-libbz2_so | |||
@@ -0,0 +1,59 @@ | |||
1 | |||
2 | # This Makefile builds a shared version of the library, | ||
3 | # libbz2.so.1.0.6, with soname libbz2.so.1.0, | ||
4 | # at least on x86-Linux (RedHat 7.2), | ||
5 | # with gcc-2.96 20000731 (Red Hat Linux 7.1 2.96-98). | ||
6 | # Please see the README file for some important info | ||
7 | # about building the library like this. | ||
8 | |||
9 | # ------------------------------------------------------------------ | ||
10 | # This file is part of bzip2/libbzip2, a program and library for | ||
11 | # lossless, block-sorting data compression. | ||
12 | # | ||
13 | # bzip2/libbzip2 version 1.0.6 of 6 September 2010 | ||
14 | # Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | ||
15 | # | ||
16 | # Please read the WARNING, DISCLAIMER and PATENTS sections in the | ||
17 | # README file. | ||
18 | # | ||
19 | # This program is released under the terms of the license contained | ||
20 | # in the file LICENSE. | ||
21 | # ------------------------------------------------------------------ | ||
22 | |||
23 | |||
24 | SHELL=/bin/sh | ||
25 | CC=gcc | ||
26 | BIGFILES=-D_FILE_OFFSET_BITS=64 | ||
27 | CFLAGS=-fpic -fPIC -Wall -Winline -O2 -g $(BIGFILES) | ||
28 | |||
29 | OBJS= blocksort.o \ | ||
30 | huffman.o \ | ||
31 | crctable.o \ | ||
32 | randtable.o \ | ||
33 | compress.o \ | ||
34 | decompress.o \ | ||
35 | bzlib.o | ||
36 | |||
37 | all: $(OBJS) | ||
38 | $(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.6 $(OBJS) | ||
39 | $(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.6 | ||
40 | rm -f libbz2.so.1.0 | ||
41 | ln -s libbz2.so.1.0.6 libbz2.so.1.0 | ||
42 | |||
43 | clean: | ||
44 | rm -f $(OBJS) bzip2.o libbz2.so.1.0.6 libbz2.so.1.0 bzip2-shared | ||
45 | |||
46 | blocksort.o: blocksort.c | ||
47 | $(CC) $(CFLAGS) -c blocksort.c | ||
48 | huffman.o: huffman.c | ||
49 | $(CC) $(CFLAGS) -c huffman.c | ||
50 | crctable.o: crctable.c | ||
51 | $(CC) $(CFLAGS) -c crctable.c | ||
52 | randtable.o: randtable.c | ||
53 | $(CC) $(CFLAGS) -c randtable.c | ||
54 | compress.o: compress.c | ||
55 | $(CC) $(CFLAGS) -c compress.c | ||
56 | decompress.o: decompress.c | ||
57 | $(CC) $(CFLAGS) -c decompress.c | ||
58 | bzlib.o: bzlib.c | ||
59 | $(CC) $(CFLAGS) -c bzlib.c | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/README b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/README new file mode 100644 index 0000000..9fb0f63 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/README | |||
@@ -0,0 +1,215 @@ | |||
1 | |||
2 | This is the README for bzip2/libzip2. | ||
3 | This version is fully compatible with the previous public releases. | ||
4 | |||
5 | ------------------------------------------------------------------ | ||
6 | This file is part of bzip2/libbzip2, a program and library for | ||
7 | lossless, block-sorting data compression. | ||
8 | |||
9 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | ||
10 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | ||
11 | |||
12 | Please read the WARNING, DISCLAIMER and PATENTS sections in this file. | ||
13 | |||
14 | This program is released under the terms of the license contained | ||
15 | in the file LICENSE. | ||
16 | ------------------------------------------------------------------ | ||
17 | |||
18 | Complete documentation is available in Postscript form (manual.ps), | ||
19 | PDF (manual.pdf) or html (manual.html). A plain-text version of the | ||
20 | manual page is available as bzip2.txt. | ||
21 | |||
22 | |||
23 | HOW TO BUILD -- UNIX | ||
24 | |||
25 | Type 'make'. This builds the library libbz2.a and then the programs | ||
26 | bzip2 and bzip2recover. Six self-tests are run. If the self-tests | ||
27 | complete ok, carry on to installation: | ||
28 | |||
29 | To install in /usr/local/bin, /usr/local/lib, /usr/local/man and | ||
30 | /usr/local/include, type | ||
31 | |||
32 | make install | ||
33 | |||
34 | To install somewhere else, eg, /xxx/yyy/{bin,lib,man,include}, type | ||
35 | |||
36 | make install PREFIX=/xxx/yyy | ||
37 | |||
38 | If you are (justifiably) paranoid and want to see what 'make install' | ||
39 | is going to do, you can first do | ||
40 | |||
41 | make -n install or | ||
42 | make -n install PREFIX=/xxx/yyy respectively. | ||
43 | |||
44 | The -n instructs make to show the commands it would execute, but not | ||
45 | actually execute them. | ||
46 | |||
47 | |||
48 | HOW TO BUILD -- UNIX, shared library libbz2.so. | ||
49 | |||
50 | Do 'make -f Makefile-libbz2_so'. This Makefile seems to work for | ||
51 | Linux-ELF (RedHat 7.2 on an x86 box), with gcc. I make no claims | ||
52 | that it works for any other platform, though I suspect it probably | ||
53 | will work for most platforms employing both ELF and gcc. | ||
54 | |||
55 | bzip2-shared, a client of the shared library, is also built, but not | ||
56 | self-tested. So I suggest you also build using the normal Makefile, | ||
57 | since that conducts a self-test. A second reason to prefer the | ||
58 | version statically linked to the library is that, on x86 platforms, | ||
59 | building shared objects makes a valuable register (%ebx) unavailable | ||
60 | to gcc, resulting in a slowdown of 10%-20%, at least for bzip2. | ||
61 | |||
62 | Important note for people upgrading .so's from 0.9.0/0.9.5 to version | ||
63 | 1.0.X. All the functions in the library have been renamed, from (eg) | ||
64 | bzCompress to BZ2_bzCompress, to avoid namespace pollution. | ||
65 | Unfortunately this means that the libbz2.so created by | ||
66 | Makefile-libbz2_so will not work with any program which used an older | ||
67 | version of the library. I do encourage library clients to make the | ||
68 | effort to upgrade to use version 1.0, since it is both faster and more | ||
69 | robust than previous versions. | ||
70 | |||
71 | |||
72 | HOW TO BUILD -- Windows 95, NT, DOS, Mac, etc. | ||
73 | |||
74 | It's difficult for me to support compilation on all these platforms. | ||
75 | My approach is to collect binaries for these platforms, and put them | ||
76 | on the master web site (http://www.bzip.org). Look there. However | ||
77 | (FWIW), bzip2-1.0.X is very standard ANSI C and should compile | ||
78 | unmodified with MS Visual C. If you have difficulties building, you | ||
79 | might want to read README.COMPILATION.PROBLEMS. | ||
80 | |||
81 | At least using MS Visual C++ 6, you can build from the unmodified | ||
82 | sources by issuing, in a command shell: | ||
83 | |||
84 | nmake -f makefile.msc | ||
85 | |||
86 | (you may need to first run the MSVC-provided script VCVARS32.BAT | ||
87 | so as to set up paths to the MSVC tools correctly). | ||
88 | |||
89 | |||
90 | VALIDATION | ||
91 | |||
92 | Correct operation, in the sense that a compressed file can always be | ||
93 | decompressed to reproduce the original, is obviously of paramount | ||
94 | importance. To validate bzip2, I used a modified version of Mark | ||
95 | Nelson's churn program. Churn is an automated test driver which | ||
96 | recursively traverses a directory structure, using bzip2 to compress | ||
97 | and then decompress each file it encounters, and checking that the | ||
98 | decompressed data is the same as the original. | ||
99 | |||
100 | |||
101 | |||
102 | Please read and be aware of the following: | ||
103 | |||
104 | WARNING: | ||
105 | |||
106 | This program and library (attempts to) compress data by | ||
107 | performing several non-trivial transformations on it. | ||
108 | Unless you are 100% familiar with *all* the algorithms | ||
109 | contained herein, and with the consequences of modifying them, | ||
110 | you should NOT meddle with the compression or decompression | ||
111 | machinery. Incorrect changes can and very likely *will* | ||
112 | lead to disastrous loss of data. | ||
113 | |||
114 | |||
115 | DISCLAIMER: | ||
116 | |||
117 | I TAKE NO RESPONSIBILITY FOR ANY LOSS OF DATA ARISING FROM THE | ||
118 | USE OF THIS PROGRAM/LIBRARY, HOWSOEVER CAUSED. | ||
119 | |||
120 | Every compression of a file implies an assumption that the | ||
121 | compressed file can be decompressed to reproduce the original. | ||
122 | Great efforts in design, coding and testing have been made to | ||
123 | ensure that this program works correctly. However, the complexity | ||
124 | of the algorithms, and, in particular, the presence of various | ||
125 | special cases in the code which occur with very low but non-zero | ||
126 | probability make it impossible to rule out the possibility of bugs | ||
127 | remaining in the program. DO NOT COMPRESS ANY DATA WITH THIS | ||
128 | PROGRAM UNLESS YOU ARE PREPARED TO ACCEPT THE POSSIBILITY, HOWEVER | ||
129 | SMALL, THAT THE DATA WILL NOT BE RECOVERABLE. | ||
130 | |||
131 | That is not to say this program is inherently unreliable. | ||
132 | Indeed, I very much hope the opposite is true. bzip2/libbzip2 | ||
133 | has been carefully constructed and extensively tested. | ||
134 | |||
135 | |||
136 | PATENTS: | ||
137 | |||
138 | To the best of my knowledge, bzip2/libbzip2 does not use any | ||
139 | patented algorithms. However, I do not have the resources | ||
140 | to carry out a patent search. Therefore I cannot give any | ||
141 | guarantee of the above statement. | ||
142 | |||
143 | |||
144 | |||
145 | WHAT'S NEW IN 0.9.0 (as compared to 0.1pl2) ? | ||
146 | |||
147 | * Approx 10% faster compression, 30% faster decompression | ||
148 | * -t (test mode) is a lot quicker | ||
149 | * Can decompress concatenated compressed files | ||
150 | * Programming interface, so programs can directly read/write .bz2 files | ||
151 | * Less restrictive (BSD-style) licensing | ||
152 | * Flag handling more compatible with GNU gzip | ||
153 | * Much more documentation, i.e., a proper user manual | ||
154 | * Hopefully, improved portability (at least of the library) | ||
155 | |||
156 | WHAT'S NEW IN 0.9.5 ? | ||
157 | |||
158 | * Compression speed is much less sensitive to the input | ||
159 | data than in previous versions. Specifically, the very | ||
160 | slow performance caused by repetitive data is fixed. | ||
161 | * Many small improvements in file and flag handling. | ||
162 | * A Y2K statement. | ||
163 | |||
164 | WHAT'S NEW IN 1.0.0 ? | ||
165 | |||
166 | See the CHANGES file. | ||
167 | |||
168 | WHAT'S NEW IN 1.0.2 ? | ||
169 | |||
170 | See the CHANGES file. | ||
171 | |||
172 | WHAT'S NEW IN 1.0.3 ? | ||
173 | |||
174 | See the CHANGES file. | ||
175 | |||
176 | WHAT'S NEW IN 1.0.4 ? | ||
177 | |||
178 | See the CHANGES file. | ||
179 | |||
180 | WHAT'S NEW IN 1.0.5 ? | ||
181 | |||
182 | See the CHANGES file. | ||
183 | |||
184 | WHAT'S NEW IN 1.0.6 ? | ||
185 | |||
186 | See the CHANGES file. | ||
187 | |||
188 | |||
189 | I hope you find bzip2 useful. Feel free to contact me at | ||
190 | jseward@bzip.org | ||
191 | if you have any suggestions or queries. Many people mailed me with | ||
192 | comments, suggestions and patches after the releases of bzip-0.15, | ||
193 | bzip-0.21, and bzip2 versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1, | ||
194 | 1.0.2 and 1.0.3, and the changes in bzip2 are largely a result of this | ||
195 | feedback. I thank you for your comments. | ||
196 | |||
197 | bzip2's "home" is http://www.bzip.org/ | ||
198 | |||
199 | Julian Seward | ||
200 | jseward@bzip.org | ||
201 | Cambridge, UK. | ||
202 | |||
203 | 18 July 1996 (version 0.15) | ||
204 | 25 August 1996 (version 0.21) | ||
205 | 7 August 1997 (bzip2, version 0.1) | ||
206 | 29 August 1997 (bzip2, version 0.1pl2) | ||
207 | 23 August 1998 (bzip2, version 0.9.0) | ||
208 | 8 June 1999 (bzip2, version 0.9.5) | ||
209 | 4 Sept 1999 (bzip2, version 0.9.5d) | ||
210 | 5 May 2000 (bzip2, version 1.0pre8) | ||
211 | 30 December 2001 (bzip2, version 1.0.2pre1) | ||
212 | 15 February 2005 (bzip2, version 1.0.3) | ||
213 | 20 December 2006 (bzip2, version 1.0.4) | ||
214 | 10 December 2007 (bzip2, version 1.0.5) | ||
215 | 6 Sept 2010 (bzip2, version 1.0.6) | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/README.COMPILATION.PROBLEMS b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/README.COMPILATION.PROBLEMS new file mode 100644 index 0000000..667d0d6 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/README.COMPILATION.PROBLEMS | |||
@@ -0,0 +1,58 @@ | |||
1 | ------------------------------------------------------------------ | ||
2 | This file is part of bzip2/libbzip2, a program and library for | ||
3 | lossless, block-sorting data compression. | ||
4 | |||
5 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | ||
6 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | ||
7 | |||
8 | Please read the WARNING, DISCLAIMER and PATENTS sections in the | ||
9 | README file. | ||
10 | |||
11 | This program is released under the terms of the license contained | ||
12 | in the file LICENSE. | ||
13 | ------------------------------------------------------------------ | ||
14 | |||
15 | bzip2-1.0.6 should compile without problems on the vast majority of | ||
16 | platforms. Using the supplied Makefile, I've built and tested it | ||
17 | myself for x86-linux and amd64-linux. With makefile.msc, Visual C++ | ||
18 | 6.0 and nmake, you can build a native Win32 version too. Large file | ||
19 | support seems to work correctly on at least on amd64-linux. | ||
20 | |||
21 | When I say "large file" I mean a file of size 2,147,483,648 (2^31) | ||
22 | bytes or above. Many older OSs can't handle files above this size, | ||
23 | but many newer ones can. Large files are pretty huge -- most files | ||
24 | you'll encounter are not Large Files. | ||
25 | |||
26 | Early versions of bzip2 (0.1, 0.9.0, 0.9.5) compiled on a wide variety | ||
27 | of platforms without difficulty, and I hope this version will continue | ||
28 | in that tradition. However, in order to support large files, I've had | ||
29 | to include the define -D_FILE_OFFSET_BITS=64 in the Makefile. This | ||
30 | can cause problems. | ||
31 | |||
32 | The technique of adding -D_FILE_OFFSET_BITS=64 to get large file | ||
33 | support is, as far as I know, the Recommended Way to get correct large | ||
34 | file support. For more details, see the Large File Support | ||
35 | Specification, published by the Large File Summit, at | ||
36 | |||
37 | http://ftp.sas.com/standards/large.file | ||
38 | |||
39 | As a general comment, if you get compilation errors which you think | ||
40 | are related to large file support, try removing the above define from | ||
41 | the Makefile, ie, delete the line | ||
42 | |||
43 | BIGFILES=-D_FILE_OFFSET_BITS=64 | ||
44 | |||
45 | from the Makefile, and do 'make clean ; make'. This will give you a | ||
46 | version of bzip2 without large file support, which, for most | ||
47 | applications, is probably not a problem. | ||
48 | |||
49 | Alternatively, try some of the platform-specific hints listed below. | ||
50 | |||
51 | You can use the spewG.c program to generate huge files to test bzip2's | ||
52 | large file support, if you are feeling paranoid. Be aware though that | ||
53 | any compilation problems which affect bzip2 will also affect spewG.c, | ||
54 | alas. | ||
55 | |||
56 | AIX: I have reports that for large file support, you need to specify | ||
57 | -D_LARGE_FILES rather than -D_FILE_OFFSET_BITS=64. I have not tested | ||
58 | this myself. | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/README.XML.STUFF b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/README.XML.STUFF new file mode 100644 index 0000000..3a57f3f --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/README.XML.STUFF | |||
@@ -0,0 +1,45 @@ | |||
1 | ---------------------------------------------------------------- | ||
2 | This file is part of bzip2/libbzip2, a program and library for | ||
3 | lossless, block-sorting data compression. | ||
4 | |||
5 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | ||
6 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | ||
7 | |||
8 | Please read the WARNING, DISCLAIMER and PATENTS sections in the | ||
9 | README file. | ||
10 | |||
11 | This program is released under the terms of the license contained | ||
12 | in the file LICENSE. | ||
13 | ---------------------------------------------------------------- | ||
14 | |||
15 | The script xmlproc.sh takes an xml file as input, | ||
16 | and processes it to create .pdf, .html or .ps output. | ||
17 | It uses format.pl, a perl script to format <pre> blocks nicely, | ||
18 | and add CDATA tags so writers do not have to use eg. < | ||
19 | |||
20 | The file "entities.xml" must be edited to reflect current | ||
21 | version, year, etc. | ||
22 | |||
23 | |||
24 | Usage: | ||
25 | |||
26 | ./xmlproc.sh -v manual.xml | ||
27 | Validates an xml file to ensure no dtd-compliance errors | ||
28 | |||
29 | ./xmlproc.sh -html manual.xml | ||
30 | Output: manual.html | ||
31 | |||
32 | ./xmlproc.sh -pdf manual.xml | ||
33 | Output: manual.pdf | ||
34 | |||
35 | ./xmlproc.sh -ps manual.xml | ||
36 | Output: manual.ps | ||
37 | |||
38 | |||
39 | Notum bene: | ||
40 | - pdfxmltex barfs if given a filename with an underscore in it | ||
41 | |||
42 | - xmltex won't work yet - there's a bug in passivetex | ||
43 | which we are all waiting for Sebastian to fix. | ||
44 | So we are going the xml -> pdf -> ps route for the time being, | ||
45 | using pdfxmltex. | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/blocksort.c b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/blocksort.c new file mode 100644 index 0000000..d0d662c --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/blocksort.c | |||
@@ -0,0 +1,1094 @@ | |||
1 | |||
2 | /*-------------------------------------------------------------*/ | ||
3 | /*--- Block sorting machinery ---*/ | ||
4 | /*--- blocksort.c ---*/ | ||
5 | /*-------------------------------------------------------------*/ | ||
6 | |||
7 | /* ------------------------------------------------------------------ | ||
8 | This file is part of bzip2/libbzip2, a program and library for | ||
9 | lossless, block-sorting data compression. | ||
10 | |||
11 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | ||
12 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | ||
13 | |||
14 | Please read the WARNING, DISCLAIMER and PATENTS sections in the | ||
15 | README file. | ||
16 | |||
17 | This program is released under the terms of the license contained | ||
18 | in the file LICENSE. | ||
19 | ------------------------------------------------------------------ */ | ||
20 | |||
21 | |||
22 | #include "bzlib_private.h" | ||
23 | |||
24 | /*---------------------------------------------*/ | ||
25 | /*--- Fallback O(N log(N)^2) sorting ---*/ | ||
26 | /*--- algorithm, for repetitive blocks ---*/ | ||
27 | /*---------------------------------------------*/ | ||
28 | |||
29 | /*---------------------------------------------*/ | ||
30 | static | ||
31 | __inline__ | ||
32 | void fallbackSimpleSort ( UInt32* fmap, | ||
33 | UInt32* eclass, | ||
34 | Int32 lo, | ||
35 | Int32 hi ) | ||
36 | { | ||
37 | Int32 i, j, tmp; | ||
38 | UInt32 ec_tmp; | ||
39 | |||
40 | if (lo == hi) return; | ||
41 | |||
42 | if (hi - lo > 3) { | ||
43 | for ( i = hi-4; i >= lo; i-- ) { | ||
44 | tmp = fmap[i]; | ||
45 | ec_tmp = eclass[tmp]; | ||
46 | for ( j = i+4; j <= hi && ec_tmp > eclass[fmap[j]]; j += 4 ) | ||
47 | fmap[j-4] = fmap[j]; | ||
48 | fmap[j-4] = tmp; | ||
49 | } | ||
50 | } | ||
51 | |||
52 | for ( i = hi-1; i >= lo; i-- ) { | ||
53 | tmp = fmap[i]; | ||
54 | ec_tmp = eclass[tmp]; | ||
55 | for ( j = i+1; j <= hi && ec_tmp > eclass[fmap[j]]; j++ ) | ||
56 | fmap[j-1] = fmap[j]; | ||
57 | fmap[j-1] = tmp; | ||
58 | } | ||
59 | } | ||
60 | |||
61 | |||
62 | /*---------------------------------------------*/ | ||
63 | #define fswap(zz1, zz2) \ | ||
64 | { Int32 zztmp = zz1; zz1 = zz2; zz2 = zztmp; } | ||
65 | |||
66 | #define fvswap(zzp1, zzp2, zzn) \ | ||
67 | { \ | ||
68 | Int32 yyp1 = (zzp1); \ | ||
69 | Int32 yyp2 = (zzp2); \ | ||
70 | Int32 yyn = (zzn); \ | ||
71 | while (yyn > 0) { \ | ||
72 | fswap(fmap[yyp1], fmap[yyp2]); \ | ||
73 | yyp1++; yyp2++; yyn--; \ | ||
74 | } \ | ||
75 | } | ||
76 | |||
77 | |||
78 | #define fmin(a,b) ((a) < (b)) ? (a) : (b) | ||
79 | |||
80 | #define fpush(lz,hz) { stackLo[sp] = lz; \ | ||
81 | stackHi[sp] = hz; \ | ||
82 | sp++; } | ||
83 | |||
84 | #define fpop(lz,hz) { sp--; \ | ||
85 | lz = stackLo[sp]; \ | ||
86 | hz = stackHi[sp]; } | ||
87 | |||
88 | #define FALLBACK_QSORT_SMALL_THRESH 10 | ||
89 | #define FALLBACK_QSORT_STACK_SIZE 100 | ||
90 | |||
91 | |||
92 | static | ||
93 | void fallbackQSort3 ( UInt32* fmap, | ||
94 | UInt32* eclass, | ||
95 | Int32 loSt, | ||
96 | Int32 hiSt ) | ||
97 | { | ||
98 | Int32 unLo, unHi, ltLo, gtHi, n, m; | ||
99 | Int32 sp, lo, hi; | ||
100 | UInt32 med, r, r3; | ||
101 | Int32 stackLo[FALLBACK_QSORT_STACK_SIZE]; | ||
102 | Int32 stackHi[FALLBACK_QSORT_STACK_SIZE]; | ||
103 | |||
104 | r = 0; | ||
105 | |||
106 | sp = 0; | ||
107 | fpush ( loSt, hiSt ); | ||
108 | |||
109 | while (sp > 0) { | ||
110 | |||
111 | AssertH ( sp < FALLBACK_QSORT_STACK_SIZE - 1, 1004 ); | ||
112 | |||
113 | fpop ( lo, hi ); | ||
114 | if (hi - lo < FALLBACK_QSORT_SMALL_THRESH) { | ||
115 | fallbackSimpleSort ( fmap, eclass, lo, hi ); | ||
116 | continue; | ||
117 | } | ||
118 | |||
119 | /* Random partitioning. Median of 3 sometimes fails to | ||
120 | avoid bad cases. Median of 9 seems to help but | ||
121 | looks rather expensive. This too seems to work but | ||
122 | is cheaper. Guidance for the magic constants | ||
123 | 7621 and 32768 is taken from Sedgewick's algorithms | ||
124 | book, chapter 35. | ||
125 | */ | ||
126 | r = ((r * 7621) + 1) % 32768; | ||
127 | r3 = r % 3; | ||
128 | if (r3 == 0) med = eclass[fmap[lo]]; else | ||
129 | if (r3 == 1) med = eclass[fmap[(lo+hi)>>1]]; else | ||
130 | med = eclass[fmap[hi]]; | ||
131 | |||
132 | unLo = ltLo = lo; | ||
133 | unHi = gtHi = hi; | ||
134 | |||
135 | while (1) { | ||
136 | while (1) { | ||
137 | if (unLo > unHi) break; | ||
138 | n = (Int32)eclass[fmap[unLo]] - (Int32)med; | ||
139 | if (n == 0) { | ||
140 | fswap(fmap[unLo], fmap[ltLo]); | ||
141 | ltLo++; unLo++; | ||
142 | continue; | ||
143 | }; | ||
144 | if (n > 0) break; | ||
145 | unLo++; | ||
146 | } | ||
147 | while (1) { | ||
148 | if (unLo > unHi) break; | ||
149 | n = (Int32)eclass[fmap[unHi]] - (Int32)med; | ||
150 | if (n == 0) { | ||
151 | fswap(fmap[unHi], fmap[gtHi]); | ||
152 | gtHi--; unHi--; | ||
153 | continue; | ||
154 | }; | ||
155 | if (n < 0) break; | ||
156 | unHi--; | ||
157 | } | ||
158 | if (unLo > unHi) break; | ||
159 | fswap(fmap[unLo], fmap[unHi]); unLo++; unHi--; | ||
160 | } | ||
161 | |||
162 | AssertD ( unHi == unLo-1, "fallbackQSort3(2)" ); | ||
163 | |||
164 | if (gtHi < ltLo) continue; | ||
165 | |||
166 | n = fmin(ltLo-lo, unLo-ltLo); fvswap(lo, unLo-n, n); | ||
167 | m = fmin(hi-gtHi, gtHi-unHi); fvswap(unLo, hi-m+1, m); | ||
168 | |||
169 | n = lo + unLo - ltLo - 1; | ||
170 | m = hi - (gtHi - unHi) + 1; | ||
171 | |||
172 | if (n - lo > hi - m) { | ||
173 | fpush ( lo, n ); | ||
174 | fpush ( m, hi ); | ||
175 | } else { | ||
176 | fpush ( m, hi ); | ||
177 | fpush ( lo, n ); | ||
178 | } | ||
179 | } | ||
180 | } | ||
181 | |||
182 | #undef fmin | ||
183 | #undef fpush | ||
184 | #undef fpop | ||
185 | #undef fswap | ||
186 | #undef fvswap | ||
187 | #undef FALLBACK_QSORT_SMALL_THRESH | ||
188 | #undef FALLBACK_QSORT_STACK_SIZE | ||
189 | |||
190 | |||
191 | /*---------------------------------------------*/ | ||
192 | /* Pre: | ||
193 | nblock > 0 | ||
194 | eclass exists for [0 .. nblock-1] | ||
195 | ((UChar*)eclass) [0 .. nblock-1] holds block | ||
196 | ptr exists for [0 .. nblock-1] | ||
197 | |||
198 | Post: | ||
199 | ((UChar*)eclass) [0 .. nblock-1] holds block | ||
200 | All other areas of eclass destroyed | ||
201 | fmap [0 .. nblock-1] holds sorted order | ||
202 | bhtab [ 0 .. 2+(nblock/32) ] destroyed | ||
203 | */ | ||
204 | |||
205 | #define SET_BH(zz) bhtab[(zz) >> 5] |= (1 << ((zz) & 31)) | ||
206 | #define CLEAR_BH(zz) bhtab[(zz) >> 5] &= ~(1 << ((zz) & 31)) | ||
207 | #define ISSET_BH(zz) (bhtab[(zz) >> 5] & (1 << ((zz) & 31))) | ||
208 | #define WORD_BH(zz) bhtab[(zz) >> 5] | ||
209 | #define UNALIGNED_BH(zz) ((zz) & 0x01f) | ||
210 | |||
211 | static | ||
212 | void fallbackSort ( UInt32* fmap, | ||
213 | UInt32* eclass, | ||
214 | UInt32* bhtab, | ||
215 | Int32 nblock, | ||
216 | Int32 verb ) | ||
217 | { | ||
218 | Int32 ftab[257]; | ||
219 | Int32 ftabCopy[256]; | ||
220 | Int32 H, i, j, k, l, r, cc, cc1; | ||
221 | Int32 nNotDone; | ||
222 | Int32 nBhtab; | ||
223 | UChar* eclass8 = (UChar*)eclass; | ||
224 | |||
225 | /*-- | ||
226 | Initial 1-char radix sort to generate | ||
227 | initial fmap and initial BH bits. | ||
228 | --*/ | ||
229 | if (verb >= 4) | ||
230 | VPrintf0 ( " bucket sorting ...\n" ); | ||
231 | for (i = 0; i < 257; i++) ftab[i] = 0; | ||
232 | for (i = 0; i < nblock; i++) ftab[eclass8[i]]++; | ||
233 | for (i = 0; i < 256; i++) ftabCopy[i] = ftab[i]; | ||
234 | for (i = 1; i < 257; i++) ftab[i] += ftab[i-1]; | ||
235 | |||
236 | for (i = 0; i < nblock; i++) { | ||
237 | j = eclass8[i]; | ||
238 | k = ftab[j] - 1; | ||
239 | ftab[j] = k; | ||
240 | fmap[k] = i; | ||
241 | } | ||
242 | |||
243 | nBhtab = 2 + (nblock / 32); | ||
244 | for (i = 0; i < nBhtab; i++) bhtab[i] = 0; | ||
245 | for (i = 0; i < 256; i++) SET_BH(ftab[i]); | ||
246 | |||
247 | /*-- | ||
248 | Inductively refine the buckets. Kind-of an | ||
249 | "exponential radix sort" (!), inspired by the | ||
250 | Manber-Myers suffix array construction algorithm. | ||
251 | --*/ | ||
252 | |||
253 | /*-- set sentinel bits for block-end detection --*/ | ||
254 | for (i = 0; i < 32; i++) { | ||
255 | SET_BH(nblock + 2*i); | ||
256 | CLEAR_BH(nblock + 2*i + 1); | ||
257 | } | ||
258 | |||
259 | /*-- the log(N) loop --*/ | ||
260 | H = 1; | ||
261 | while (1) { | ||
262 | |||
263 | if (verb >= 4) | ||
264 | VPrintf1 ( " depth %6d has ", H ); | ||
265 | |||
266 | j = 0; | ||
267 | for (i = 0; i < nblock; i++) { | ||
268 | if (ISSET_BH(i)) j = i; | ||
269 | k = fmap[i] - H; if (k < 0) k += nblock; | ||
270 | eclass[k] = j; | ||
271 | } | ||
272 | |||
273 | nNotDone = 0; | ||
274 | r = -1; | ||
275 | while (1) { | ||
276 | |||
277 | /*-- find the next non-singleton bucket --*/ | ||
278 | k = r + 1; | ||
279 | while (ISSET_BH(k) && UNALIGNED_BH(k)) k++; | ||
280 | if (ISSET_BH(k)) { | ||
281 | while (WORD_BH(k) == 0xffffffff) k += 32; | ||
282 | while (ISSET_BH(k)) k++; | ||
283 | } | ||
284 | l = k - 1; | ||
285 | if (l >= nblock) break; | ||
286 | while (!ISSET_BH(k) && UNALIGNED_BH(k)) k++; | ||
287 | if (!ISSET_BH(k)) { | ||
288 | while (WORD_BH(k) == 0x00000000) k += 32; | ||
289 | while (!ISSET_BH(k)) k++; | ||
290 | } | ||
291 | r = k - 1; | ||
292 | if (r >= nblock) break; | ||
293 | |||
294 | /*-- now [l, r] bracket current bucket --*/ | ||
295 | if (r > l) { | ||
296 | nNotDone += (r - l + 1); | ||
297 | fallbackQSort3 ( fmap, eclass, l, r ); | ||
298 | |||
299 | /*-- scan bucket and generate header bits-- */ | ||
300 | cc = -1; | ||
301 | for (i = l; i <= r; i++) { | ||
302 | cc1 = eclass[fmap[i]]; | ||
303 | if (cc != cc1) { SET_BH(i); cc = cc1; }; | ||
304 | } | ||
305 | } | ||
306 | } | ||
307 | |||
308 | if (verb >= 4) | ||
309 | VPrintf1 ( "%6d unresolved strings\n", nNotDone ); | ||
310 | |||
311 | H *= 2; | ||
312 | if (H > nblock || nNotDone == 0) break; | ||
313 | } | ||
314 | |||
315 | /*-- | ||
316 | Reconstruct the original block in | ||
317 | eclass8 [0 .. nblock-1], since the | ||
318 | previous phase destroyed it. | ||
319 | --*/ | ||
320 | if (verb >= 4) | ||
321 | VPrintf0 ( " reconstructing block ...\n" ); | ||
322 | j = 0; | ||
323 | for (i = 0; i < nblock; i++) { | ||
324 | while (ftabCopy[j] == 0) j++; | ||
325 | ftabCopy[j]--; | ||
326 | eclass8[fmap[i]] = (UChar)j; | ||
327 | } | ||
328 | AssertH ( j < 256, 1005 ); | ||
329 | } | ||
330 | |||
331 | #undef SET_BH | ||
332 | #undef CLEAR_BH | ||
333 | #undef ISSET_BH | ||
334 | #undef WORD_BH | ||
335 | #undef UNALIGNED_BH | ||
336 | |||
337 | |||
338 | /*---------------------------------------------*/ | ||
339 | /*--- The main, O(N^2 log(N)) sorting ---*/ | ||
340 | /*--- algorithm. Faster for "normal" ---*/ | ||
341 | /*--- non-repetitive blocks. ---*/ | ||
342 | /*---------------------------------------------*/ | ||
343 | |||
344 | /*---------------------------------------------*/ | ||
345 | static | ||
346 | __inline__ | ||
347 | Bool mainGtU ( UInt32 i1, | ||
348 | UInt32 i2, | ||
349 | UChar* block, | ||
350 | UInt16* quadrant, | ||
351 | UInt32 nblock, | ||
352 | Int32* budget ) | ||
353 | { | ||
354 | Int32 k; | ||
355 | UChar c1, c2; | ||
356 | UInt16 s1, s2; | ||
357 | |||
358 | AssertD ( i1 != i2, "mainGtU" ); | ||
359 | /* 1 */ | ||
360 | c1 = block[i1]; c2 = block[i2]; | ||
361 | if (c1 != c2) return (c1 > c2); | ||
362 | i1++; i2++; | ||
363 | /* 2 */ | ||
364 | c1 = block[i1]; c2 = block[i2]; | ||
365 | if (c1 != c2) return (c1 > c2); | ||
366 | i1++; i2++; | ||
367 | /* 3 */ | ||
368 | c1 = block[i1]; c2 = block[i2]; | ||
369 | if (c1 != c2) return (c1 > c2); | ||
370 | i1++; i2++; | ||
371 | /* 4 */ | ||
372 | c1 = block[i1]; c2 = block[i2]; | ||
373 | if (c1 != c2) return (c1 > c2); | ||
374 | i1++; i2++; | ||
375 | /* 5 */ | ||
376 | c1 = block[i1]; c2 = block[i2]; | ||
377 | if (c1 != c2) return (c1 > c2); | ||
378 | i1++; i2++; | ||
379 | /* 6 */ | ||
380 | c1 = block[i1]; c2 = block[i2]; | ||
381 | if (c1 != c2) return (c1 > c2); | ||
382 | i1++; i2++; | ||
383 | /* 7 */ | ||
384 | c1 = block[i1]; c2 = block[i2]; | ||
385 | if (c1 != c2) return (c1 > c2); | ||
386 | i1++; i2++; | ||
387 | /* 8 */ | ||
388 | c1 = block[i1]; c2 = block[i2]; | ||
389 | if (c1 != c2) return (c1 > c2); | ||
390 | i1++; i2++; | ||
391 | /* 9 */ | ||
392 | c1 = block[i1]; c2 = block[i2]; | ||
393 | if (c1 != c2) return (c1 > c2); | ||
394 | i1++; i2++; | ||
395 | /* 10 */ | ||
396 | c1 = block[i1]; c2 = block[i2]; | ||
397 | if (c1 != c2) return (c1 > c2); | ||
398 | i1++; i2++; | ||
399 | /* 11 */ | ||
400 | c1 = block[i1]; c2 = block[i2]; | ||
401 | if (c1 != c2) return (c1 > c2); | ||
402 | i1++; i2++; | ||
403 | /* 12 */ | ||
404 | c1 = block[i1]; c2 = block[i2]; | ||
405 | if (c1 != c2) return (c1 > c2); | ||
406 | i1++; i2++; | ||
407 | |||
408 | k = nblock + 8; | ||
409 | |||
410 | do { | ||
411 | /* 1 */ | ||
412 | c1 = block[i1]; c2 = block[i2]; | ||
413 | if (c1 != c2) return (c1 > c2); | ||
414 | s1 = quadrant[i1]; s2 = quadrant[i2]; | ||
415 | if (s1 != s2) return (s1 > s2); | ||
416 | i1++; i2++; | ||
417 | /* 2 */ | ||
418 | c1 = block[i1]; c2 = block[i2]; | ||
419 | if (c1 != c2) return (c1 > c2); | ||
420 | s1 = quadrant[i1]; s2 = quadrant[i2]; | ||
421 | if (s1 != s2) return (s1 > s2); | ||
422 | i1++; i2++; | ||
423 | /* 3 */ | ||
424 | c1 = block[i1]; c2 = block[i2]; | ||
425 | if (c1 != c2) return (c1 > c2); | ||
426 | s1 = quadrant[i1]; s2 = quadrant[i2]; | ||
427 | if (s1 != s2) return (s1 > s2); | ||
428 | i1++; i2++; | ||
429 | /* 4 */ | ||
430 | c1 = block[i1]; c2 = block[i2]; | ||
431 | if (c1 != c2) return (c1 > c2); | ||
432 | s1 = quadrant[i1]; s2 = quadrant[i2]; | ||
433 | if (s1 != s2) return (s1 > s2); | ||
434 | i1++; i2++; | ||
435 | /* 5 */ | ||
436 | c1 = block[i1]; c2 = block[i2]; | ||
437 | if (c1 != c2) return (c1 > c2); | ||
438 | s1 = quadrant[i1]; s2 = quadrant[i2]; | ||
439 | if (s1 != s2) return (s1 > s2); | ||
440 | i1++; i2++; | ||
441 | /* 6 */ | ||
442 | c1 = block[i1]; c2 = block[i2]; | ||
443 | if (c1 != c2) return (c1 > c2); | ||
444 | s1 = quadrant[i1]; s2 = quadrant[i2]; | ||
445 | if (s1 != s2) return (s1 > s2); | ||
446 | i1++; i2++; | ||
447 | /* 7 */ | ||
448 | c1 = block[i1]; c2 = block[i2]; | ||
449 | if (c1 != c2) return (c1 > c2); | ||
450 | s1 = quadrant[i1]; s2 = quadrant[i2]; | ||
451 | if (s1 != s2) return (s1 > s2); | ||
452 | i1++; i2++; | ||
453 | /* 8 */ | ||
454 | c1 = block[i1]; c2 = block[i2]; | ||
455 | if (c1 != c2) return (c1 > c2); | ||
456 | s1 = quadrant[i1]; s2 = quadrant[i2]; | ||
457 | if (s1 != s2) return (s1 > s2); | ||
458 | i1++; i2++; | ||
459 | |||
460 | if (i1 >= nblock) i1 -= nblock; | ||
461 | if (i2 >= nblock) i2 -= nblock; | ||
462 | |||
463 | k -= 8; | ||
464 | (*budget)--; | ||
465 | } | ||
466 | while (k >= 0); | ||
467 | |||
468 | return False; | ||
469 | } | ||
470 | |||
471 | |||
472 | /*---------------------------------------------*/ | ||
473 | /*-- | ||
474 | Knuth's increments seem to work better | ||
475 | than Incerpi-Sedgewick here. Possibly | ||
476 | because the number of elems to sort is | ||
477 | usually small, typically <= 20. | ||
478 | --*/ | ||
479 | static | ||
480 | Int32 incs[14] = { 1, 4, 13, 40, 121, 364, 1093, 3280, | ||
481 | 9841, 29524, 88573, 265720, | ||
482 | 797161, 2391484 }; | ||
483 | |||
484 | static | ||
485 | void mainSimpleSort ( UInt32* ptr, | ||
486 | UChar* block, | ||
487 | UInt16* quadrant, | ||
488 | Int32 nblock, | ||
489 | Int32 lo, | ||
490 | Int32 hi, | ||
491 | Int32 d, | ||
492 | Int32* budget ) | ||
493 | { | ||
494 | Int32 i, j, h, bigN, hp; | ||
495 | UInt32 v; | ||
496 | |||
497 | bigN = hi - lo + 1; | ||
498 | if (bigN < 2) return; | ||
499 | |||
500 | hp = 0; | ||
501 | while (incs[hp] < bigN) hp++; | ||
502 | hp--; | ||
503 | |||
504 | for (; hp >= 0; hp--) { | ||
505 | h = incs[hp]; | ||
506 | |||
507 | i = lo + h; | ||
508 | while (True) { | ||
509 | |||
510 | /*-- copy 1 --*/ | ||
511 | if (i > hi) break; | ||
512 | v = ptr[i]; | ||
513 | j = i; | ||
514 | while ( mainGtU ( | ||
515 | ptr[j-h]+d, v+d, block, quadrant, nblock, budget | ||
516 | ) ) { | ||
517 | ptr[j] = ptr[j-h]; | ||
518 | j = j - h; | ||
519 | if (j <= (lo + h - 1)) break; | ||
520 | } | ||
521 | ptr[j] = v; | ||
522 | i++; | ||
523 | |||
524 | /*-- copy 2 --*/ | ||
525 | if (i > hi) break; | ||
526 | v = ptr[i]; | ||
527 | j = i; | ||
528 | while ( mainGtU ( | ||
529 | ptr[j-h]+d, v+d, block, quadrant, nblock, budget | ||
530 | ) ) { | ||
531 | ptr[j] = ptr[j-h]; | ||
532 | j = j - h; | ||
533 | if (j <= (lo + h - 1)) break; | ||
534 | } | ||
535 | ptr[j] = v; | ||
536 | i++; | ||
537 | |||
538 | /*-- copy 3 --*/ | ||
539 | if (i > hi) break; | ||
540 | v = ptr[i]; | ||
541 | j = i; | ||
542 | while ( mainGtU ( | ||
543 | ptr[j-h]+d, v+d, block, quadrant, nblock, budget | ||
544 | ) ) { | ||
545 | ptr[j] = ptr[j-h]; | ||
546 | j = j - h; | ||
547 | if (j <= (lo + h - 1)) break; | ||
548 | } | ||
549 | ptr[j] = v; | ||
550 | i++; | ||
551 | |||
552 | if (*budget < 0) return; | ||
553 | } | ||
554 | } | ||
555 | } | ||
556 | |||
557 | |||
558 | /*---------------------------------------------*/ | ||
559 | /*-- | ||
560 | The following is an implementation of | ||
561 | an elegant 3-way quicksort for strings, | ||
562 | described in a paper "Fast Algorithms for | ||
563 | Sorting and Searching Strings", by Robert | ||
564 | Sedgewick and Jon L. Bentley. | ||
565 | --*/ | ||
566 | |||
567 | #define mswap(zz1, zz2) \ | ||
568 | { Int32 zztmp = zz1; zz1 = zz2; zz2 = zztmp; } | ||
569 | |||
570 | #define mvswap(zzp1, zzp2, zzn) \ | ||
571 | { \ | ||
572 | Int32 yyp1 = (zzp1); \ | ||
573 | Int32 yyp2 = (zzp2); \ | ||
574 | Int32 yyn = (zzn); \ | ||
575 | while (yyn > 0) { \ | ||
576 | mswap(ptr[yyp1], ptr[yyp2]); \ | ||
577 | yyp1++; yyp2++; yyn--; \ | ||
578 | } \ | ||
579 | } | ||
580 | |||
581 | static | ||
582 | __inline__ | ||
583 | UChar mmed3 ( UChar a, UChar b, UChar c ) | ||
584 | { | ||
585 | UChar t; | ||
586 | if (a > b) { t = a; a = b; b = t; }; | ||
587 | if (b > c) { | ||
588 | b = c; | ||
589 | if (a > b) b = a; | ||
590 | } | ||
591 | return b; | ||
592 | } | ||
593 | |||
594 | #define mmin(a,b) ((a) < (b)) ? (a) : (b) | ||
595 | |||
596 | #define mpush(lz,hz,dz) { stackLo[sp] = lz; \ | ||
597 | stackHi[sp] = hz; \ | ||
598 | stackD [sp] = dz; \ | ||
599 | sp++; } | ||
600 | |||
601 | #define mpop(lz,hz,dz) { sp--; \ | ||
602 | lz = stackLo[sp]; \ | ||
603 | hz = stackHi[sp]; \ | ||
604 | dz = stackD [sp]; } | ||
605 | |||
606 | |||
607 | #define mnextsize(az) (nextHi[az]-nextLo[az]) | ||
608 | |||
609 | #define mnextswap(az,bz) \ | ||
610 | { Int32 tz; \ | ||
611 | tz = nextLo[az]; nextLo[az] = nextLo[bz]; nextLo[bz] = tz; \ | ||
612 | tz = nextHi[az]; nextHi[az] = nextHi[bz]; nextHi[bz] = tz; \ | ||
613 | tz = nextD [az]; nextD [az] = nextD [bz]; nextD [bz] = tz; } | ||
614 | |||
615 | |||
616 | #define MAIN_QSORT_SMALL_THRESH 20 | ||
617 | #define MAIN_QSORT_DEPTH_THRESH (BZ_N_RADIX + BZ_N_QSORT) | ||
618 | #define MAIN_QSORT_STACK_SIZE 100 | ||
619 | |||
620 | static | ||
621 | void mainQSort3 ( UInt32* ptr, | ||
622 | UChar* block, | ||
623 | UInt16* quadrant, | ||
624 | Int32 nblock, | ||
625 | Int32 loSt, | ||
626 | Int32 hiSt, | ||
627 | Int32 dSt, | ||
628 | Int32* budget ) | ||
629 | { | ||
630 | Int32 unLo, unHi, ltLo, gtHi, n, m, med; | ||
631 | Int32 sp, lo, hi, d; | ||
632 | |||
633 | Int32 stackLo[MAIN_QSORT_STACK_SIZE]; | ||
634 | Int32 stackHi[MAIN_QSORT_STACK_SIZE]; | ||
635 | Int32 stackD [MAIN_QSORT_STACK_SIZE]; | ||
636 | |||
637 | Int32 nextLo[3]; | ||
638 | Int32 nextHi[3]; | ||
639 | Int32 nextD [3]; | ||
640 | |||
641 | sp = 0; | ||
642 | mpush ( loSt, hiSt, dSt ); | ||
643 | |||
644 | while (sp > 0) { | ||
645 | |||
646 | AssertH ( sp < MAIN_QSORT_STACK_SIZE - 2, 1001 ); | ||
647 | |||
648 | mpop ( lo, hi, d ); | ||
649 | if (hi - lo < MAIN_QSORT_SMALL_THRESH || | ||
650 | d > MAIN_QSORT_DEPTH_THRESH) { | ||
651 | mainSimpleSort ( ptr, block, quadrant, nblock, lo, hi, d, budget ); | ||
652 | if (*budget < 0) return; | ||
653 | continue; | ||
654 | } | ||
655 | |||
656 | med = (Int32) | ||
657 | mmed3 ( block[ptr[ lo ]+d], | ||
658 | block[ptr[ hi ]+d], | ||
659 | block[ptr[ (lo+hi)>>1 ]+d] ); | ||
660 | |||
661 | unLo = ltLo = lo; | ||
662 | unHi = gtHi = hi; | ||
663 | |||
664 | while (True) { | ||
665 | while (True) { | ||
666 | if (unLo > unHi) break; | ||
667 | n = ((Int32)block[ptr[unLo]+d]) - med; | ||
668 | if (n == 0) { | ||
669 | mswap(ptr[unLo], ptr[ltLo]); | ||
670 | ltLo++; unLo++; continue; | ||
671 | }; | ||
672 | if (n > 0) break; | ||
673 | unLo++; | ||
674 | } | ||
675 | while (True) { | ||
676 | if (unLo > unHi) break; | ||
677 | n = ((Int32)block[ptr[unHi]+d]) - med; | ||
678 | if (n == 0) { | ||
679 | mswap(ptr[unHi], ptr[gtHi]); | ||
680 | gtHi--; unHi--; continue; | ||
681 | }; | ||
682 | if (n < 0) break; | ||
683 | unHi--; | ||
684 | } | ||
685 | if (unLo > unHi) break; | ||
686 | mswap(ptr[unLo], ptr[unHi]); unLo++; unHi--; | ||
687 | } | ||
688 | |||
689 | AssertD ( unHi == unLo-1, "mainQSort3(2)" ); | ||
690 | |||
691 | if (gtHi < ltLo) { | ||
692 | mpush(lo, hi, d+1 ); | ||
693 | continue; | ||
694 | } | ||
695 | |||
696 | n = mmin(ltLo-lo, unLo-ltLo); mvswap(lo, unLo-n, n); | ||
697 | m = mmin(hi-gtHi, gtHi-unHi); mvswap(unLo, hi-m+1, m); | ||
698 | |||
699 | n = lo + unLo - ltLo - 1; | ||
700 | m = hi - (gtHi - unHi) + 1; | ||
701 | |||
702 | nextLo[0] = lo; nextHi[0] = n; nextD[0] = d; | ||
703 | nextLo[1] = m; nextHi[1] = hi; nextD[1] = d; | ||
704 | nextLo[2] = n+1; nextHi[2] = m-1; nextD[2] = d+1; | ||
705 | |||
706 | if (mnextsize(0) < mnextsize(1)) mnextswap(0,1); | ||
707 | if (mnextsize(1) < mnextsize(2)) mnextswap(1,2); | ||
708 | if (mnextsize(0) < mnextsize(1)) mnextswap(0,1); | ||
709 | |||
710 | AssertD (mnextsize(0) >= mnextsize(1), "mainQSort3(8)" ); | ||
711 | AssertD (mnextsize(1) >= mnextsize(2), "mainQSort3(9)" ); | ||
712 | |||
713 | mpush (nextLo[0], nextHi[0], nextD[0]); | ||
714 | mpush (nextLo[1], nextHi[1], nextD[1]); | ||
715 | mpush (nextLo[2], nextHi[2], nextD[2]); | ||
716 | } | ||
717 | } | ||
718 | |||
719 | #undef mswap | ||
720 | #undef mvswap | ||
721 | #undef mpush | ||
722 | #undef mpop | ||
723 | #undef mmin | ||
724 | #undef mnextsize | ||
725 | #undef mnextswap | ||
726 | #undef MAIN_QSORT_SMALL_THRESH | ||
727 | #undef MAIN_QSORT_DEPTH_THRESH | ||
728 | #undef MAIN_QSORT_STACK_SIZE | ||
729 | |||
730 | |||
731 | /*---------------------------------------------*/ | ||
732 | /* Pre: | ||
733 | nblock > N_OVERSHOOT | ||
734 | block32 exists for [0 .. nblock-1 +N_OVERSHOOT] | ||
735 | ((UChar*)block32) [0 .. nblock-1] holds block | ||
736 | ptr exists for [0 .. nblock-1] | ||
737 | |||
738 | Post: | ||
739 | ((UChar*)block32) [0 .. nblock-1] holds block | ||
740 | All other areas of block32 destroyed | ||
741 | ftab [0 .. 65536 ] destroyed | ||
742 | ptr [0 .. nblock-1] holds sorted order | ||
743 | if (*budget < 0), sorting was abandoned | ||
744 | */ | ||
745 | |||
746 | #define BIGFREQ(b) (ftab[((b)+1) << 8] - ftab[(b) << 8]) | ||
747 | #define SETMASK (1 << 21) | ||
748 | #define CLEARMASK (~(SETMASK)) | ||
749 | |||
750 | static | ||
751 | void mainSort ( UInt32* ptr, | ||
752 | UChar* block, | ||
753 | UInt16* quadrant, | ||
754 | UInt32* ftab, | ||
755 | Int32 nblock, | ||
756 | Int32 verb, | ||
757 | Int32* budget ) | ||
758 | { | ||
759 | Int32 i, j, k, ss, sb; | ||
760 | Int32 runningOrder[256]; | ||
761 | Bool bigDone[256]; | ||
762 | Int32 copyStart[256]; | ||
763 | Int32 copyEnd [256]; | ||
764 | UChar c1; | ||
765 | Int32 numQSorted; | ||
766 | UInt16 s; | ||
767 | if (verb >= 4) VPrintf0 ( " main sort initialise ...\n" ); | ||
768 | |||
769 | /*-- set up the 2-byte frequency table --*/ | ||
770 | for (i = 65536; i >= 0; i--) ftab[i] = 0; | ||
771 | |||
772 | j = block[0] << 8; | ||
773 | i = nblock-1; | ||
774 | for (; i >= 3; i -= 4) { | ||
775 | quadrant[i] = 0; | ||
776 | j = (j >> 8) | ( ((UInt16)block[i]) << 8); | ||
777 | ftab[j]++; | ||
778 | quadrant[i-1] = 0; | ||
779 | j = (j >> 8) | ( ((UInt16)block[i-1]) << 8); | ||
780 | ftab[j]++; | ||
781 | quadrant[i-2] = 0; | ||
782 | j = (j >> 8) | ( ((UInt16)block[i-2]) << 8); | ||
783 | ftab[j]++; | ||
784 | quadrant[i-3] = 0; | ||
785 | j = (j >> 8) | ( ((UInt16)block[i-3]) << 8); | ||
786 | ftab[j]++; | ||
787 | } | ||
788 | for (; i >= 0; i--) { | ||
789 | quadrant[i] = 0; | ||
790 | j = (j >> 8) | ( ((UInt16)block[i]) << 8); | ||
791 | ftab[j]++; | ||
792 | } | ||
793 | |||
794 | /*-- (emphasises close relationship of block & quadrant) --*/ | ||
795 | for (i = 0; i < BZ_N_OVERSHOOT; i++) { | ||
796 | block [nblock+i] = block[i]; | ||
797 | quadrant[nblock+i] = 0; | ||
798 | } | ||
799 | |||
800 | if (verb >= 4) VPrintf0 ( " bucket sorting ...\n" ); | ||
801 | |||
802 | /*-- Complete the initial radix sort --*/ | ||
803 | for (i = 1; i <= 65536; i++) ftab[i] += ftab[i-1]; | ||
804 | |||
805 | s = block[0] << 8; | ||
806 | i = nblock-1; | ||
807 | for (; i >= 3; i -= 4) { | ||
808 | s = (s >> 8) | (block[i] << 8); | ||
809 | j = ftab[s] -1; | ||
810 | ftab[s] = j; | ||
811 | ptr[j] = i; | ||
812 | s = (s >> 8) | (block[i-1] << 8); | ||
813 | j = ftab[s] -1; | ||
814 | ftab[s] = j; | ||
815 | ptr[j] = i-1; | ||
816 | s = (s >> 8) | (block[i-2] << 8); | ||
817 | j = ftab[s] -1; | ||
818 | ftab[s] = j; | ||
819 | ptr[j] = i-2; | ||
820 | s = (s >> 8) | (block[i-3] << 8); | ||
821 | j = ftab[s] -1; | ||
822 | ftab[s] = j; | ||
823 | ptr[j] = i-3; | ||
824 | } | ||
825 | for (; i >= 0; i--) { | ||
826 | s = (s >> 8) | (block[i] << 8); | ||
827 | j = ftab[s] -1; | ||
828 | ftab[s] = j; | ||
829 | ptr[j] = i; | ||
830 | } | ||
831 | |||
832 | /*-- | ||
833 | Now ftab contains the first loc of every small bucket. | ||
834 | Calculate the running order, from smallest to largest | ||
835 | big bucket. | ||
836 | --*/ | ||
837 | for (i = 0; i <= 255; i++) { | ||
838 | bigDone [i] = False; | ||
839 | runningOrder[i] = i; | ||
840 | } | ||
841 | |||
842 | { | ||
843 | Int32 vv; | ||
844 | Int32 h = 1; | ||
845 | do h = 3 * h + 1; while (h <= 256); | ||
846 | do { | ||
847 | h = h / 3; | ||
848 | for (i = h; i <= 255; i++) { | ||
849 | vv = runningOrder[i]; | ||
850 | j = i; | ||
851 | while ( BIGFREQ(runningOrder[j-h]) > BIGFREQ(vv) ) { | ||
852 | runningOrder[j] = runningOrder[j-h]; | ||
853 | j = j - h; | ||
854 | if (j <= (h - 1)) goto zero; | ||
855 | } | ||
856 | zero: | ||
857 | runningOrder[j] = vv; | ||
858 | } | ||
859 | } while (h != 1); | ||
860 | } | ||
861 | |||
862 | /*-- | ||
863 | The main sorting loop. | ||
864 | --*/ | ||
865 | |||
866 | numQSorted = 0; | ||
867 | |||
868 | for (i = 0; i <= 255; i++) { | ||
869 | |||
870 | /*-- | ||
871 | Process big buckets, starting with the least full. | ||
872 | Basically this is a 3-step process in which we call | ||
873 | mainQSort3 to sort the small buckets [ss, j], but | ||
874 | also make a big effort to avoid the calls if we can. | ||
875 | --*/ | ||
876 | ss = runningOrder[i]; | ||
877 | |||
878 | /*-- | ||
879 | Step 1: | ||
880 | Complete the big bucket [ss] by quicksorting | ||
881 | any unsorted small buckets [ss, j], for j != ss. | ||
882 | Hopefully previous pointer-scanning phases have already | ||
883 | completed many of the small buckets [ss, j], so | ||
884 | we don't have to sort them at all. | ||
885 | --*/ | ||
886 | for (j = 0; j <= 255; j++) { | ||
887 | if (j != ss) { | ||
888 | sb = (ss << 8) + j; | ||
889 | if ( ! (ftab[sb] & SETMASK) ) { | ||
890 | Int32 lo = ftab[sb] & CLEARMASK; | ||
891 | Int32 hi = (ftab[sb+1] & CLEARMASK) - 1; | ||
892 | if (hi > lo) { | ||
893 | if (verb >= 4) | ||
894 | VPrintf4 ( " qsort [0x%x, 0x%x] " | ||
895 | "done %d this %d\n", | ||
896 | ss, j, numQSorted, hi - lo + 1 ); | ||
897 | mainQSort3 ( | ||
898 | ptr, block, quadrant, nblock, | ||
899 | lo, hi, BZ_N_RADIX, budget | ||
900 | ); | ||
901 | numQSorted += (hi - lo + 1); | ||
902 | if (*budget < 0) return; | ||
903 | } | ||
904 | } | ||
905 | ftab[sb] |= SETMASK; | ||
906 | } | ||
907 | } | ||
908 | |||
909 | AssertH ( !bigDone[ss], 1006 ); | ||
910 | |||
911 | /*-- | ||
912 | Step 2: | ||
913 | Now scan this big bucket [ss] so as to synthesise the | ||
914 | sorted order for small buckets [t, ss] for all t, | ||
915 | including, magically, the bucket [ss,ss] too. | ||
916 | This will avoid doing Real Work in subsequent Step 1's. | ||
917 | --*/ | ||
918 | { | ||
919 | for (j = 0; j <= 255; j++) { | ||
920 | copyStart[j] = ftab[(j << 8) + ss] & CLEARMASK; | ||
921 | copyEnd [j] = (ftab[(j << 8) + ss + 1] & CLEARMASK) - 1; | ||
922 | } | ||
923 | for (j = ftab[ss << 8] & CLEARMASK; j < copyStart[ss]; j++) { | ||
924 | k = ptr[j]-1; if (k < 0) k += nblock; | ||
925 | c1 = block[k]; | ||
926 | if (!bigDone[c1]) | ||
927 | ptr[ copyStart[c1]++ ] = k; | ||
928 | } | ||
929 | for (j = (ftab[(ss+1) << 8] & CLEARMASK) - 1; j > copyEnd[ss]; j--) { | ||
930 | k = ptr[j]-1; if (k < 0) k += nblock; | ||
931 | c1 = block[k]; | ||
932 | if (!bigDone[c1]) | ||
933 | ptr[ copyEnd[c1]-- ] = k; | ||
934 | } | ||
935 | } | ||
936 | |||
937 | AssertH ( (copyStart[ss]-1 == copyEnd[ss]) | ||
938 | || | ||
939 | /* Extremely rare case missing in bzip2-1.0.0 and 1.0.1. | ||
940 | Necessity for this case is demonstrated by compressing | ||
941 | a sequence of approximately 48.5 million of character | ||
942 | 251; 1.0.0/1.0.1 will then die here. */ | ||
943 | (copyStart[ss] == 0 && copyEnd[ss] == nblock-1), | ||
944 | 1007 ) | ||
945 | |||
946 | for (j = 0; j <= 255; j++) ftab[(j << 8) + ss] |= SETMASK; | ||
947 | |||
948 | /*-- | ||
949 | Step 3: | ||
950 | The [ss] big bucket is now done. Record this fact, | ||
951 | and update the quadrant descriptors. Remember to | ||
952 | update quadrants in the overshoot area too, if | ||
953 | necessary. The "if (i < 255)" test merely skips | ||
954 | this updating for the last bucket processed, since | ||
955 | updating for the last bucket is pointless. | ||
956 | |||
957 | The quadrant array provides a way to incrementally | ||
958 | cache sort orderings, as they appear, so as to | ||
959 | make subsequent comparisons in fullGtU() complete | ||
960 | faster. For repetitive blocks this makes a big | ||
961 | difference (but not big enough to be able to avoid | ||
962 | the fallback sorting mechanism, exponential radix sort). | ||
963 | |||
964 | The precise meaning is: at all times: | ||
965 | |||
966 | for 0 <= i < nblock and 0 <= j <= nblock | ||
967 | |||
968 | if block[i] != block[j], | ||
969 | |||
970 | then the relative values of quadrant[i] and | ||
971 | quadrant[j] are meaningless. | ||
972 | |||
973 | else { | ||
974 | if quadrant[i] < quadrant[j] | ||
975 | then the string starting at i lexicographically | ||
976 | precedes the string starting at j | ||
977 | |||
978 | else if quadrant[i] > quadrant[j] | ||
979 | then the string starting at j lexicographically | ||
980 | precedes the string starting at i | ||
981 | |||
982 | else | ||
983 | the relative ordering of the strings starting | ||
984 | at i and j has not yet been determined. | ||
985 | } | ||
986 | --*/ | ||
987 | bigDone[ss] = True; | ||
988 | |||
989 | if (i < 255) { | ||
990 | Int32 bbStart = ftab[ss << 8] & CLEARMASK; | ||
991 | Int32 bbSize = (ftab[(ss+1) << 8] & CLEARMASK) - bbStart; | ||
992 | Int32 shifts = 0; | ||
993 | |||
994 | while ((bbSize >> shifts) > 65534) shifts++; | ||
995 | |||
996 | for (j = bbSize-1; j >= 0; j--) { | ||
997 | Int32 a2update = ptr[bbStart + j]; | ||
998 | UInt16 qVal = (UInt16)(j >> shifts); | ||
999 | quadrant[a2update] = qVal; | ||
1000 | if (a2update < BZ_N_OVERSHOOT) | ||
1001 | quadrant[a2update + nblock] = qVal; | ||
1002 | } | ||
1003 | AssertH ( ((bbSize-1) >> shifts) <= 65535, 1002 ); | ||
1004 | } | ||
1005 | |||
1006 | } | ||
1007 | |||
1008 | if (verb >= 4) | ||
1009 | VPrintf3 ( " %d pointers, %d sorted, %d scanned\n", | ||
1010 | nblock, numQSorted, nblock - numQSorted ); | ||
1011 | } | ||
1012 | |||
1013 | #undef BIGFREQ | ||
1014 | #undef SETMASK | ||
1015 | #undef CLEARMASK | ||
1016 | |||
1017 | |||
1018 | /*---------------------------------------------*/ | ||
1019 | /* Pre: | ||
1020 | nblock > 0 | ||
1021 | arr2 exists for [0 .. nblock-1 +N_OVERSHOOT] | ||
1022 | ((UChar*)arr2) [0 .. nblock-1] holds block | ||
1023 | arr1 exists for [0 .. nblock-1] | ||
1024 | |||
1025 | Post: | ||
1026 | ((UChar*)arr2) [0 .. nblock-1] holds block | ||
1027 | All other areas of block destroyed | ||
1028 | ftab [ 0 .. 65536 ] destroyed | ||
1029 | arr1 [0 .. nblock-1] holds sorted order | ||
1030 | */ | ||
1031 | void BZ2_blockSort ( EState* s ) | ||
1032 | { | ||
1033 | UInt32* ptr = s->ptr; | ||
1034 | UChar* block = s->block; | ||
1035 | UInt32* ftab = s->ftab; | ||
1036 | Int32 nblock = s->nblock; | ||
1037 | Int32 verb = s->verbosity; | ||
1038 | Int32 wfact = s->workFactor; | ||
1039 | UInt16* quadrant; | ||
1040 | Int32 budget; | ||
1041 | Int32 budgetInit; | ||
1042 | Int32 i; | ||
1043 | |||
1044 | if (nblock < 10000) { | ||
1045 | fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb ); | ||
1046 | } else { | ||
1047 | /* Calculate the location for quadrant, remembering to get | ||
1048 | the alignment right. Assumes that &(block[0]) is at least | ||
1049 | 2-byte aligned -- this should be ok since block is really | ||
1050 | the first section of arr2. | ||
1051 | */ | ||
1052 | i = nblock+BZ_N_OVERSHOOT; | ||
1053 | if (i & 1) i++; | ||
1054 | quadrant = (UInt16*)(&(block[i])); | ||
1055 | |||
1056 | /* (wfact-1) / 3 puts the default-factor-30 | ||
1057 | transition point at very roughly the same place as | ||
1058 | with v0.1 and v0.9.0. | ||
1059 | Not that it particularly matters any more, since the | ||
1060 | resulting compressed stream is now the same regardless | ||
1061 | of whether or not we use the main sort or fallback sort. | ||
1062 | */ | ||
1063 | if (wfact < 1 ) wfact = 1; | ||
1064 | if (wfact > 100) wfact = 100; | ||
1065 | budgetInit = nblock * ((wfact-1) / 3); | ||
1066 | budget = budgetInit; | ||
1067 | |||
1068 | mainSort ( ptr, block, quadrant, ftab, nblock, verb, &budget ); | ||
1069 | if (verb >= 3) | ||
1070 | VPrintf3 ( " %d work, %d block, ratio %5.2f\n", | ||
1071 | budgetInit - budget, | ||
1072 | nblock, | ||
1073 | (float)(budgetInit - budget) / | ||
1074 | (float)(nblock==0 ? 1 : nblock) ); | ||
1075 | if (budget < 0) { | ||
1076 | if (verb >= 2) | ||
1077 | VPrintf0 ( " too repetitive; using fallback" | ||
1078 | " sorting algorithm\n" ); | ||
1079 | fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb ); | ||
1080 | } | ||
1081 | } | ||
1082 | |||
1083 | s->origPtr = -1; | ||
1084 | for (i = 0; i < s->nblock; i++) | ||
1085 | if (ptr[i] == 0) | ||
1086 | { s->origPtr = i; break; }; | ||
1087 | |||
1088 | AssertH( s->origPtr != -1, 1003 ); | ||
1089 | } | ||
1090 | |||
1091 | |||
1092 | /*-------------------------------------------------------------*/ | ||
1093 | /*--- end blocksort.c ---*/ | ||
1094 | /*-------------------------------------------------------------*/ | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bz-common.xsl b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bz-common.xsl new file mode 100644 index 0000000..66fcd6f --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bz-common.xsl | |||
@@ -0,0 +1,39 @@ | |||
1 | <?xml version="1.0"?> <!-- -*- sgml -*- --> | ||
2 | <xsl:stylesheet | ||
3 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> | ||
4 | |||
5 | <!-- we like '1.2 Title' --> | ||
6 | <xsl:param name="section.autolabel" select="'1'"/> | ||
7 | <xsl:param name="section.label.includes.component.label" select="'1'"/> | ||
8 | |||
9 | <!-- Do not put 'Chapter' at the start of eg 'Chapter 1. Doing This' --> | ||
10 | <xsl:param name="local.l10n.xml" select="document('')"/> | ||
11 | <l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0"> | ||
12 | <l:l10n language="en"> | ||
13 | <l:context name="title-numbered"> | ||
14 | <l:template name="chapter" text="%n. %t"/> | ||
15 | </l:context> | ||
16 | </l:l10n> | ||
17 | </l:i18n> | ||
18 | |||
19 | <!-- don't generate sub-tocs for qanda sets --> | ||
20 | <xsl:param name="generate.toc"> | ||
21 | set toc,title | ||
22 | book toc,title,figure,table,example,equation | ||
23 | chapter toc,title | ||
24 | section toc | ||
25 | sect1 toc | ||
26 | sect2 toc | ||
27 | sect3 toc | ||
28 | sect4 nop | ||
29 | sect5 nop | ||
30 | qandaset toc | ||
31 | qandadiv nop | ||
32 | appendix toc,title | ||
33 | article/appendix nop | ||
34 | article toc,title | ||
35 | preface toc,title | ||
36 | reference toc,title | ||
37 | </xsl:param> | ||
38 | |||
39 | </xsl:stylesheet> | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bz-fo.xsl b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bz-fo.xsl new file mode 100644 index 0000000..ba3e301 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bz-fo.xsl | |||
@@ -0,0 +1,276 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> <!-- -*- sgml -*- --> | ||
2 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
3 | xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0"> | ||
4 | |||
5 | <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl"/> | ||
6 | <xsl:import href="bz-common.xsl"/> | ||
7 | |||
8 | <!-- set indent = yes while debugging, then change to NO --> | ||
9 | <xsl:output method="xml" indent="yes"/> | ||
10 | |||
11 | <!-- ensure only passivetex extensions are on --> | ||
12 | <xsl:param name="stylesheet.result.type" select="'fo'"/> | ||
13 | <!-- fo extensions: PDF bookmarks and index terms --> | ||
14 | <xsl:param name="use.extensions" select="'1'"/> | ||
15 | <xsl:param name="xep.extensions" select="0"/> | ||
16 | <xsl:param name="fop.extensions" select="0"/> | ||
17 | <xsl:param name="saxon.extensions" select="0"/> | ||
18 | <xsl:param name="passivetex.extensions" select="1"/> | ||
19 | <xsl:param name="tablecolumns.extension" select="'1'"/> | ||
20 | |||
21 | <!-- ensure we are using single sided --> | ||
22 | <xsl:param name="double.sided" select="'0'"/> | ||
23 | |||
24 | <!-- insert cross references to page numbers --> | ||
25 | <xsl:param name="insert.xref.page.number" select="1"/> | ||
26 | |||
27 | <!-- <?custom-pagebreak?> inserts a page break at this point --> | ||
28 | <xsl:template match="processing-instruction('custom-pagebreak')"> | ||
29 | <fo:block break-before='page'/> | ||
30 | </xsl:template> | ||
31 | |||
32 | <!-- show links in color --> | ||
33 | <xsl:attribute-set name="xref.properties"> | ||
34 | <xsl:attribute name="color">blue</xsl:attribute> | ||
35 | </xsl:attribute-set> | ||
36 | |||
37 | <!-- make pre listings indented a bit + a bg colour --> | ||
38 | <xsl:template match="programlisting | screen"> | ||
39 | <fo:block start-indent="0.25in" wrap-option="no-wrap" | ||
40 | white-space-collapse="false" text-align="start" | ||
41 | font-family="monospace" background-color="#f2f2f9" | ||
42 | linefeed-treatment="preserve" | ||
43 | xsl:use-attribute-sets="normal.para.spacing"> | ||
44 | <xsl:apply-templates/> | ||
45 | </fo:block> | ||
46 | </xsl:template> | ||
47 | <!-- make verbatim output prettier --> | ||
48 | <xsl:template match="literallayout"> | ||
49 | <fo:block start-indent="0.25in" wrap-option="no-wrap" | ||
50 | white-space-collapse="false" text-align="start" | ||
51 | font-family="monospace" background-color="#edf7f4" | ||
52 | linefeed-treatment="preserve" | ||
53 | space-before="0em" space-after="0em"> | ||
54 | <xsl:apply-templates/> | ||
55 | </fo:block> | ||
56 | </xsl:template> | ||
57 | |||
58 | <!-- workaround bug in passivetex fo output for itemizedlist --> | ||
59 | <xsl:template match="itemizedlist/listitem"> | ||
60 | <xsl:variable name="id"> | ||
61 | <xsl:call-template name="object.id"/></xsl:variable> | ||
62 | <xsl:variable name="itemsymbol"> | ||
63 | <xsl:call-template name="list.itemsymbol"> | ||
64 | <xsl:with-param name="node" select="parent::itemizedlist"/> | ||
65 | </xsl:call-template> | ||
66 | </xsl:variable> | ||
67 | <xsl:variable name="item.contents"> | ||
68 | <fo:list-item-label end-indent="label-end()"> | ||
69 | <fo:block> | ||
70 | <xsl:choose> | ||
71 | <xsl:when test="$itemsymbol='disc'">•</xsl:when> | ||
72 | <xsl:when test="$itemsymbol='bullet'">•</xsl:when> | ||
73 | <xsl:otherwise>•</xsl:otherwise> | ||
74 | </xsl:choose> | ||
75 | </fo:block> | ||
76 | </fo:list-item-label> | ||
77 | <fo:list-item-body start-indent="body-start()"> | ||
78 | <xsl:apply-templates/> <!-- removed extra block wrapper --> | ||
79 | </fo:list-item-body> | ||
80 | </xsl:variable> | ||
81 | <xsl:choose> | ||
82 | <xsl:when test="parent::*/@spacing = 'compact'"> | ||
83 | <fo:list-item id="{$id}" | ||
84 | xsl:use-attribute-sets="compact.list.item.spacing"> | ||
85 | <xsl:copy-of select="$item.contents"/> | ||
86 | </fo:list-item> | ||
87 | </xsl:when> | ||
88 | <xsl:otherwise> | ||
89 | <fo:list-item id="{$id}" xsl:use-attribute-sets="list.item.spacing"> | ||
90 | <xsl:copy-of select="$item.contents"/> | ||
91 | </fo:list-item> | ||
92 | </xsl:otherwise> | ||
93 | </xsl:choose> | ||
94 | </xsl:template> | ||
95 | |||
96 | <!-- workaround bug in passivetex fo output for orderedlist --> | ||
97 | <xsl:template match="orderedlist/listitem"> | ||
98 | <xsl:variable name="id"> | ||
99 | <xsl:call-template name="object.id"/></xsl:variable> | ||
100 | <xsl:variable name="item.contents"> | ||
101 | <fo:list-item-label end-indent="label-end()"> | ||
102 | <fo:block> | ||
103 | <xsl:apply-templates select="." mode="item-number"/> | ||
104 | </fo:block> | ||
105 | </fo:list-item-label> | ||
106 | <fo:list-item-body start-indent="body-start()"> | ||
107 | <xsl:apply-templates/> <!-- removed extra block wrapper --> | ||
108 | </fo:list-item-body> | ||
109 | </xsl:variable> | ||
110 | <xsl:choose> | ||
111 | <xsl:when test="parent::*/@spacing = 'compact'"> | ||
112 | <fo:list-item id="{$id}" | ||
113 | xsl:use-attribute-sets="compact.list.item.spacing"> | ||
114 | <xsl:copy-of select="$item.contents"/> | ||
115 | </fo:list-item> | ||
116 | </xsl:when> | ||
117 | <xsl:otherwise> | ||
118 | <fo:list-item id="{$id}" xsl:use-attribute-sets="list.item.spacing"> | ||
119 | <xsl:copy-of select="$item.contents"/> | ||
120 | </fo:list-item> | ||
121 | </xsl:otherwise> | ||
122 | </xsl:choose> | ||
123 | </xsl:template> | ||
124 | |||
125 | <!-- workaround bug in passivetex fo output for variablelist --> | ||
126 | <xsl:param name="variablelist.as.blocks" select="1"/> | ||
127 | <xsl:template match="varlistentry" mode="vl.as.blocks"> | ||
128 | <xsl:variable name="id"> | ||
129 | <xsl:call-template name="object.id"/></xsl:variable> | ||
130 | <fo:block id="{$id}" xsl:use-attribute-sets="list.item.spacing" | ||
131 | keep-together.within-column="always" | ||
132 | keep-with-next.within-column="always"> | ||
133 | <xsl:apply-templates select="term"/> | ||
134 | </fo:block> | ||
135 | <fo:block start-indent="0.5in" end-indent="0in" | ||
136 | space-after.minimum="0.2em" | ||
137 | space-after.optimum="0.4em" | ||
138 | space-after.maximum="0.6em"> | ||
139 | <fo:block> | ||
140 | <xsl:apply-templates select="listitem"/> | ||
141 | </fo:block> | ||
142 | </fo:block> | ||
143 | </xsl:template> | ||
144 | |||
145 | |||
146 | <!-- workaround bug in footers: force right-align w/two 80|30 cols --> | ||
147 | <xsl:template name="footer.table"> | ||
148 | <xsl:param name="pageclass" select="''"/> | ||
149 | <xsl:param name="sequence" select="''"/> | ||
150 | <xsl:param name="gentext-key" select="''"/> | ||
151 | <xsl:choose> | ||
152 | <xsl:when test="$pageclass = 'index'"> | ||
153 | <xsl:attribute name="margin-left">0pt</xsl:attribute> | ||
154 | </xsl:when> | ||
155 | </xsl:choose> | ||
156 | <xsl:variable name="candidate"> | ||
157 | <fo:table table-layout="fixed" width="100%"> | ||
158 | <fo:table-column column-number="1" column-width="80%"/> | ||
159 | <fo:table-column column-number="2" column-width="20%"/> | ||
160 | <fo:table-body> | ||
161 | <fo:table-row height="14pt"> | ||
162 | <fo:table-cell text-align="left" display-align="after"> | ||
163 | <xsl:attribute name="relative-align">baseline</xsl:attribute> | ||
164 | <fo:block> | ||
165 | <fo:block> </fo:block><!-- empty cell --> | ||
166 | </fo:block> | ||
167 | </fo:table-cell> | ||
168 | <fo:table-cell text-align="center" display-align="after"> | ||
169 | <xsl:attribute name="relative-align">baseline</xsl:attribute> | ||
170 | <fo:block> | ||
171 | <xsl:call-template name="footer.content"> | ||
172 | <xsl:with-param name="pageclass" select="$pageclass"/> | ||
173 | <xsl:with-param name="sequence" select="$sequence"/> | ||
174 | <xsl:with-param name="position" select="'center'"/> | ||
175 | <xsl:with-param name="gentext-key" select="$gentext-key"/> | ||
176 | </xsl:call-template> | ||
177 | </fo:block> | ||
178 | </fo:table-cell> | ||
179 | </fo:table-row> | ||
180 | </fo:table-body> | ||
181 | </fo:table> | ||
182 | </xsl:variable> | ||
183 | <!-- Really output a footer? --> | ||
184 | <xsl:choose> | ||
185 | <xsl:when test="$pageclass='titlepage' and $gentext-key='book' | ||
186 | and $sequence='first'"> | ||
187 | <!-- no, book titlepages have no footers at all --> | ||
188 | </xsl:when> | ||
189 | <xsl:when test="$sequence = 'blank' and $footers.on.blank.pages = 0"> | ||
190 | <!-- no output --> | ||
191 | </xsl:when> | ||
192 | <xsl:otherwise> | ||
193 | <xsl:copy-of select="$candidate"/> | ||
194 | </xsl:otherwise> | ||
195 | </xsl:choose> | ||
196 | </xsl:template> | ||
197 | |||
198 | |||
199 | <!-- fix bug in headers: force right-align w/two 40|60 cols --> | ||
200 | <xsl:template name="header.table"> | ||
201 | <xsl:param name="pageclass" select="''"/> | ||
202 | <xsl:param name="sequence" select="''"/> | ||
203 | <xsl:param name="gentext-key" select="''"/> | ||
204 | <xsl:choose> | ||
205 | <xsl:when test="$pageclass = 'index'"> | ||
206 | <xsl:attribute name="margin-left">0pt</xsl:attribute> | ||
207 | </xsl:when> | ||
208 | </xsl:choose> | ||
209 | <xsl:variable name="candidate"> | ||
210 | <fo:table table-layout="fixed" width="100%"> | ||
211 | <xsl:call-template name="head.sep.rule"> | ||
212 | <xsl:with-param name="pageclass" select="$pageclass"/> | ||
213 | <xsl:with-param name="sequence" select="$sequence"/> | ||
214 | <xsl:with-param name="gentext-key" select="$gentext-key"/> | ||
215 | </xsl:call-template> | ||
216 | <fo:table-column column-number="1" column-width="40%"/> | ||
217 | <fo:table-column column-number="2" column-width="60%"/> | ||
218 | <fo:table-body> | ||
219 | <fo:table-row height="14pt"> | ||
220 | <fo:table-cell text-align="left" display-align="before"> | ||
221 | <xsl:attribute name="relative-align">baseline</xsl:attribute> | ||
222 | <fo:block> | ||
223 | <fo:block> </fo:block><!-- empty cell --> | ||
224 | </fo:block> | ||
225 | </fo:table-cell> | ||
226 | <fo:table-cell text-align="center" display-align="before"> | ||
227 | <xsl:attribute name="relative-align">baseline</xsl:attribute> | ||
228 | <fo:block> | ||
229 | <xsl:call-template name="header.content"> | ||
230 | <xsl:with-param name="pageclass" select="$pageclass"/> | ||
231 | <xsl:with-param name="sequence" select="$sequence"/> | ||
232 | <xsl:with-param name="position" select="'center'"/> | ||
233 | <xsl:with-param name="gentext-key" select="$gentext-key"/> | ||
234 | </xsl:call-template> | ||
235 | </fo:block> | ||
236 | </fo:table-cell> | ||
237 | </fo:table-row> | ||
238 | </fo:table-body> | ||
239 | </fo:table> | ||
240 | </xsl:variable> | ||
241 | <!-- Really output a header? --> | ||
242 | <xsl:choose> | ||
243 | <xsl:when test="$pageclass = 'titlepage' and $gentext-key = 'book' | ||
244 | and $sequence='first'"> | ||
245 | <!-- no, book titlepages have no headers at all --> | ||
246 | </xsl:when> | ||
247 | <xsl:when test="$sequence = 'blank' and $headers.on.blank.pages = 0"> | ||
248 | <!-- no output --> | ||
249 | </xsl:when> | ||
250 | <xsl:otherwise> | ||
251 | <xsl:copy-of select="$candidate"/> | ||
252 | </xsl:otherwise> | ||
253 | </xsl:choose> | ||
254 | </xsl:template> | ||
255 | |||
256 | |||
257 | <!-- Bug-fix for Suse 10 PassiveTex version --> | ||
258 | <!-- Precompute attribute values 'cos PassiveTex is too stupid: --> | ||
259 | <xsl:attribute-set name="component.title.properties"> | ||
260 | <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute> | ||
261 | <xsl:attribute name="space-before.optimum"> | ||
262 | <xsl:value-of select="concat($body.font.master, 'pt')"/> | ||
263 | </xsl:attribute> | ||
264 | <xsl:attribute name="space-before.minimum"> | ||
265 | <xsl:value-of select="$body.font.master * 0.8"/> | ||
266 | <xsl:text>pt</xsl:text> | ||
267 | </xsl:attribute> | ||
268 | <xsl:attribute name="space-before.maximum"> | ||
269 | <xsl:value-of select="$body.font.master * 1.2"/> | ||
270 | <xsl:text>pt</xsl:text> | ||
271 | </xsl:attribute> | ||
272 | <xsl:attribute name="hyphenate">false</xsl:attribute> | ||
273 | </xsl:attribute-set> | ||
274 | |||
275 | |||
276 | </xsl:stylesheet> | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bz-html.xsl b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bz-html.xsl new file mode 100644 index 0000000..1785fff --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bz-html.xsl | |||
@@ -0,0 +1,20 @@ | |||
1 | <?xml version="1.0"?> <!-- -*- sgml -*- --> | ||
2 | <!DOCTYPE xsl:stylesheet [ <!ENTITY bz-css SYSTEM "./bzip.css"> ]> | ||
3 | |||
4 | <xsl:stylesheet | ||
5 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> | ||
6 | |||
7 | <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl"/> | ||
8 | <xsl:import href="bz-common.xsl"/> | ||
9 | |||
10 | <!-- use 8859-1 encoding --> | ||
11 | <xsl:output method="html" encoding="ISO-8859-1" indent="yes"/> | ||
12 | |||
13 | <!-- we include the css directly when generating one large file --> | ||
14 | <xsl:template name="user.head.content"> | ||
15 | <style type="text/css" media="screen"> | ||
16 | <xsl:text>&bz-css;</xsl:text> | ||
17 | </style> | ||
18 | </xsl:template> | ||
19 | |||
20 | </xsl:stylesheet> | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzcompress.c b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzcompress.c new file mode 100644 index 0000000..caf7696 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzcompress.c | |||
@@ -0,0 +1,672 @@ | |||
1 | |||
2 | /*-------------------------------------------------------------*/ | ||
3 | /*--- Compression machinery (not incl block sorting) ---*/ | ||
4 | /*--- compress.c ---*/ | ||
5 | /*-------------------------------------------------------------*/ | ||
6 | |||
7 | /* ------------------------------------------------------------------ | ||
8 | This file is part of bzip2/libbzip2, a program and library for | ||
9 | lossless, block-sorting data compression. | ||
10 | |||
11 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | ||
12 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | ||
13 | |||
14 | Please read the WARNING, DISCLAIMER and PATENTS sections in the | ||
15 | README file. | ||
16 | |||
17 | This program is released under the terms of the license contained | ||
18 | in the file LICENSE. | ||
19 | ------------------------------------------------------------------ */ | ||
20 | |||
21 | |||
22 | /* CHANGES | ||
23 | 0.9.0 -- original version. | ||
24 | 0.9.0a/b -- no changes in this file. | ||
25 | 0.9.0c -- changed setting of nGroups in sendMTFValues() | ||
26 | so as to do a bit better on small files | ||
27 | */ | ||
28 | |||
29 | #include "bzlib_private.h" | ||
30 | |||
31 | |||
32 | /*---------------------------------------------------*/ | ||
33 | /*--- Bit stream I/O ---*/ | ||
34 | /*---------------------------------------------------*/ | ||
35 | |||
36 | /*---------------------------------------------------*/ | ||
37 | void BZ2_bsInitWrite ( EState* s ) | ||
38 | { | ||
39 | s->bsLive = 0; | ||
40 | s->bsBuff = 0; | ||
41 | } | ||
42 | |||
43 | |||
44 | /*---------------------------------------------------*/ | ||
45 | static | ||
46 | void bsFinishWrite ( EState* s ) | ||
47 | { | ||
48 | while (s->bsLive > 0) { | ||
49 | s->zbits[s->numZ] = (UChar)(s->bsBuff >> 24); | ||
50 | s->numZ++; | ||
51 | s->bsBuff <<= 8; | ||
52 | s->bsLive -= 8; | ||
53 | } | ||
54 | } | ||
55 | |||
56 | |||
57 | /*---------------------------------------------------*/ | ||
58 | #define bsNEEDW(nz) \ | ||
59 | { \ | ||
60 | while (s->bsLive >= 8) { \ | ||
61 | s->zbits[s->numZ] \ | ||
62 | = (UChar)(s->bsBuff >> 24); \ | ||
63 | s->numZ++; \ | ||
64 | s->bsBuff <<= 8; \ | ||
65 | s->bsLive -= 8; \ | ||
66 | } \ | ||
67 | } | ||
68 | |||
69 | |||
70 | /*---------------------------------------------------*/ | ||
71 | static | ||
72 | __inline__ | ||
73 | void bsW ( EState* s, Int32 n, UInt32 v ) | ||
74 | { | ||
75 | bsNEEDW ( n ); | ||
76 | s->bsBuff |= (v << (32 - s->bsLive - n)); | ||
77 | s->bsLive += n; | ||
78 | } | ||
79 | |||
80 | |||
81 | /*---------------------------------------------------*/ | ||
82 | static | ||
83 | void bsPutUInt32 ( EState* s, UInt32 u ) | ||
84 | { | ||
85 | bsW ( s, 8, (u >> 24) & 0xffL ); | ||
86 | bsW ( s, 8, (u >> 16) & 0xffL ); | ||
87 | bsW ( s, 8, (u >> 8) & 0xffL ); | ||
88 | bsW ( s, 8, u & 0xffL ); | ||
89 | } | ||
90 | |||
91 | |||
92 | /*---------------------------------------------------*/ | ||
93 | static | ||
94 | void bsPutUChar ( EState* s, UChar c ) | ||
95 | { | ||
96 | bsW( s, 8, (UInt32)c ); | ||
97 | } | ||
98 | |||
99 | |||
100 | /*---------------------------------------------------*/ | ||
101 | /*--- The back end proper ---*/ | ||
102 | /*---------------------------------------------------*/ | ||
103 | |||
104 | /*---------------------------------------------------*/ | ||
105 | static | ||
106 | void makeMaps_e ( EState* s ) | ||
107 | { | ||
108 | Int32 i; | ||
109 | s->nInUse = 0; | ||
110 | for (i = 0; i < 256; i++) | ||
111 | if (s->inUse[i]) { | ||
112 | s->unseqToSeq[i] = s->nInUse; | ||
113 | s->nInUse++; | ||
114 | } | ||
115 | } | ||
116 | |||
117 | |||
118 | /*---------------------------------------------------*/ | ||
119 | static | ||
120 | void generateMTFValues ( EState* s ) | ||
121 | { | ||
122 | UChar yy[256]; | ||
123 | Int32 i, j; | ||
124 | Int32 zPend; | ||
125 | Int32 wr; | ||
126 | Int32 EOB; | ||
127 | |||
128 | /* | ||
129 | After sorting (eg, here), | ||
130 | s->arr1 [ 0 .. s->nblock-1 ] holds sorted order, | ||
131 | and | ||
132 | ((UChar*)s->arr2) [ 0 .. s->nblock-1 ] | ||
133 | holds the original block data. | ||
134 | |||
135 | The first thing to do is generate the MTF values, | ||
136 | and put them in | ||
137 | ((UInt16*)s->arr1) [ 0 .. s->nblock-1 ]. | ||
138 | Because there are strictly fewer or equal MTF values | ||
139 | than block values, ptr values in this area are overwritten | ||
140 | with MTF values only when they are no longer needed. | ||
141 | |||
142 | The final compressed bitstream is generated into the | ||
143 | area starting at | ||
144 | (UChar*) (&((UChar*)s->arr2)[s->nblock]) | ||
145 | |||
146 | These storage aliases are set up in bzCompressInit(), | ||
147 | except for the last one, which is arranged in | ||
148 | compressBlock(). | ||
149 | */ | ||
150 | UInt32* ptr = s->ptr; | ||
151 | UChar* block = s->block; | ||
152 | UInt16* mtfv = s->mtfv; | ||
153 | |||
154 | makeMaps_e ( s ); | ||
155 | EOB = s->nInUse+1; | ||
156 | |||
157 | for (i = 0; i <= EOB; i++) s->mtfFreq[i] = 0; | ||
158 | |||
159 | wr = 0; | ||
160 | zPend = 0; | ||
161 | for (i = 0; i < s->nInUse; i++) yy[i] = (UChar) i; | ||
162 | |||
163 | for (i = 0; i < s->nblock; i++) { | ||
164 | UChar ll_i; | ||
165 | AssertD ( wr <= i, "generateMTFValues(1)" ); | ||
166 | j = ptr[i]-1; if (j < 0) j += s->nblock; | ||
167 | ll_i = s->unseqToSeq[block[j]]; | ||
168 | AssertD ( ll_i < s->nInUse, "generateMTFValues(2a)" ); | ||
169 | |||
170 | if (yy[0] == ll_i) { | ||
171 | zPend++; | ||
172 | } else { | ||
173 | |||
174 | if (zPend > 0) { | ||
175 | zPend--; | ||
176 | while (True) { | ||
177 | if (zPend & 1) { | ||
178 | mtfv[wr] = BZ_RUNB; wr++; | ||
179 | s->mtfFreq[BZ_RUNB]++; | ||
180 | } else { | ||
181 | mtfv[wr] = BZ_RUNA; wr++; | ||
182 | s->mtfFreq[BZ_RUNA]++; | ||
183 | } | ||
184 | if (zPend < 2) break; | ||
185 | zPend = (zPend - 2) / 2; | ||
186 | }; | ||
187 | zPend = 0; | ||
188 | } | ||
189 | { | ||
190 | register UChar rtmp; | ||
191 | register UChar* ryy_j; | ||
192 | register UChar rll_i; | ||
193 | rtmp = yy[1]; | ||
194 | yy[1] = yy[0]; | ||
195 | ryy_j = &(yy[1]); | ||
196 | rll_i = ll_i; | ||
197 | while ( rll_i != rtmp ) { | ||
198 | register UChar rtmp2; | ||
199 | ryy_j++; | ||
200 | rtmp2 = rtmp; | ||
201 | rtmp = *ryy_j; | ||
202 | *ryy_j = rtmp2; | ||
203 | }; | ||
204 | yy[0] = rtmp; | ||
205 | j = ryy_j - &(yy[0]); | ||
206 | mtfv[wr] = j+1; wr++; s->mtfFreq[j+1]++; | ||
207 | } | ||
208 | |||
209 | } | ||
210 | } | ||
211 | |||
212 | if (zPend > 0) { | ||
213 | zPend--; | ||
214 | while (True) { | ||
215 | if (zPend & 1) { | ||
216 | mtfv[wr] = BZ_RUNB; wr++; | ||
217 | s->mtfFreq[BZ_RUNB]++; | ||
218 | } else { | ||
219 | mtfv[wr] = BZ_RUNA; wr++; | ||
220 | s->mtfFreq[BZ_RUNA]++; | ||
221 | } | ||
222 | if (zPend < 2) break; | ||
223 | zPend = (zPend - 2) / 2; | ||
224 | }; | ||
225 | zPend = 0; | ||
226 | } | ||
227 | |||
228 | mtfv[wr] = EOB; wr++; s->mtfFreq[EOB]++; | ||
229 | |||
230 | s->nMTF = wr; | ||
231 | } | ||
232 | |||
233 | |||
234 | /*---------------------------------------------------*/ | ||
235 | #define BZ_LESSER_ICOST 0 | ||
236 | #define BZ_GREATER_ICOST 15 | ||
237 | |||
238 | static | ||
239 | void sendMTFValues ( EState* s ) | ||
240 | { | ||
241 | Int32 v, t, i, j, gs, ge, totc, bt, bc, iter; | ||
242 | Int32 nSelectors, alphaSize, minLen, maxLen, selCtr; | ||
243 | Int32 nGroups, nBytes; | ||
244 | |||
245 | /*-- | ||
246 | UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; | ||
247 | is a global since the decoder also needs it. | ||
248 | |||
249 | Int32 code[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; | ||
250 | Int32 rfreq[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; | ||
251 | are also globals only used in this proc. | ||
252 | Made global to keep stack frame size small. | ||
253 | --*/ | ||
254 | |||
255 | |||
256 | UInt16 cost[BZ_N_GROUPS]; | ||
257 | Int32 fave[BZ_N_GROUPS]; | ||
258 | |||
259 | UInt16* mtfv = s->mtfv; | ||
260 | |||
261 | if (s->verbosity >= 3) | ||
262 | VPrintf3( " %d in block, %d after MTF & 1-2 coding, " | ||
263 | "%d+2 syms in use\n", | ||
264 | s->nblock, s->nMTF, s->nInUse ); | ||
265 | |||
266 | alphaSize = s->nInUse+2; | ||
267 | for (t = 0; t < BZ_N_GROUPS; t++) | ||
268 | for (v = 0; v < alphaSize; v++) | ||
269 | s->len[t][v] = BZ_GREATER_ICOST; | ||
270 | |||
271 | /*--- Decide how many coding tables to use ---*/ | ||
272 | AssertH ( s->nMTF > 0, 3001 ); | ||
273 | if (s->nMTF < 200) nGroups = 2; else | ||
274 | if (s->nMTF < 600) nGroups = 3; else | ||
275 | if (s->nMTF < 1200) nGroups = 4; else | ||
276 | if (s->nMTF < 2400) nGroups = 5; else | ||
277 | nGroups = 6; | ||
278 | |||
279 | /*--- Generate an initial set of coding tables ---*/ | ||
280 | { | ||
281 | Int32 nPart, remF, tFreq, aFreq; | ||
282 | |||
283 | nPart = nGroups; | ||
284 | remF = s->nMTF; | ||
285 | gs = 0; | ||
286 | while (nPart > 0) { | ||
287 | tFreq = remF / nPart; | ||
288 | ge = gs-1; | ||
289 | aFreq = 0; | ||
290 | while (aFreq < tFreq && ge < alphaSize-1) { | ||
291 | ge++; | ||
292 | aFreq += s->mtfFreq[ge]; | ||
293 | } | ||
294 | |||
295 | if (ge > gs | ||
296 | && nPart != nGroups && nPart != 1 | ||
297 | && ((nGroups-nPart) % 2 == 1)) { | ||
298 | aFreq -= s->mtfFreq[ge]; | ||
299 | ge--; | ||
300 | } | ||
301 | |||
302 | if (s->verbosity >= 3) | ||
303 | VPrintf5( " initial group %d, [%d .. %d], " | ||
304 | "has %d syms (%4.1f%%)\n", | ||
305 | nPart, gs, ge, aFreq, | ||
306 | (100.0 * (float)aFreq) / (float)(s->nMTF) ); | ||
307 | |||
308 | for (v = 0; v < alphaSize; v++) | ||
309 | if (v >= gs && v <= ge) | ||
310 | s->len[nPart-1][v] = BZ_LESSER_ICOST; else | ||
311 | s->len[nPart-1][v] = BZ_GREATER_ICOST; | ||
312 | |||
313 | nPart--; | ||
314 | gs = ge+1; | ||
315 | remF -= aFreq; | ||
316 | } | ||
317 | } | ||
318 | |||
319 | /*--- | ||
320 | Iterate up to BZ_N_ITERS times to improve the tables. | ||
321 | ---*/ | ||
322 | for (iter = 0; iter < BZ_N_ITERS; iter++) { | ||
323 | |||
324 | for (t = 0; t < nGroups; t++) fave[t] = 0; | ||
325 | |||
326 | for (t = 0; t < nGroups; t++) | ||
327 | for (v = 0; v < alphaSize; v++) | ||
328 | s->rfreq[t][v] = 0; | ||
329 | |||
330 | /*--- | ||
331 | Set up an auxiliary length table which is used to fast-track | ||
332 | the common case (nGroups == 6). | ||
333 | ---*/ | ||
334 | if (nGroups == 6) { | ||
335 | for (v = 0; v < alphaSize; v++) { | ||
336 | s->len_pack[v][0] = (s->len[1][v] << 16) | s->len[0][v]; | ||
337 | s->len_pack[v][1] = (s->len[3][v] << 16) | s->len[2][v]; | ||
338 | s->len_pack[v][2] = (s->len[5][v] << 16) | s->len[4][v]; | ||
339 | } | ||
340 | } | ||
341 | |||
342 | nSelectors = 0; | ||
343 | totc = 0; | ||
344 | gs = 0; | ||
345 | while (True) { | ||
346 | |||
347 | /*--- Set group start & end marks. --*/ | ||
348 | if (gs >= s->nMTF) break; | ||
349 | ge = gs + BZ_G_SIZE - 1; | ||
350 | if (ge >= s->nMTF) ge = s->nMTF-1; | ||
351 | |||
352 | /*-- | ||
353 | Calculate the cost of this group as coded | ||
354 | by each of the coding tables. | ||
355 | --*/ | ||
356 | for (t = 0; t < nGroups; t++) cost[t] = 0; | ||
357 | |||
358 | if (nGroups == 6 && 50 == ge-gs+1) { | ||
359 | /*--- fast track the common case ---*/ | ||
360 | register UInt32 cost01, cost23, cost45; | ||
361 | register UInt16 icv; | ||
362 | cost01 = cost23 = cost45 = 0; | ||
363 | |||
364 | # define BZ_ITER(nn) \ | ||
365 | icv = mtfv[gs+(nn)]; \ | ||
366 | cost01 += s->len_pack[icv][0]; \ | ||
367 | cost23 += s->len_pack[icv][1]; \ | ||
368 | cost45 += s->len_pack[icv][2]; \ | ||
369 | |||
370 | BZ_ITER(0); BZ_ITER(1); BZ_ITER(2); BZ_ITER(3); BZ_ITER(4); | ||
371 | BZ_ITER(5); BZ_ITER(6); BZ_ITER(7); BZ_ITER(8); BZ_ITER(9); | ||
372 | BZ_ITER(10); BZ_ITER(11); BZ_ITER(12); BZ_ITER(13); BZ_ITER(14); | ||
373 | BZ_ITER(15); BZ_ITER(16); BZ_ITER(17); BZ_ITER(18); BZ_ITER(19); | ||
374 | BZ_ITER(20); BZ_ITER(21); BZ_ITER(22); BZ_ITER(23); BZ_ITER(24); | ||
375 | BZ_ITER(25); BZ_ITER(26); BZ_ITER(27); BZ_ITER(28); BZ_ITER(29); | ||
376 | BZ_ITER(30); BZ_ITER(31); BZ_ITER(32); BZ_ITER(33); BZ_ITER(34); | ||
377 | BZ_ITER(35); BZ_ITER(36); BZ_ITER(37); BZ_ITER(38); BZ_ITER(39); | ||
378 | BZ_ITER(40); BZ_ITER(41); BZ_ITER(42); BZ_ITER(43); BZ_ITER(44); | ||
379 | BZ_ITER(45); BZ_ITER(46); BZ_ITER(47); BZ_ITER(48); BZ_ITER(49); | ||
380 | |||
381 | # undef BZ_ITER | ||
382 | |||
383 | cost[0] = cost01 & 0xffff; cost[1] = cost01 >> 16; | ||
384 | cost[2] = cost23 & 0xffff; cost[3] = cost23 >> 16; | ||
385 | cost[4] = cost45 & 0xffff; cost[5] = cost45 >> 16; | ||
386 | |||
387 | } else { | ||
388 | /*--- slow version which correctly handles all situations ---*/ | ||
389 | for (i = gs; i <= ge; i++) { | ||
390 | UInt16 icv = mtfv[i]; | ||
391 | for (t = 0; t < nGroups; t++) cost[t] += s->len[t][icv]; | ||
392 | } | ||
393 | } | ||
394 | |||
395 | /*-- | ||
396 | Find the coding table which is best for this group, | ||
397 | and record its identity in the selector table. | ||
398 | --*/ | ||
399 | bc = 999999999; bt = -1; | ||
400 | for (t = 0; t < nGroups; t++) | ||
401 | if (cost[t] < bc) { bc = cost[t]; bt = t; }; | ||
402 | totc += bc; | ||
403 | fave[bt]++; | ||
404 | s->selector[nSelectors] = bt; | ||
405 | nSelectors++; | ||
406 | |||
407 | /*-- | ||
408 | Increment the symbol frequencies for the selected table. | ||
409 | --*/ | ||
410 | if (nGroups == 6 && 50 == ge-gs+1) { | ||
411 | /*--- fast track the common case ---*/ | ||
412 | |||
413 | # define BZ_ITUR(nn) s->rfreq[bt][ mtfv[gs+(nn)] ]++ | ||
414 | |||
415 | BZ_ITUR(0); BZ_ITUR(1); BZ_ITUR(2); BZ_ITUR(3); BZ_ITUR(4); | ||
416 | BZ_ITUR(5); BZ_ITUR(6); BZ_ITUR(7); BZ_ITUR(8); BZ_ITUR(9); | ||
417 | BZ_ITUR(10); BZ_ITUR(11); BZ_ITUR(12); BZ_ITUR(13); BZ_ITUR(14); | ||
418 | BZ_ITUR(15); BZ_ITUR(16); BZ_ITUR(17); BZ_ITUR(18); BZ_ITUR(19); | ||
419 | BZ_ITUR(20); BZ_ITUR(21); BZ_ITUR(22); BZ_ITUR(23); BZ_ITUR(24); | ||
420 | BZ_ITUR(25); BZ_ITUR(26); BZ_ITUR(27); BZ_ITUR(28); BZ_ITUR(29); | ||
421 | BZ_ITUR(30); BZ_ITUR(31); BZ_ITUR(32); BZ_ITUR(33); BZ_ITUR(34); | ||
422 | BZ_ITUR(35); BZ_ITUR(36); BZ_ITUR(37); BZ_ITUR(38); BZ_ITUR(39); | ||
423 | BZ_ITUR(40); BZ_ITUR(41); BZ_ITUR(42); BZ_ITUR(43); BZ_ITUR(44); | ||
424 | BZ_ITUR(45); BZ_ITUR(46); BZ_ITUR(47); BZ_ITUR(48); BZ_ITUR(49); | ||
425 | |||
426 | # undef BZ_ITUR | ||
427 | |||
428 | } else { | ||
429 | /*--- slow version which correctly handles all situations ---*/ | ||
430 | for (i = gs; i <= ge; i++) | ||
431 | s->rfreq[bt][ mtfv[i] ]++; | ||
432 | } | ||
433 | |||
434 | gs = ge+1; | ||
435 | } | ||
436 | if (s->verbosity >= 3) { | ||
437 | VPrintf2 ( " pass %d: size is %d, grp uses are ", | ||
438 | iter+1, totc/8 ); | ||
439 | for (t = 0; t < nGroups; t++) | ||
440 | VPrintf1 ( "%d ", fave[t] ); | ||
441 | VPrintf0 ( "\n" ); | ||
442 | } | ||
443 | |||
444 | /*-- | ||
445 | Recompute the tables based on the accumulated frequencies. | ||
446 | --*/ | ||
447 | /* maxLen was changed from 20 to 17 in bzip2-1.0.3. See | ||
448 | comment in huffman.c for details. */ | ||
449 | for (t = 0; t < nGroups; t++) | ||
450 | BZ2_hbMakeCodeLengths ( &(s->len[t][0]), &(s->rfreq[t][0]), | ||
451 | alphaSize, 17 /*20*/ ); | ||
452 | } | ||
453 | |||
454 | |||
455 | AssertH( nGroups < 8, 3002 ); | ||
456 | AssertH( nSelectors < 32768 && | ||
457 | nSelectors <= (2 + (900000 / BZ_G_SIZE)), | ||
458 | 3003 ); | ||
459 | |||
460 | |||
461 | /*--- Compute MTF values for the selectors. ---*/ | ||
462 | { | ||
463 | UChar pos[BZ_N_GROUPS], ll_i, tmp2, tmp; | ||
464 | for (i = 0; i < nGroups; i++) pos[i] = i; | ||
465 | for (i = 0; i < nSelectors; i++) { | ||
466 | ll_i = s->selector[i]; | ||
467 | j = 0; | ||
468 | tmp = pos[j]; | ||
469 | while ( ll_i != tmp ) { | ||
470 | j++; | ||
471 | tmp2 = tmp; | ||
472 | tmp = pos[j]; | ||
473 | pos[j] = tmp2; | ||
474 | }; | ||
475 | pos[0] = tmp; | ||
476 | s->selectorMtf[i] = j; | ||
477 | } | ||
478 | }; | ||
479 | |||
480 | /*--- Assign actual codes for the tables. --*/ | ||
481 | for (t = 0; t < nGroups; t++) { | ||
482 | minLen = 32; | ||
483 | maxLen = 0; | ||
484 | for (i = 0; i < alphaSize; i++) { | ||
485 | if (s->len[t][i] > maxLen) maxLen = s->len[t][i]; | ||
486 | if (s->len[t][i] < minLen) minLen = s->len[t][i]; | ||
487 | } | ||
488 | AssertH ( !(maxLen > 17 /*20*/ ), 3004 ); | ||
489 | AssertH ( !(minLen < 1), 3005 ); | ||
490 | BZ2_hbAssignCodes ( &(s->code[t][0]), &(s->len[t][0]), | ||
491 | minLen, maxLen, alphaSize ); | ||
492 | } | ||
493 | |||
494 | /*--- Transmit the mapping table. ---*/ | ||
495 | { | ||
496 | Bool inUse16[16]; | ||
497 | for (i = 0; i < 16; i++) { | ||
498 | inUse16[i] = False; | ||
499 | for (j = 0; j < 16; j++) | ||
500 | if (s->inUse[i * 16 + j]) inUse16[i] = True; | ||
501 | } | ||
502 | |||
503 | nBytes = s->numZ; | ||
504 | for (i = 0; i < 16; i++) | ||
505 | if (inUse16[i]) bsW(s,1,1); else bsW(s,1,0); | ||
506 | |||
507 | for (i = 0; i < 16; i++) | ||
508 | if (inUse16[i]) | ||
509 | for (j = 0; j < 16; j++) { | ||
510 | if (s->inUse[i * 16 + j]) bsW(s,1,1); else bsW(s,1,0); | ||
511 | } | ||
512 | |||
513 | if (s->verbosity >= 3) | ||
514 | VPrintf1( " bytes: mapping %d, ", s->numZ-nBytes ); | ||
515 | } | ||
516 | |||
517 | /*--- Now the selectors. ---*/ | ||
518 | nBytes = s->numZ; | ||
519 | bsW ( s, 3, nGroups ); | ||
520 | bsW ( s, 15, nSelectors ); | ||
521 | for (i = 0; i < nSelectors; i++) { | ||
522 | for (j = 0; j < s->selectorMtf[i]; j++) bsW(s,1,1); | ||
523 | bsW(s,1,0); | ||
524 | } | ||
525 | if (s->verbosity >= 3) | ||
526 | VPrintf1( "selectors %d, ", s->numZ-nBytes ); | ||
527 | |||
528 | /*--- Now the coding tables. ---*/ | ||
529 | nBytes = s->numZ; | ||
530 | |||
531 | for (t = 0; t < nGroups; t++) { | ||
532 | Int32 curr = s->len[t][0]; | ||
533 | bsW ( s, 5, curr ); | ||
534 | for (i = 0; i < alphaSize; i++) { | ||
535 | while (curr < s->len[t][i]) { bsW(s,2,2); curr++; /* 10 */ }; | ||
536 | while (curr > s->len[t][i]) { bsW(s,2,3); curr--; /* 11 */ }; | ||
537 | bsW ( s, 1, 0 ); | ||
538 | } | ||
539 | } | ||
540 | |||
541 | if (s->verbosity >= 3) | ||
542 | VPrintf1 ( "code lengths %d, ", s->numZ-nBytes ); | ||
543 | |||
544 | /*--- And finally, the block data proper ---*/ | ||
545 | nBytes = s->numZ; | ||
546 | selCtr = 0; | ||
547 | gs = 0; | ||
548 | while (True) { | ||
549 | if (gs >= s->nMTF) break; | ||
550 | ge = gs + BZ_G_SIZE - 1; | ||
551 | if (ge >= s->nMTF) ge = s->nMTF-1; | ||
552 | AssertH ( s->selector[selCtr] < nGroups, 3006 ); | ||
553 | |||
554 | if (nGroups == 6 && 50 == ge-gs+1) { | ||
555 | /*--- fast track the common case ---*/ | ||
556 | UInt16 mtfv_i; | ||
557 | UChar* s_len_sel_selCtr | ||
558 | = &(s->len[s->selector[selCtr]][0]); | ||
559 | Int32* s_code_sel_selCtr | ||
560 | = &(s->code[s->selector[selCtr]][0]); | ||
561 | |||
562 | # define BZ_ITAH(nn) \ | ||
563 | mtfv_i = mtfv[gs+(nn)]; \ | ||
564 | bsW ( s, \ | ||
565 | s_len_sel_selCtr[mtfv_i], \ | ||
566 | s_code_sel_selCtr[mtfv_i] ) | ||
567 | |||
568 | BZ_ITAH(0); BZ_ITAH(1); BZ_ITAH(2); BZ_ITAH(3); BZ_ITAH(4); | ||
569 | BZ_ITAH(5); BZ_ITAH(6); BZ_ITAH(7); BZ_ITAH(8); BZ_ITAH(9); | ||
570 | BZ_ITAH(10); BZ_ITAH(11); BZ_ITAH(12); BZ_ITAH(13); BZ_ITAH(14); | ||
571 | BZ_ITAH(15); BZ_ITAH(16); BZ_ITAH(17); BZ_ITAH(18); BZ_ITAH(19); | ||
572 | BZ_ITAH(20); BZ_ITAH(21); BZ_ITAH(22); BZ_ITAH(23); BZ_ITAH(24); | ||
573 | BZ_ITAH(25); BZ_ITAH(26); BZ_ITAH(27); BZ_ITAH(28); BZ_ITAH(29); | ||
574 | BZ_ITAH(30); BZ_ITAH(31); BZ_ITAH(32); BZ_ITAH(33); BZ_ITAH(34); | ||
575 | BZ_ITAH(35); BZ_ITAH(36); BZ_ITAH(37); BZ_ITAH(38); BZ_ITAH(39); | ||
576 | BZ_ITAH(40); BZ_ITAH(41); BZ_ITAH(42); BZ_ITAH(43); BZ_ITAH(44); | ||
577 | BZ_ITAH(45); BZ_ITAH(46); BZ_ITAH(47); BZ_ITAH(48); BZ_ITAH(49); | ||
578 | |||
579 | # undef BZ_ITAH | ||
580 | |||
581 | } else { | ||
582 | /*--- slow version which correctly handles all situations ---*/ | ||
583 | for (i = gs; i <= ge; i++) { | ||
584 | bsW ( s, | ||
585 | s->len [s->selector[selCtr]] [mtfv[i]], | ||
586 | s->code [s->selector[selCtr]] [mtfv[i]] ); | ||
587 | } | ||
588 | } | ||
589 | |||
590 | |||
591 | gs = ge+1; | ||
592 | selCtr++; | ||
593 | } | ||
594 | AssertH( selCtr == nSelectors, 3007 ); | ||
595 | |||
596 | if (s->verbosity >= 3) | ||
597 | VPrintf1( "codes %d\n", s->numZ-nBytes ); | ||
598 | } | ||
599 | |||
600 | |||
601 | /*---------------------------------------------------*/ | ||
602 | void BZ2_compressBlock ( EState* s, Bool is_last_block ) | ||
603 | { | ||
604 | if (s->nblock > 0) { | ||
605 | |||
606 | BZ_FINALISE_CRC ( s->blockCRC ); | ||
607 | s->combinedCRC = (s->combinedCRC << 1) | (s->combinedCRC >> 31); | ||
608 | s->combinedCRC ^= s->blockCRC; | ||
609 | if (s->blockNo > 1) s->numZ = 0; | ||
610 | |||
611 | if (s->verbosity >= 2) | ||
612 | VPrintf4( " block %d: crc = 0x%08x, " | ||
613 | "combined CRC = 0x%08x, size = %d\n", | ||
614 | s->blockNo, s->blockCRC, s->combinedCRC, s->nblock ); | ||
615 | |||
616 | BZ2_blockSort ( s ); | ||
617 | } | ||
618 | |||
619 | s->zbits = (UChar*) (&((UChar*)s->arr2)[s->nblock]); | ||
620 | |||
621 | /*-- If this is the first block, create the stream header. --*/ | ||
622 | if (s->blockNo == 1) { | ||
623 | BZ2_bsInitWrite ( s ); | ||
624 | bsPutUChar ( s, BZ_HDR_B ); | ||
625 | bsPutUChar ( s, BZ_HDR_Z ); | ||
626 | bsPutUChar ( s, BZ_HDR_h ); | ||
627 | bsPutUChar ( s, (UChar)(BZ_HDR_0 + s->blockSize100k) ); | ||
628 | } | ||
629 | |||
630 | if (s->nblock > 0) { | ||
631 | |||
632 | bsPutUChar ( s, 0x31 ); bsPutUChar ( s, 0x41 ); | ||
633 | bsPutUChar ( s, 0x59 ); bsPutUChar ( s, 0x26 ); | ||
634 | bsPutUChar ( s, 0x53 ); bsPutUChar ( s, 0x59 ); | ||
635 | |||
636 | /*-- Now the block's CRC, so it is in a known place. --*/ | ||
637 | bsPutUInt32 ( s, s->blockCRC ); | ||
638 | |||
639 | /*-- | ||
640 | Now a single bit indicating (non-)randomisation. | ||
641 | As of version 0.9.5, we use a better sorting algorithm | ||
642 | which makes randomisation unnecessary. So always set | ||
643 | the randomised bit to 'no'. Of course, the decoder | ||
644 | still needs to be able to handle randomised blocks | ||
645 | so as to maintain backwards compatibility with | ||
646 | older versions of bzip2. | ||
647 | --*/ | ||
648 | bsW(s,1,0); | ||
649 | |||
650 | bsW ( s, 24, s->origPtr ); | ||
651 | generateMTFValues ( s ); | ||
652 | sendMTFValues ( s ); | ||
653 | } | ||
654 | |||
655 | |||
656 | /*-- If this is the last block, add the stream trailer. --*/ | ||
657 | if (is_last_block) { | ||
658 | |||
659 | bsPutUChar ( s, 0x17 ); bsPutUChar ( s, 0x72 ); | ||
660 | bsPutUChar ( s, 0x45 ); bsPutUChar ( s, 0x38 ); | ||
661 | bsPutUChar ( s, 0x50 ); bsPutUChar ( s, 0x90 ); | ||
662 | bsPutUInt32 ( s, s->combinedCRC ); | ||
663 | if (s->verbosity >= 2) | ||
664 | VPrintf1( " final combined CRC = 0x%08x\n ", s->combinedCRC ); | ||
665 | bsFinishWrite ( s ); | ||
666 | } | ||
667 | } | ||
668 | |||
669 | |||
670 | /*-------------------------------------------------------------*/ | ||
671 | /*--- end compress.c ---*/ | ||
672 | /*-------------------------------------------------------------*/ | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzdiff b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzdiff new file mode 100644 index 0000000..6fc38f9 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzdiff | |||
@@ -0,0 +1,76 @@ | |||
1 | #!/bin/sh | ||
2 | # sh is buggy on RS/6000 AIX 3.2. Replace above line with #!/bin/ksh | ||
3 | |||
4 | # Bzcmp/diff wrapped for bzip2, | ||
5 | # adapted from zdiff by Philippe Troin <phil@fifi.org> for Debian GNU/Linux. | ||
6 | |||
7 | # Bzcmp and bzdiff are used to invoke the cmp or the diff pro- | ||
8 | # gram on compressed files. All options specified are passed | ||
9 | # directly to cmp or diff. If only 1 file is specified, then | ||
10 | # the files compared are file1 and an uncompressed file1.gz. | ||
11 | # If two files are specified, then they are uncompressed (if | ||
12 | # necessary) and fed to cmp or diff. The exit status from cmp | ||
13 | # or diff is preserved. | ||
14 | |||
15 | PATH="/usr/bin:/bin:$PATH"; export PATH | ||
16 | prog=`echo $0 | sed 's|.*/||'` | ||
17 | case "$prog" in | ||
18 | *cmp) comp=${CMP-cmp} ;; | ||
19 | *) comp=${DIFF-diff} ;; | ||
20 | esac | ||
21 | |||
22 | OPTIONS= | ||
23 | FILES= | ||
24 | for ARG | ||
25 | do | ||
26 | case "$ARG" in | ||
27 | -*) OPTIONS="$OPTIONS $ARG";; | ||
28 | *) if test -f "$ARG"; then | ||
29 | FILES="$FILES $ARG" | ||
30 | else | ||
31 | echo "${prog}: $ARG not found or not a regular file" | ||
32 | exit 1 | ||
33 | fi ;; | ||
34 | esac | ||
35 | done | ||
36 | if test -z "$FILES"; then | ||
37 | echo "Usage: $prog [${comp}_options] file [file]" | ||
38 | exit 1 | ||
39 | fi | ||
40 | tmp=`mktemp ${TMPDIR:-/tmp}/bzdiff.XXXXXXXXXX` || { | ||
41 | echo 'cannot create a temporary file' >&2 | ||
42 | exit 1 | ||
43 | } | ||
44 | set $FILES | ||
45 | if test $# -eq 1; then | ||
46 | FILE=`echo "$1" | sed 's/.bz2$//'` | ||
47 | bzip2 -cd "$FILE.bz2" | $comp $OPTIONS - "$FILE" | ||
48 | STAT="$?" | ||
49 | |||
50 | elif test $# -eq 2; then | ||
51 | case "$1" in | ||
52 | *.bz2) | ||
53 | case "$2" in | ||
54 | *.bz2) | ||
55 | F=`echo "$2" | sed 's|.*/||;s|.bz2$||'` | ||
56 | bzip2 -cdfq "$2" > $tmp | ||
57 | bzip2 -cdfq "$1" | $comp $OPTIONS - $tmp | ||
58 | STAT="$?" | ||
59 | /bin/rm -f $tmp;; | ||
60 | |||
61 | *) bzip2 -cdfq "$1" | $comp $OPTIONS - "$2" | ||
62 | STAT="$?";; | ||
63 | esac;; | ||
64 | *) case "$2" in | ||
65 | *.bz2) | ||
66 | bzip2 -cdfq "$2" | $comp $OPTIONS "$1" - | ||
67 | STAT="$?";; | ||
68 | *) $comp $OPTIONS "$1" "$2" | ||
69 | STAT="$?";; | ||
70 | esac;; | ||
71 | esac | ||
72 | exit "$STAT" | ||
73 | else | ||
74 | echo "Usage: $prog [${comp}_options] file [file]" | ||
75 | exit 1 | ||
76 | fi | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzdiff.1 b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzdiff.1 new file mode 100644 index 0000000..adb7a8e --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzdiff.1 | |||
@@ -0,0 +1,47 @@ | |||
1 | \"Shamelessly copied from zmore.1 by Philippe Troin <phil@fifi.org> | ||
2 | \"for Debian GNU/Linux | ||
3 | .TH BZDIFF 1 | ||
4 | .SH NAME | ||
5 | bzcmp, bzdiff \- compare bzip2 compressed files | ||
6 | .SH SYNOPSIS | ||
7 | .B bzcmp | ||
8 | [ cmp_options ] file1 | ||
9 | [ file2 ] | ||
10 | .br | ||
11 | .B bzdiff | ||
12 | [ diff_options ] file1 | ||
13 | [ file2 ] | ||
14 | .SH DESCRIPTION | ||
15 | .I Bzcmp | ||
16 | and | ||
17 | .I bzdiff | ||
18 | are used to invoke the | ||
19 | .I cmp | ||
20 | or the | ||
21 | .I diff | ||
22 | program on bzip2 compressed files. All options specified are passed | ||
23 | directly to | ||
24 | .I cmp | ||
25 | or | ||
26 | .IR diff "." | ||
27 | If only 1 file is specified, then the files compared are | ||
28 | .I file1 | ||
29 | and an uncompressed | ||
30 | .IR file1 ".bz2." | ||
31 | If two files are specified, then they are uncompressed if necessary and fed to | ||
32 | .I cmp | ||
33 | or | ||
34 | .IR diff "." | ||
35 | The exit status from | ||
36 | .I cmp | ||
37 | or | ||
38 | .I diff | ||
39 | is preserved. | ||
40 | .SH "SEE ALSO" | ||
41 | cmp(1), diff(1), bzmore(1), bzless(1), bzgrep(1), bzip2(1) | ||
42 | .SH BUGS | ||
43 | Messages from the | ||
44 | .I cmp | ||
45 | or | ||
46 | .I diff | ||
47 | programs refer to temporary filenames instead of those specified. | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzgrep b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzgrep new file mode 100644 index 0000000..9a04b83 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzgrep | |||
@@ -0,0 +1,75 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # Bzgrep wrapped for bzip2, | ||
4 | # adapted from zgrep by Philippe Troin <phil@fifi.org> for Debian GNU/Linux. | ||
5 | ## zgrep notice: | ||
6 | ## zgrep -- a wrapper around a grep program that decompresses files as needed | ||
7 | ## Adapted from a version sent by Charles Levert <charles@comm.polymtl.ca> | ||
8 | |||
9 | PATH="/usr/bin:$PATH"; export PATH | ||
10 | |||
11 | prog=`echo $0 | sed 's|.*/||'` | ||
12 | case "$prog" in | ||
13 | *egrep) grep=${EGREP-egrep} ;; | ||
14 | *fgrep) grep=${FGREP-fgrep} ;; | ||
15 | *) grep=${GREP-grep} ;; | ||
16 | esac | ||
17 | pat="" | ||
18 | while test $# -ne 0; do | ||
19 | case "$1" in | ||
20 | -e | -f) opt="$opt $1"; shift; pat="$1" | ||
21 | if test "$grep" = grep; then # grep is buggy with -e on SVR4 | ||
22 | grep=egrep | ||
23 | fi;; | ||
24 | -A | -B) opt="$opt $1 $2"; shift;; | ||
25 | -*) opt="$opt $1";; | ||
26 | *) if test -z "$pat"; then | ||
27 | pat="$1" | ||
28 | else | ||
29 | break; | ||
30 | fi;; | ||
31 | esac | ||
32 | shift | ||
33 | done | ||
34 | |||
35 | if test -z "$pat"; then | ||
36 | echo "grep through bzip2 files" | ||
37 | echo "usage: $prog [grep_options] pattern [files]" | ||
38 | exit 1 | ||
39 | fi | ||
40 | |||
41 | list=0 | ||
42 | silent=0 | ||
43 | op=`echo "$opt" | sed -e 's/ //g' -e 's/-//g'` | ||
44 | case "$op" in | ||
45 | *l*) list=1 | ||
46 | esac | ||
47 | case "$op" in | ||
48 | *h*) silent=1 | ||
49 | esac | ||
50 | |||
51 | if test $# -eq 0; then | ||
52 | bzip2 -cdfq | $grep $opt "$pat" | ||
53 | exit $? | ||
54 | fi | ||
55 | |||
56 | res=0 | ||
57 | for i do | ||
58 | if test -f "$i"; then :; else if test -f "$i.bz2"; then i="$i.bz2"; fi; fi | ||
59 | if test $list -eq 1; then | ||
60 | bzip2 -cdfq "$i" | $grep $opt "$pat" 2>&1 > /dev/null && echo $i | ||
61 | r=$? | ||
62 | elif test $# -eq 1 -o $silent -eq 1; then | ||
63 | bzip2 -cdfq "$i" | $grep $opt "$pat" | ||
64 | r=$? | ||
65 | else | ||
66 | j=${i//\\/\\\\} | ||
67 | j=${j//|/\\|} | ||
68 | j=${j//&/\\&} | ||
69 | j=`printf "%s" "$j" | tr '\n' ' '` | ||
70 | bzip2 -cdfq "$i" | $grep $opt "$pat" | sed "s|^|${j}:|" | ||
71 | r=$? | ||
72 | fi | ||
73 | test "$r" -ne 0 && res="$r" | ||
74 | done | ||
75 | exit $res | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzgrep.1 b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzgrep.1 new file mode 100644 index 0000000..930af8c --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzgrep.1 | |||
@@ -0,0 +1,56 @@ | |||
1 | \"Shamelessly copied from zmore.1 by Philippe Troin <phil@fifi.org> | ||
2 | \"for Debian GNU/Linux | ||
3 | .TH BZGREP 1 | ||
4 | .SH NAME | ||
5 | bzgrep, bzfgrep, bzegrep \- search possibly bzip2 compressed files for a regular expression | ||
6 | .SH SYNOPSIS | ||
7 | .B bzgrep | ||
8 | [ grep_options ] | ||
9 | .BI [\ -e\ ] " pattern" | ||
10 | .IR filename ".\|.\|." | ||
11 | .br | ||
12 | .B bzegrep | ||
13 | [ egrep_options ] | ||
14 | .BI [\ -e\ ] " pattern" | ||
15 | .IR filename ".\|.\|." | ||
16 | .br | ||
17 | .B bzfgrep | ||
18 | [ fgrep_options ] | ||
19 | .BI [\ -e\ ] " pattern" | ||
20 | .IR filename ".\|.\|." | ||
21 | .SH DESCRIPTION | ||
22 | .IR Bzgrep | ||
23 | is used to invoke the | ||
24 | .I grep | ||
25 | on bzip2-compressed files. All options specified are passed directly to | ||
26 | .I grep. | ||
27 | If no file is specified, then the standard input is decompressed | ||
28 | if necessary and fed to grep. | ||
29 | Otherwise the given files are uncompressed if necessary and fed to | ||
30 | .I grep. | ||
31 | .PP | ||
32 | If | ||
33 | .I bzgrep | ||
34 | is invoked as | ||
35 | .I bzegrep | ||
36 | or | ||
37 | .I bzfgrep | ||
38 | then | ||
39 | .I egrep | ||
40 | or | ||
41 | .I fgrep | ||
42 | is used instead of | ||
43 | .I grep. | ||
44 | If the GREP environment variable is set, | ||
45 | .I bzgrep | ||
46 | uses it as the | ||
47 | .I grep | ||
48 | program to be invoked. For example: | ||
49 | |||
50 | for sh: GREP=fgrep bzgrep string files | ||
51 | for csh: (setenv GREP fgrep; bzgrep string files) | ||
52 | .SH AUTHOR | ||
53 | Charles Levert (charles@comm.polymtl.ca). Adapted to bzip2 by Philippe | ||
54 | Troin <phil@fifi.org> for Debian GNU/Linux. | ||
55 | .SH "SEE ALSO" | ||
56 | grep(1), egrep(1), fgrep(1), bzdiff(1), bzmore(1), bzless(1), bzip2(1) | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzip.css b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzip.css new file mode 100644 index 0000000..43193d8 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzip.css | |||
@@ -0,0 +1,74 @@ | |||
1 | /* Colours: | ||
2 | #74240f dark brown h1, h2, h3, h4 | ||
3 | #336699 medium blue links | ||
4 | #339999 turquoise link hover colour | ||
5 | #202020 almost black general text | ||
6 | #761596 purple md5sum text | ||
7 | #626262 dark gray pre border | ||
8 | #eeeeee very light gray pre background | ||
9 | #f2f2f9 very light blue nav table background | ||
10 | #3366cc medium blue nav table border | ||
11 | */ | ||
12 | |||
13 | a, a:link, a:visited, a:active { color: #336699; } | ||
14 | a:hover { color: #339999; } | ||
15 | |||
16 | body { font: 80%/126% sans-serif; } | ||
17 | h1, h2, h3, h4 { color: #74240f; } | ||
18 | |||
19 | dt { color: #336699; font-weight: bold } | ||
20 | dd { | ||
21 | margin-left: 1.5em; | ||
22 | padding-bottom: 0.8em; | ||
23 | } | ||
24 | |||
25 | /* -- ruler -- */ | ||
26 | div.hr_blue { | ||
27 | height: 3px; | ||
28 | background:#ffffff url("/images/hr_blue.png") repeat-x; } | ||
29 | div.hr_blue hr { display:none; } | ||
30 | |||
31 | /* release styles */ | ||
32 | #release p { margin-top: 0.4em; } | ||
33 | #release .md5sum { color: #761596; } | ||
34 | |||
35 | |||
36 | /* ------ styles for docs|manuals|howto ------ */ | ||
37 | /* -- lists -- */ | ||
38 | ul { | ||
39 | margin: 0px 4px 16px 16px; | ||
40 | padding: 0px; | ||
41 | list-style: url("/images/li-blue.png"); | ||
42 | } | ||
43 | ul li { | ||
44 | margin-bottom: 10px; | ||
45 | } | ||
46 | ul ul { | ||
47 | list-style-type: none; | ||
48 | list-style-image: none; | ||
49 | margin-left: 0px; | ||
50 | } | ||
51 | |||
52 | /* header / footer nav tables */ | ||
53 | table.nav { | ||
54 | border: solid 1px #3366cc; | ||
55 | background: #f2f2f9; | ||
56 | background-color: #f2f2f9; | ||
57 | margin-bottom: 0.5em; | ||
58 | } | ||
59 | /* don't have underlined links in chunked nav menus */ | ||
60 | table.nav a { text-decoration: none; } | ||
61 | table.nav a:hover { text-decoration: underline; } | ||
62 | table.nav td { font-size: 85%; } | ||
63 | |||
64 | code, tt, pre { font-size: 120%; } | ||
65 | code, tt { color: #761596; } | ||
66 | |||
67 | div.literallayout, pre.programlisting, pre.screen { | ||
68 | color: #000000; | ||
69 | padding: 0.5em; | ||
70 | background: #eeeeee; | ||
71 | border: 1px solid #626262; | ||
72 | background-color: #eeeeee; | ||
73 | margin: 4px 0px 4px 0px; | ||
74 | } | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzip2.1 b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzip2.1 new file mode 100644 index 0000000..ce3a78e --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzip2.1 | |||
@@ -0,0 +1,454 @@ | |||
1 | .PU | ||
2 | .TH bzip2 1 | ||
3 | .SH NAME | ||
4 | bzip2, bunzip2 \- a block-sorting file compressor, v1.0.6 | ||
5 | .br | ||
6 | bzcat \- decompresses files to stdout | ||
7 | .br | ||
8 | bzip2recover \- recovers data from damaged bzip2 files | ||
9 | |||
10 | .SH SYNOPSIS | ||
11 | .ll +8 | ||
12 | .B bzip2 | ||
13 | .RB [ " \-cdfkqstvzVL123456789 " ] | ||
14 | [ | ||
15 | .I "filenames \&..." | ||
16 | ] | ||
17 | .ll -8 | ||
18 | .br | ||
19 | .B bunzip2 | ||
20 | .RB [ " \-fkvsVL " ] | ||
21 | [ | ||
22 | .I "filenames \&..." | ||
23 | ] | ||
24 | .br | ||
25 | .B bzcat | ||
26 | .RB [ " \-s " ] | ||
27 | [ | ||
28 | .I "filenames \&..." | ||
29 | ] | ||
30 | .br | ||
31 | .B bzip2recover | ||
32 | .I "filename" | ||
33 | |||
34 | .SH DESCRIPTION | ||
35 | .I bzip2 | ||
36 | compresses files using the Burrows-Wheeler block sorting | ||
37 | text compression algorithm, and Huffman coding. Compression is | ||
38 | generally considerably better than that achieved by more conventional | ||
39 | LZ77/LZ78-based compressors, and approaches the performance of the PPM | ||
40 | family of statistical compressors. | ||
41 | |||
42 | The command-line options are deliberately very similar to | ||
43 | those of | ||
44 | .I GNU gzip, | ||
45 | but they are not identical. | ||
46 | |||
47 | .I bzip2 | ||
48 | expects a list of file names to accompany the | ||
49 | command-line flags. Each file is replaced by a compressed version of | ||
50 | itself, with the name "original_name.bz2". | ||
51 | Each compressed file | ||
52 | has the same modification date, permissions, and, when possible, | ||
53 | ownership as the corresponding original, so that these properties can | ||
54 | be correctly restored at decompression time. File name handling is | ||
55 | naive in the sense that there is no mechanism for preserving original | ||
56 | file names, permissions, ownerships or dates in filesystems which lack | ||
57 | these concepts, or have serious file name length restrictions, such as | ||
58 | MS-DOS. | ||
59 | |||
60 | .I bzip2 | ||
61 | and | ||
62 | .I bunzip2 | ||
63 | will by default not overwrite existing | ||
64 | files. If you want this to happen, specify the \-f flag. | ||
65 | |||
66 | If no file names are specified, | ||
67 | .I bzip2 | ||
68 | compresses from standard | ||
69 | input to standard output. In this case, | ||
70 | .I bzip2 | ||
71 | will decline to | ||
72 | write compressed output to a terminal, as this would be entirely | ||
73 | incomprehensible and therefore pointless. | ||
74 | |||
75 | .I bunzip2 | ||
76 | (or | ||
77 | .I bzip2 \-d) | ||
78 | decompresses all | ||
79 | specified files. Files which were not created by | ||
80 | .I bzip2 | ||
81 | will be detected and ignored, and a warning issued. | ||
82 | .I bzip2 | ||
83 | attempts to guess the filename for the decompressed file | ||
84 | from that of the compressed file as follows: | ||
85 | |||
86 | filename.bz2 becomes filename | ||
87 | filename.bz becomes filename | ||
88 | filename.tbz2 becomes filename.tar | ||
89 | filename.tbz becomes filename.tar | ||
90 | anyothername becomes anyothername.out | ||
91 | |||
92 | If the file does not end in one of the recognised endings, | ||
93 | .I .bz2, | ||
94 | .I .bz, | ||
95 | .I .tbz2 | ||
96 | or | ||
97 | .I .tbz, | ||
98 | .I bzip2 | ||
99 | complains that it cannot | ||
100 | guess the name of the original file, and uses the original name | ||
101 | with | ||
102 | .I .out | ||
103 | appended. | ||
104 | |||
105 | As with compression, supplying no | ||
106 | filenames causes decompression from | ||
107 | standard input to standard output. | ||
108 | |||
109 | .I bunzip2 | ||
110 | will correctly decompress a file which is the | ||
111 | concatenation of two or more compressed files. The result is the | ||
112 | concatenation of the corresponding uncompressed files. Integrity | ||
113 | testing (\-t) | ||
114 | of concatenated | ||
115 | compressed files is also supported. | ||
116 | |||
117 | You can also compress or decompress files to the standard output by | ||
118 | giving the \-c flag. Multiple files may be compressed and | ||
119 | decompressed like this. The resulting outputs are fed sequentially to | ||
120 | stdout. Compression of multiple files | ||
121 | in this manner generates a stream | ||
122 | containing multiple compressed file representations. Such a stream | ||
123 | can be decompressed correctly only by | ||
124 | .I bzip2 | ||
125 | version 0.9.0 or | ||
126 | later. Earlier versions of | ||
127 | .I bzip2 | ||
128 | will stop after decompressing | ||
129 | the first file in the stream. | ||
130 | |||
131 | .I bzcat | ||
132 | (or | ||
133 | .I bzip2 -dc) | ||
134 | decompresses all specified files to | ||
135 | the standard output. | ||
136 | |||
137 | .I bzip2 | ||
138 | will read arguments from the environment variables | ||
139 | .I BZIP2 | ||
140 | and | ||
141 | .I BZIP, | ||
142 | in that order, and will process them | ||
143 | before any arguments read from the command line. This gives a | ||
144 | convenient way to supply default arguments. | ||
145 | |||
146 | Compression is always performed, even if the compressed | ||
147 | file is slightly | ||
148 | larger than the original. Files of less than about one hundred bytes | ||
149 | tend to get larger, since the compression mechanism has a constant | ||
150 | overhead in the region of 50 bytes. Random data (including the output | ||
151 | of most file compressors) is coded at about 8.05 bits per byte, giving | ||
152 | an expansion of around 0.5%. | ||
153 | |||
154 | As a self-check for your protection, | ||
155 | .I | ||
156 | bzip2 | ||
157 | uses 32-bit CRCs to | ||
158 | make sure that the decompressed version of a file is identical to the | ||
159 | original. This guards against corruption of the compressed data, and | ||
160 | against undetected bugs in | ||
161 | .I bzip2 | ||
162 | (hopefully very unlikely). The | ||
163 | chances of data corruption going undetected is microscopic, about one | ||
164 | chance in four billion for each file processed. Be aware, though, that | ||
165 | the check occurs upon decompression, so it can only tell you that | ||
166 | something is wrong. It can't help you | ||
167 | recover the original uncompressed | ||
168 | data. You can use | ||
169 | .I bzip2recover | ||
170 | to try to recover data from | ||
171 | damaged files. | ||
172 | |||
173 | Return values: 0 for a normal exit, 1 for environmental problems (file | ||
174 | not found, invalid flags, I/O errors, &c), 2 to indicate a corrupt | ||
175 | compressed file, 3 for an internal consistency error (eg, bug) which | ||
176 | caused | ||
177 | .I bzip2 | ||
178 | to panic. | ||
179 | |||
180 | .SH OPTIONS | ||
181 | .TP | ||
182 | .B \-c --stdout | ||
183 | Compress or decompress to standard output. | ||
184 | .TP | ||
185 | .B \-d --decompress | ||
186 | Force decompression. | ||
187 | .I bzip2, | ||
188 | .I bunzip2 | ||
189 | and | ||
190 | .I bzcat | ||
191 | are | ||
192 | really the same program, and the decision about what actions to take is | ||
193 | done on the basis of which name is used. This flag overrides that | ||
194 | mechanism, and forces | ||
195 | .I bzip2 | ||
196 | to decompress. | ||
197 | .TP | ||
198 | .B \-z --compress | ||
199 | The complement to \-d: forces compression, regardless of the | ||
200 | invocation name. | ||
201 | .TP | ||
202 | .B \-t --test | ||
203 | Check integrity of the specified file(s), but don't decompress them. | ||
204 | This really performs a trial decompression and throws away the result. | ||
205 | .TP | ||
206 | .B \-f --force | ||
207 | Force overwrite of output files. Normally, | ||
208 | .I bzip2 | ||
209 | will not overwrite | ||
210 | existing output files. Also forces | ||
211 | .I bzip2 | ||
212 | to break hard links | ||
213 | to files, which it otherwise wouldn't do. | ||
214 | |||
215 | bzip2 normally declines to decompress files which don't have the | ||
216 | correct magic header bytes. If forced (-f), however, it will pass | ||
217 | such files through unmodified. This is how GNU gzip behaves. | ||
218 | .TP | ||
219 | .B \-k --keep | ||
220 | Keep (don't delete) input files during compression | ||
221 | or decompression. | ||
222 | .TP | ||
223 | .B \-s --small | ||
224 | Reduce memory usage, for compression, decompression and testing. Files | ||
225 | are decompressed and tested using a modified algorithm which only | ||
226 | requires 2.5 bytes per block byte. This means any file can be | ||
227 | decompressed in 2300k of memory, albeit at about half the normal speed. | ||
228 | |||
229 | During compression, \-s selects a block size of 200k, which limits | ||
230 | memory use to around the same figure, at the expense of your compression | ||
231 | ratio. In short, if your machine is low on memory (8 megabytes or | ||
232 | less), use \-s for everything. See MEMORY MANAGEMENT below. | ||
233 | .TP | ||
234 | .B \-q --quiet | ||
235 | Suppress non-essential warning messages. Messages pertaining to | ||
236 | I/O errors and other critical events will not be suppressed. | ||
237 | .TP | ||
238 | .B \-v --verbose | ||
239 | Verbose mode -- show the compression ratio for each file processed. | ||
240 | Further \-v's increase the verbosity level, spewing out lots of | ||
241 | information which is primarily of interest for diagnostic purposes. | ||
242 | .TP | ||
243 | .B \-L --license -V --version | ||
244 | Display the software version, license terms and conditions. | ||
245 | .TP | ||
246 | .B \-1 (or \-\-fast) to \-9 (or \-\-best) | ||
247 | Set the block size to 100 k, 200 k .. 900 k when compressing. Has no | ||
248 | effect when decompressing. See MEMORY MANAGEMENT below. | ||
249 | The \-\-fast and \-\-best aliases are primarily for GNU gzip | ||
250 | compatibility. In particular, \-\-fast doesn't make things | ||
251 | significantly faster. | ||
252 | And \-\-best merely selects the default behaviour. | ||
253 | .TP | ||
254 | .B \-- | ||
255 | Treats all subsequent arguments as file names, even if they start | ||
256 | with a dash. This is so you can handle files with names beginning | ||
257 | with a dash, for example: bzip2 \-- \-myfilename. | ||
258 | .TP | ||
259 | .B \--repetitive-fast --repetitive-best | ||
260 | These flags are redundant in versions 0.9.5 and above. They provided | ||
261 | some coarse control over the behaviour of the sorting algorithm in | ||
262 | earlier versions, which was sometimes useful. 0.9.5 and above have an | ||
263 | improved algorithm which renders these flags irrelevant. | ||
264 | |||
265 | .SH MEMORY MANAGEMENT | ||
266 | .I bzip2 | ||
267 | compresses large files in blocks. The block size affects | ||
268 | both the compression ratio achieved, and the amount of memory needed for | ||
269 | compression and decompression. The flags \-1 through \-9 | ||
270 | specify the block size to be 100,000 bytes through 900,000 bytes (the | ||
271 | default) respectively. At decompression time, the block size used for | ||
272 | compression is read from the header of the compressed file, and | ||
273 | .I bunzip2 | ||
274 | then allocates itself just enough memory to decompress | ||
275 | the file. Since block sizes are stored in compressed files, it follows | ||
276 | that the flags \-1 to \-9 are irrelevant to and so ignored | ||
277 | during decompression. | ||
278 | |||
279 | Compression and decompression requirements, | ||
280 | in bytes, can be estimated as: | ||
281 | |||
282 | Compression: 400k + ( 8 x block size ) | ||
283 | |||
284 | Decompression: 100k + ( 4 x block size ), or | ||
285 | 100k + ( 2.5 x block size ) | ||
286 | |||
287 | Larger block sizes give rapidly diminishing marginal returns. Most of | ||
288 | the compression comes from the first two or three hundred k of block | ||
289 | size, a fact worth bearing in mind when using | ||
290 | .I bzip2 | ||
291 | on small machines. | ||
292 | It is also important to appreciate that the decompression memory | ||
293 | requirement is set at compression time by the choice of block size. | ||
294 | |||
295 | For files compressed with the default 900k block size, | ||
296 | .I bunzip2 | ||
297 | will require about 3700 kbytes to decompress. To support decompression | ||
298 | of any file on a 4 megabyte machine, | ||
299 | .I bunzip2 | ||
300 | has an option to | ||
301 | decompress using approximately half this amount of memory, about 2300 | ||
302 | kbytes. Decompression speed is also halved, so you should use this | ||
303 | option only where necessary. The relevant flag is -s. | ||
304 | |||
305 | In general, try and use the largest block size memory constraints allow, | ||
306 | since that maximises the compression achieved. Compression and | ||
307 | decompression speed are virtually unaffected by block size. | ||
308 | |||
309 | Another significant point applies to files which fit in a single block | ||
310 | -- that means most files you'd encounter using a large block size. The | ||
311 | amount of real memory touched is proportional to the size of the file, | ||
312 | since the file is smaller than a block. For example, compressing a file | ||
313 | 20,000 bytes long with the flag -9 will cause the compressor to | ||
314 | allocate around 7600k of memory, but only touch 400k + 20000 * 8 = 560 | ||
315 | kbytes of it. Similarly, the decompressor will allocate 3700k but only | ||
316 | touch 100k + 20000 * 4 = 180 kbytes. | ||
317 | |||
318 | Here is a table which summarises the maximum memory usage for different | ||
319 | block sizes. Also recorded is the total compressed size for 14 files of | ||
320 | the Calgary Text Compression Corpus totalling 3,141,622 bytes. This | ||
321 | column gives some feel for how compression varies with block size. | ||
322 | These figures tend to understate the advantage of larger block sizes for | ||
323 | larger files, since the Corpus is dominated by smaller files. | ||
324 | |||
325 | Compress Decompress Decompress Corpus | ||
326 | Flag usage usage -s usage Size | ||
327 | |||
328 | -1 1200k 500k 350k 914704 | ||
329 | -2 2000k 900k 600k 877703 | ||
330 | -3 2800k 1300k 850k 860338 | ||
331 | -4 3600k 1700k 1100k 846899 | ||
332 | -5 4400k 2100k 1350k 845160 | ||
333 | -6 5200k 2500k 1600k 838626 | ||
334 | -7 6100k 2900k 1850k 834096 | ||
335 | -8 6800k 3300k 2100k 828642 | ||
336 | -9 7600k 3700k 2350k 828642 | ||
337 | |||
338 | .SH RECOVERING DATA FROM DAMAGED FILES | ||
339 | .I bzip2 | ||
340 | compresses files in blocks, usually 900kbytes long. Each | ||
341 | block is handled independently. If a media or transmission error causes | ||
342 | a multi-block .bz2 | ||
343 | file to become damaged, it may be possible to | ||
344 | recover data from the undamaged blocks in the file. | ||
345 | |||
346 | The compressed representation of each block is delimited by a 48-bit | ||
347 | pattern, which makes it possible to find the block boundaries with | ||
348 | reasonable certainty. Each block also carries its own 32-bit CRC, so | ||
349 | damaged blocks can be distinguished from undamaged ones. | ||
350 | |||
351 | .I bzip2recover | ||
352 | is a simple program whose purpose is to search for | ||
353 | blocks in .bz2 files, and write each block out into its own .bz2 | ||
354 | file. You can then use | ||
355 | .I bzip2 | ||
356 | \-t | ||
357 | to test the | ||
358 | integrity of the resulting files, and decompress those which are | ||
359 | undamaged. | ||
360 | |||
361 | .I bzip2recover | ||
362 | takes a single argument, the name of the damaged file, | ||
363 | and writes a number of files "rec00001file.bz2", | ||
364 | "rec00002file.bz2", etc, containing the extracted blocks. | ||
365 | The output filenames are designed so that the use of | ||
366 | wildcards in subsequent processing -- for example, | ||
367 | "bzip2 -dc rec*file.bz2 > recovered_data" -- processes the files in | ||
368 | the correct order. | ||
369 | |||
370 | .I bzip2recover | ||
371 | should be of most use dealing with large .bz2 | ||
372 | files, as these will contain many blocks. It is clearly | ||
373 | futile to use it on damaged single-block files, since a | ||
374 | damaged block cannot be recovered. If you wish to minimise | ||
375 | any potential data loss through media or transmission errors, | ||
376 | you might consider compressing with a smaller | ||
377 | block size. | ||
378 | |||
379 | .SH PERFORMANCE NOTES | ||
380 | The sorting phase of compression gathers together similar strings in the | ||
381 | file. Because of this, files containing very long runs of repeated | ||
382 | symbols, like "aabaabaabaab ..." (repeated several hundred times) may | ||
383 | compress more slowly than normal. Versions 0.9.5 and above fare much | ||
384 | better than previous versions in this respect. The ratio between | ||
385 | worst-case and average-case compression time is in the region of 10:1. | ||
386 | For previous versions, this figure was more like 100:1. You can use the | ||
387 | \-vvvv option to monitor progress in great detail, if you want. | ||
388 | |||
389 | Decompression speed is unaffected by these phenomena. | ||
390 | |||
391 | .I bzip2 | ||
392 | usually allocates several megabytes of memory to operate | ||
393 | in, and then charges all over it in a fairly random fashion. This means | ||
394 | that performance, both for compressing and decompressing, is largely | ||
395 | determined by the speed at which your machine can service cache misses. | ||
396 | Because of this, small changes to the code to reduce the miss rate have | ||
397 | been observed to give disproportionately large performance improvements. | ||
398 | I imagine | ||
399 | .I bzip2 | ||
400 | will perform best on machines with very large caches. | ||
401 | |||
402 | .SH CAVEATS | ||
403 | I/O error messages are not as helpful as they could be. | ||
404 | .I bzip2 | ||
405 | tries hard to detect I/O errors and exit cleanly, but the details of | ||
406 | what the problem is sometimes seem rather misleading. | ||
407 | |||
408 | This manual page pertains to version 1.0.6 of | ||
409 | .I bzip2. | ||
410 | Compressed data created by this version is entirely forwards and | ||
411 | backwards compatible with the previous public releases, versions | ||
412 | 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1, 1.0.2 and above, but with the following | ||
413 | exception: 0.9.0 and above can correctly decompress multiple | ||
414 | concatenated compressed files. 0.1pl2 cannot do this; it will stop | ||
415 | after decompressing just the first file in the stream. | ||
416 | |||
417 | .I bzip2recover | ||
418 | versions prior to 1.0.2 used 32-bit integers to represent | ||
419 | bit positions in compressed files, so they could not handle compressed | ||
420 | files more than 512 megabytes long. Versions 1.0.2 and above use | ||
421 | 64-bit ints on some platforms which support them (GNU supported | ||
422 | targets, and Windows). To establish whether or not bzip2recover was | ||
423 | built with such a limitation, run it without arguments. In any event | ||
424 | you can build yourself an unlimited version if you can recompile it | ||
425 | with MaybeUInt64 set to be an unsigned 64-bit integer. | ||
426 | |||
427 | |||
428 | |||
429 | .SH AUTHOR | ||
430 | Julian Seward, jsewardbzip.org. | ||
431 | |||
432 | http://www.bzip.org | ||
433 | |||
434 | The ideas embodied in | ||
435 | .I bzip2 | ||
436 | are due to (at least) the following | ||
437 | people: Michael Burrows and David Wheeler (for the block sorting | ||
438 | transformation), David Wheeler (again, for the Huffman coder), Peter | ||
439 | Fenwick (for the structured coding model in the original | ||
440 | .I bzip, | ||
441 | and many refinements), and Alistair Moffat, Radford Neal and Ian Witten | ||
442 | (for the arithmetic coder in the original | ||
443 | .I bzip). | ||
444 | I am much | ||
445 | indebted for their help, support and advice. See the manual in the | ||
446 | source distribution for pointers to sources of documentation. Christian | ||
447 | von Roques encouraged me to look for faster sorting algorithms, so as to | ||
448 | speed up compression. Bela Lubkin encouraged me to improve the | ||
449 | worst-case compression performance. | ||
450 | Donna Robinson XMLised the documentation. | ||
451 | The bz* scripts are derived from those of GNU gzip. | ||
452 | Many people sent patches, helped | ||
453 | with portability problems, lent machines, gave advice and were generally | ||
454 | helpful. | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzip2.1.preformatted b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzip2.1.preformatted new file mode 100644 index 0000000..63c33be --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzip2.1.preformatted | |||
@@ -0,0 +1,399 @@ | |||
1 | bzip2(1) bzip2(1) | ||
2 | |||
3 | |||
4 | |||
5 | NNAAMMEE | ||
6 | bzip2, bunzip2 − a blockâ€sorting file compressor, v1.0.6 | ||
7 | bzcat − decompresses files to stdout | ||
8 | bzip2recover − recovers data from damaged bzip2 files | ||
9 | |||
10 | |||
11 | SSYYNNOOPPSSIISS | ||
12 | bbzziipp22 [ −−ccddffkkqqssttvvzzVVLL112233445566778899 ] [ _f_i_l_e_n_a_m_e_s _._._. ] | ||
13 | bbuunnzziipp22 [ −−ffkkvvssVVLL ] [ _f_i_l_e_n_a_m_e_s _._._. ] | ||
14 | bbzzccaatt [ −−ss ] [ _f_i_l_e_n_a_m_e_s _._._. ] | ||
15 | bbzziipp22rreeccoovveerr _f_i_l_e_n_a_m_e | ||
16 | |||
17 | |||
18 | DDEESSCCRRIIPPTTIIOONN | ||
19 | _b_z_i_p_2 compresses files using the Burrowsâ€Wheeler block | ||
20 | sorting text compression algorithm, and Huffman coding. | ||
21 | Compression is generally considerably better than that | ||
22 | achieved by more conventional LZ77/LZ78â€based compressors, | ||
23 | and approaches the performance of the PPM family of sta | ||
24 | tistical compressors. | ||
25 | |||
26 | The commandâ€line options are deliberately very similar to | ||
27 | those of _G_N_U _g_z_i_p_, but they are not identical. | ||
28 | |||
29 | _b_z_i_p_2 expects a list of file names to accompany the com | ||
30 | mandâ€line flags. Each file is replaced by a compressed | ||
31 | version of itself, with the name "original_name.bz2". | ||
32 | Each compressed file has the same modification date, per | ||
33 | missions, and, when possible, ownership as the correspond | ||
34 | ing original, so that these properties can be correctly | ||
35 | restored at decompression time. File name handling is | ||
36 | naive in the sense that there is no mechanism for preserv | ||
37 | ing original file names, permissions, ownerships or dates | ||
38 | in filesystems which lack these concepts, or have serious | ||
39 | file name length restrictions, such as MSâ€DOS. | ||
40 | |||
41 | _b_z_i_p_2 and _b_u_n_z_i_p_2 will by default not overwrite existing | ||
42 | files. If you want this to happen, specify the −f flag. | ||
43 | |||
44 | If no file names are specified, _b_z_i_p_2 compresses from | ||
45 | standard input to standard output. In this case, _b_z_i_p_2 | ||
46 | will decline to write compressed output to a terminal, as | ||
47 | this would be entirely incomprehensible and therefore | ||
48 | pointless. | ||
49 | |||
50 | _b_u_n_z_i_p_2 (or _b_z_i_p_2 _−_d_) decompresses all specified files. | ||
51 | Files which were not created by _b_z_i_p_2 will be detected and | ||
52 | ignored, and a warning issued. _b_z_i_p_2 attempts to guess | ||
53 | the filename for the decompressed file from that of the | ||
54 | compressed file as follows: | ||
55 | |||
56 | filename.bz2 becomes filename | ||
57 | filename.bz becomes filename | ||
58 | filename.tbz2 becomes filename.tar | ||
59 | filename.tbz becomes filename.tar | ||
60 | anyothername becomes anyothername.out | ||
61 | |||
62 | If the file does not end in one of the recognised endings, | ||
63 | _._b_z_2_, _._b_z_, _._t_b_z_2 or _._t_b_z_, _b_z_i_p_2 complains that it cannot | ||
64 | guess the name of the original file, and uses the original | ||
65 | name with _._o_u_t appended. | ||
66 | |||
67 | As with compression, supplying no filenames causes decom | ||
68 | pression from standard input to standard output. | ||
69 | |||
70 | _b_u_n_z_i_p_2 will correctly decompress a file which is the con | ||
71 | catenation of two or more compressed files. The result is | ||
72 | the concatenation of the corresponding uncompressed files. | ||
73 | Integrity testing (−t) of concatenated compressed files is | ||
74 | also supported. | ||
75 | |||
76 | You can also compress or decompress files to the standard | ||
77 | output by giving the −c flag. Multiple files may be com | ||
78 | pressed and decompressed like this. The resulting outputs | ||
79 | are fed sequentially to stdout. Compression of multiple | ||
80 | files in this manner generates a stream containing multi | ||
81 | ple compressed file representations. Such a stream can be | ||
82 | decompressed correctly only by _b_z_i_p_2 version 0.9.0 or | ||
83 | later. Earlier versions of _b_z_i_p_2 will stop after decom | ||
84 | pressing the first file in the stream. | ||
85 | |||
86 | _b_z_c_a_t (or _b_z_i_p_2 _â€_d_c_) decompresses all specified files to | ||
87 | the standard output. | ||
88 | |||
89 | _b_z_i_p_2 will read arguments from the environment variables | ||
90 | _B_Z_I_P_2 and _B_Z_I_P_, in that order, and will process them | ||
91 | before any arguments read from the command line. This | ||
92 | gives a convenient way to supply default arguments. | ||
93 | |||
94 | Compression is always performed, even if the compressed | ||
95 | file is slightly larger than the original. Files of less | ||
96 | than about one hundred bytes tend to get larger, since the | ||
97 | compression mechanism has a constant overhead in the | ||
98 | region of 50 bytes. Random data (including the output of | ||
99 | most file compressors) is coded at about 8.05 bits per | ||
100 | byte, giving an expansion of around 0.5%. | ||
101 | |||
102 | As a selfâ€check for your protection, _b_z_i_p_2 uses 32â€bit | ||
103 | CRCs to make sure that the decompressed version of a file | ||
104 | is identical to the original. This guards against corrup | ||
105 | tion of the compressed data, and against undetected bugs | ||
106 | in _b_z_i_p_2 (hopefully very unlikely). The chances of data | ||
107 | corruption going undetected is microscopic, about one | ||
108 | chance in four billion for each file processed. Be aware, | ||
109 | though, that the check occurs upon decompression, so it | ||
110 | can only tell you that something is wrong. It can’t help | ||
111 | you recover the original uncompressed data. You can use | ||
112 | _b_z_i_p_2_r_e_c_o_v_e_r to try to recover data from damaged files. | ||
113 | |||
114 | Return values: 0 for a normal exit, 1 for environmental | ||
115 | problems (file not found, invalid flags, I/O errors, &c), | ||
116 | 2 to indicate a corrupt compressed file, 3 for an internal | ||
117 | consistency error (eg, bug) which caused _b_z_i_p_2 to panic. | ||
118 | |||
119 | |||
120 | OOPPTTIIOONNSS | ||
121 | −−cc â€â€â€â€ssttddoouutt | ||
122 | Compress or decompress to standard output. | ||
123 | |||
124 | −−dd â€â€â€â€ddeeccoommpprreessss | ||
125 | Force decompression. _b_z_i_p_2_, _b_u_n_z_i_p_2 and _b_z_c_a_t are | ||
126 | really the same program, and the decision about | ||
127 | what actions to take is done on the basis of which | ||
128 | name is used. This flag overrides that mechanism, | ||
129 | and forces _b_z_i_p_2 to decompress. | ||
130 | |||
131 | −−zz â€â€â€â€ccoommpprreessss | ||
132 | The complement to −d: forces compression, | ||
133 | regardless of the invocation name. | ||
134 | |||
135 | −−tt â€â€â€â€tteesstt | ||
136 | Check integrity of the specified file(s), but don’t | ||
137 | decompress them. This really performs a trial | ||
138 | decompression and throws away the result. | ||
139 | |||
140 | −−ff â€â€â€â€ffoorrccee | ||
141 | Force overwrite of output files. Normally, _b_z_i_p_2 | ||
142 | will not overwrite existing output files. Also | ||
143 | forces _b_z_i_p_2 to break hard links to files, which it | ||
144 | otherwise wouldn’t do. | ||
145 | |||
146 | bzip2 normally declines to decompress files which | ||
147 | don’t have the correct magic header bytes. If | ||
148 | forced (â€f), however, it will pass such files | ||
149 | through unmodified. This is how GNU gzip behaves. | ||
150 | |||
151 | −−kk â€â€â€â€kkeeeepp | ||
152 | Keep (don’t delete) input files during compression | ||
153 | or decompression. | ||
154 | |||
155 | −−ss â€â€â€â€ssmmaallll | ||
156 | Reduce memory usage, for compression, decompression | ||
157 | and testing. Files are decompressed and tested | ||
158 | using a modified algorithm which only requires 2.5 | ||
159 | bytes per block byte. This means any file can be | ||
160 | decompressed in 2300k of memory, albeit at about | ||
161 | half the normal speed. | ||
162 | |||
163 | During compression, −s selects a block size of | ||
164 | 200k, which limits memory use to around the same | ||
165 | figure, at the expense of your compression ratio. | ||
166 | In short, if your machine is low on memory (8 | ||
167 | megabytes or less), use −s for everything. See | ||
168 | MEMORY MANAGEMENT below. | ||
169 | |||
170 | −−qq â€â€â€â€qquuiieett | ||
171 | Suppress nonâ€essential warning messages. Messages | ||
172 | pertaining to I/O errors and other critical events | ||
173 | will not be suppressed. | ||
174 | |||
175 | −−vv â€â€â€â€vveerrbboossee | ||
176 | Verbose mode â€â€ show the compression ratio for each | ||
177 | file processed. Further −v’s increase the ver | ||
178 | bosity level, spewing out lots of information which | ||
179 | is primarily of interest for diagnostic purposes. | ||
180 | |||
181 | −−LL â€â€â€â€lliicceennssee â€â€VV â€â€â€â€vveerrssiioonn | ||
182 | Display the software version, license terms and | ||
183 | conditions. | ||
184 | |||
185 | −−11 ((oorr −−−−ffaasstt)) ttoo −−99 ((oorr −−−−bbeesstt)) | ||
186 | Set the block size to 100 k, 200 k .. 900 k when | ||
187 | compressing. Has no effect when decompressing. | ||
188 | See MEMORY MANAGEMENT below. The −−fast and −−best | ||
189 | aliases are primarily for GNU gzip compatibility. | ||
190 | In particular, −−fast doesn’t make things signifi | ||
191 | cantly faster. And −−best merely selects the | ||
192 | default behaviour. | ||
193 | |||
194 | −−â€â€ Treats all subsequent arguments as file names, even | ||
195 | if they start with a dash. This is so you can han | ||
196 | dle files with names beginning with a dash, for | ||
197 | example: bzip2 −†−myfilename. | ||
198 | |||
199 | −−â€â€rreeppeettiittiivveeâ€â€ffaasstt â€â€â€â€rreeppeettiittiivveeâ€â€bbeesstt | ||
200 | These flags are redundant in versions 0.9.5 and | ||
201 | above. They provided some coarse control over the | ||
202 | behaviour of the sorting algorithm in earlier ver | ||
203 | sions, which was sometimes useful. 0.9.5 and above | ||
204 | have an improved algorithm which renders these | ||
205 | flags irrelevant. | ||
206 | |||
207 | |||
208 | MMEEMMOORRYY MMAANNAAGGEEMMEENNTT | ||
209 | _b_z_i_p_2 compresses large files in blocks. The block size | ||
210 | affects both the compression ratio achieved, and the | ||
211 | amount of memory needed for compression and decompression. | ||
212 | The flags −1 through −9 specify the block size to be | ||
213 | 100,000 bytes through 900,000 bytes (the default) respec | ||
214 | tively. At decompression time, the block size used for | ||
215 | compression is read from the header of the compressed | ||
216 | file, and _b_u_n_z_i_p_2 then allocates itself just enough memory | ||
217 | to decompress the file. Since block sizes are stored in | ||
218 | compressed files, it follows that the flags −1 to −9 are | ||
219 | irrelevant to and so ignored during decompression. | ||
220 | |||
221 | Compression and decompression requirements, in bytes, can | ||
222 | be estimated as: | ||
223 | |||
224 | Compression: 400k + ( 8 x block size ) | ||
225 | |||
226 | Decompression: 100k + ( 4 x block size ), or | ||
227 | 100k + ( 2.5 x block size ) | ||
228 | |||
229 | Larger block sizes give rapidly diminishing marginal | ||
230 | returns. Most of the compression comes from the first two | ||
231 | or three hundred k of block size, a fact worth bearing in | ||
232 | mind when using _b_z_i_p_2 on small machines. It is also | ||
233 | important to appreciate that the decompression memory | ||
234 | requirement is set at compression time by the choice of | ||
235 | block size. | ||
236 | |||
237 | For files compressed with the default 900k block size, | ||
238 | _b_u_n_z_i_p_2 will require about 3700 kbytes to decompress. To | ||
239 | support decompression of any file on a 4 megabyte machine, | ||
240 | _b_u_n_z_i_p_2 has an option to decompress using approximately | ||
241 | half this amount of memory, about 2300 kbytes. Decompres | ||
242 | sion speed is also halved, so you should use this option | ||
243 | only where necessary. The relevant flag is â€s. | ||
244 | |||
245 | In general, try and use the largest block size memory con | ||
246 | straints allow, since that maximises the compression | ||
247 | achieved. Compression and decompression speed are virtu | ||
248 | ally unaffected by block size. | ||
249 | |||
250 | Another significant point applies to files which fit in a | ||
251 | single block â€â€ that means most files you’d encounter | ||
252 | using a large block size. The amount of real memory | ||
253 | touched is proportional to the size of the file, since the | ||
254 | file is smaller than a block. For example, compressing a | ||
255 | file 20,000 bytes long with the flag â€9 will cause the | ||
256 | compressor to allocate around 7600k of memory, but only | ||
257 | touch 400k + 20000 * 8 = 560 kbytes of it. Similarly, the | ||
258 | decompressor will allocate 3700k but only touch 100k + | ||
259 | 20000 * 4 = 180 kbytes. | ||
260 | |||
261 | Here is a table which summarises the maximum memory usage | ||
262 | for different block sizes. Also recorded is the total | ||
263 | compressed size for 14 files of the Calgary Text Compres | ||
264 | sion Corpus totalling 3,141,622 bytes. This column gives | ||
265 | some feel for how compression varies with block size. | ||
266 | These figures tend to understate the advantage of larger | ||
267 | block sizes for larger files, since the Corpus is domi | ||
268 | nated by smaller files. | ||
269 | |||
270 | Compress Decompress Decompress Corpus | ||
271 | Flag usage usage â€s usage Size | ||
272 | |||
273 | â€1 1200k 500k 350k 914704 | ||
274 | â€2 2000k 900k 600k 877703 | ||
275 | â€3 2800k 1300k 850k 860338 | ||
276 | â€4 3600k 1700k 1100k 846899 | ||
277 | â€5 4400k 2100k 1350k 845160 | ||
278 | â€6 5200k 2500k 1600k 838626 | ||
279 | â€7 6100k 2900k 1850k 834096 | ||
280 | â€8 6800k 3300k 2100k 828642 | ||
281 | â€9 7600k 3700k 2350k 828642 | ||
282 | |||
283 | |||
284 | RREECCOOVVEERRIINNGG DDAATTAA FFRROOMM DDAAMMAAGGEEDD FFIILLEESS | ||
285 | _b_z_i_p_2 compresses files in blocks, usually 900kbytes long. | ||
286 | Each block is handled independently. If a media or trans | ||
287 | mission error causes a multiâ€block .bz2 file to become | ||
288 | damaged, it may be possible to recover data from the | ||
289 | undamaged blocks in the file. | ||
290 | |||
291 | The compressed representation of each block is delimited | ||
292 | by a 48â€bit pattern, which makes it possible to find the | ||
293 | block boundaries with reasonable certainty. Each block | ||
294 | also carries its own 32â€bit CRC, so damaged blocks can be | ||
295 | distinguished from undamaged ones. | ||
296 | |||
297 | _b_z_i_p_2_r_e_c_o_v_e_r is a simple program whose purpose is to | ||
298 | search for blocks in .bz2 files, and write each block out | ||
299 | into its own .bz2 file. You can then use _b_z_i_p_2 −t to test | ||
300 | the integrity of the resulting files, and decompress those | ||
301 | which are undamaged. | ||
302 | |||
303 | _b_z_i_p_2_r_e_c_o_v_e_r takes a single argument, the name of the dam | ||
304 | aged file, and writes a number of files | ||
305 | "rec00001file.bz2", "rec00002file.bz2", etc, containing | ||
306 | the extracted blocks. The output filenames are | ||
307 | designed so that the use of wildcards in subsequent pro | ||
308 | cessing â€â€ for example, "bzip2 â€dc rec*file.bz2 > recov | ||
309 | ered_data" â€â€ processes the files in the correct order. | ||
310 | |||
311 | _b_z_i_p_2_r_e_c_o_v_e_r should be of most use dealing with large .bz2 | ||
312 | files, as these will contain many blocks. It is clearly | ||
313 | futile to use it on damaged singleâ€block files, since a | ||
314 | damaged block cannot be recovered. If you wish to min | ||
315 | imise any potential data loss through media or transmis | ||
316 | sion errors, you might consider compressing with a smaller | ||
317 | block size. | ||
318 | |||
319 | |||
320 | PPEERRFFOORRMMAANNCCEE NNOOTTEESS | ||
321 | The sorting phase of compression gathers together similar | ||
322 | strings in the file. Because of this, files containing | ||
323 | very long runs of repeated symbols, like "aabaabaabaab | ||
324 | ..." (repeated several hundred times) may compress more | ||
325 | slowly than normal. Versions 0.9.5 and above fare much | ||
326 | better than previous versions in this respect. The ratio | ||
327 | between worstâ€case and averageâ€case compression time is in | ||
328 | the region of 10:1. For previous versions, this figure | ||
329 | was more like 100:1. You can use the −vvvv option to mon | ||
330 | itor progress in great detail, if you want. | ||
331 | |||
332 | Decompression speed is unaffected by these phenomena. | ||
333 | |||
334 | _b_z_i_p_2 usually allocates several megabytes of memory to | ||
335 | operate in, and then charges all over it in a fairly ran | ||
336 | dom fashion. This means that performance, both for com | ||
337 | pressing and decompressing, is largely determined by the | ||
338 | speed at which your machine can service cache misses. | ||
339 | Because of this, small changes to the code to reduce the | ||
340 | miss rate have been observed to give disproportionately | ||
341 | large performance improvements. I imagine _b_z_i_p_2 will per | ||
342 | form best on machines with very large caches. | ||
343 | |||
344 | |||
345 | CCAAVVEEAATTSS | ||
346 | I/O error messages are not as helpful as they could be. | ||
347 | _b_z_i_p_2 tries hard to detect I/O errors and exit cleanly, | ||
348 | but the details of what the problem is sometimes seem | ||
349 | rather misleading. | ||
350 | |||
351 | This manual page pertains to version 1.0.6 of _b_z_i_p_2_. Com | ||
352 | pressed data created by this version is entirely forwards | ||
353 | and backwards compatible with the previous public | ||
354 | releases, versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1, | ||
355 | 1.0.2 and above, but with the following exception: 0.9.0 | ||
356 | and above can correctly decompress multiple concatenated | ||
357 | compressed files. 0.1pl2 cannot do this; it will stop | ||
358 | after decompressing just the first file in the stream. | ||
359 | |||
360 | _b_z_i_p_2_r_e_c_o_v_e_r versions prior to 1.0.2 used 32â€bit integers | ||
361 | to represent bit positions in compressed files, so they | ||
362 | could not handle compressed files more than 512 megabytes | ||
363 | long. Versions 1.0.2 and above use 64â€bit ints on some | ||
364 | platforms which support them (GNU supported targets, and | ||
365 | Windows). To establish whether or not bzip2recover was | ||
366 | built with such a limitation, run it without arguments. | ||
367 | In any event you can build yourself an unlimited version | ||
368 | if you can recompile it with MaybeUInt64 set to be an | ||
369 | unsigned 64â€bit integer. | ||
370 | |||
371 | |||
372 | |||
373 | |||
374 | AAUUTTHHOORR | ||
375 | Julian Seward, jsewardbzip.org. | ||
376 | |||
377 | http://www.bzip.org | ||
378 | |||
379 | The ideas embodied in _b_z_i_p_2 are due to (at least) the fol | ||
380 | lowing people: Michael Burrows and David Wheeler (for the | ||
381 | block sorting transformation), David Wheeler (again, for | ||
382 | the Huffman coder), Peter Fenwick (for the structured cod | ||
383 | ing model in the original _b_z_i_p_, and many refinements), and | ||
384 | Alistair Moffat, Radford Neal and Ian Witten (for the | ||
385 | arithmetic coder in the original _b_z_i_p_)_. I am much | ||
386 | indebted for their help, support and advice. See the man | ||
387 | ual in the source distribution for pointers to sources of | ||
388 | documentation. Christian von Roques encouraged me to look | ||
389 | for faster sorting algorithms, so as to speed up compres | ||
390 | sion. Bela Lubkin encouraged me to improve the worstâ€case | ||
391 | compression performance. Donna Robinson XMLised the docu | ||
392 | mentation. The bz* scripts are derived from those of GNU | ||
393 | gzip. Many people sent patches, helped with portability | ||
394 | problems, lent machines, gave advice and were generally | ||
395 | helpful. | ||
396 | |||
397 | |||
398 | |||
399 | bzip2(1) | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzip2.c b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzip2.c new file mode 100644 index 0000000..6de9d1d --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzip2.c | |||
@@ -0,0 +1,2034 @@ | |||
1 | |||
2 | /*-----------------------------------------------------------*/ | ||
3 | /*--- A block-sorting, lossless compressor bzip2.c ---*/ | ||
4 | /*-----------------------------------------------------------*/ | ||
5 | |||
6 | /* ------------------------------------------------------------------ | ||
7 | This file is part of bzip2/libbzip2, a program and library for | ||
8 | lossless, block-sorting data compression. | ||
9 | |||
10 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | ||
11 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | ||
12 | |||
13 | Please read the WARNING, DISCLAIMER and PATENTS sections in the | ||
14 | README file. | ||
15 | |||
16 | This program is released under the terms of the license contained | ||
17 | in the file LICENSE. | ||
18 | ------------------------------------------------------------------ */ | ||
19 | |||
20 | |||
21 | /* Place a 1 beside your platform, and 0 elsewhere. | ||
22 | Generic 32-bit Unix. | ||
23 | Also works on 64-bit Unix boxes. | ||
24 | This is the default. | ||
25 | */ | ||
26 | #define BZ_UNIX 1 | ||
27 | |||
28 | /*-- | ||
29 | Win32, as seen by Jacob Navia's excellent | ||
30 | port of (Chris Fraser & David Hanson)'s excellent | ||
31 | lcc compiler. Or with MS Visual C. | ||
32 | This is selected automatically if compiled by a compiler which | ||
33 | defines _WIN32, not including the Cygwin GCC. | ||
34 | --*/ | ||
35 | #define BZ_LCCWIN32 0 | ||
36 | |||
37 | #if defined(_WIN32) && !defined(__CYGWIN__) | ||
38 | #undef BZ_LCCWIN32 | ||
39 | #define BZ_LCCWIN32 1 | ||
40 | #undef BZ_UNIX | ||
41 | #define BZ_UNIX 0 | ||
42 | #endif | ||
43 | |||
44 | |||
45 | /*---------------------------------------------*/ | ||
46 | /*-- | ||
47 | Some stuff for all platforms. | ||
48 | --*/ | ||
49 | |||
50 | #include <stdio.h> | ||
51 | #include <stdlib.h> | ||
52 | #include <string.h> | ||
53 | #include <signal.h> | ||
54 | #include <math.h> | ||
55 | #include <errno.h> | ||
56 | #include <ctype.h> | ||
57 | #include "bzlib.h" | ||
58 | |||
59 | #define ERROR_IF_EOF(i) { if ((i) == EOF) ioError(); } | ||
60 | #define ERROR_IF_NOT_ZERO(i) { if ((i) != 0) ioError(); } | ||
61 | #define ERROR_IF_MINUS_ONE(i) { if ((i) == (-1)) ioError(); } | ||
62 | |||
63 | |||
64 | /*---------------------------------------------*/ | ||
65 | /*-- | ||
66 | Platform-specific stuff. | ||
67 | --*/ | ||
68 | |||
69 | #if BZ_UNIX | ||
70 | # include <fcntl.h> | ||
71 | # include <sys/types.h> | ||
72 | # include <utime.h> | ||
73 | # include <unistd.h> | ||
74 | # include <sys/stat.h> | ||
75 | # include <sys/times.h> | ||
76 | |||
77 | # define PATH_SEP '/' | ||
78 | # define MY_LSTAT lstat | ||
79 | # define MY_STAT stat | ||
80 | # define MY_S_ISREG S_ISREG | ||
81 | # define MY_S_ISDIR S_ISDIR | ||
82 | |||
83 | # define APPEND_FILESPEC(root, name) \ | ||
84 | root=snocString((root), (name)) | ||
85 | |||
86 | # define APPEND_FLAG(root, name) \ | ||
87 | root=snocString((root), (name)) | ||
88 | |||
89 | # define SET_BINARY_MODE(fd) /**/ | ||
90 | |||
91 | # ifdef __GNUC__ | ||
92 | # define NORETURN __attribute__ ((noreturn)) | ||
93 | # else | ||
94 | # define NORETURN /**/ | ||
95 | # endif | ||
96 | |||
97 | # ifdef __DJGPP__ | ||
98 | # include <io.h> | ||
99 | # include <fcntl.h> | ||
100 | # undef MY_LSTAT | ||
101 | # undef MY_STAT | ||
102 | # define MY_LSTAT stat | ||
103 | # define MY_STAT stat | ||
104 | # undef SET_BINARY_MODE | ||
105 | # define SET_BINARY_MODE(fd) \ | ||
106 | do { \ | ||
107 | int retVal = setmode ( fileno ( fd ), \ | ||
108 | O_BINARY ); \ | ||
109 | ERROR_IF_MINUS_ONE ( retVal ); \ | ||
110 | } while ( 0 ) | ||
111 | # endif | ||
112 | |||
113 | # ifdef __CYGWIN__ | ||
114 | # include <io.h> | ||
115 | # include <fcntl.h> | ||
116 | # undef SET_BINARY_MODE | ||
117 | # define SET_BINARY_MODE(fd) \ | ||
118 | do { \ | ||
119 | int retVal = setmode ( fileno ( fd ), \ | ||
120 | O_BINARY ); \ | ||
121 | ERROR_IF_MINUS_ONE ( retVal ); \ | ||
122 | } while ( 0 ) | ||
123 | # endif | ||
124 | #endif /* BZ_UNIX */ | ||
125 | |||
126 | |||
127 | |||
128 | #if BZ_LCCWIN32 | ||
129 | # include <io.h> | ||
130 | # include <fcntl.h> | ||
131 | # include <sys\stat.h> | ||
132 | |||
133 | # define NORETURN /**/ | ||
134 | # define PATH_SEP '\\' | ||
135 | # define MY_LSTAT _stat | ||
136 | # define MY_STAT _stat | ||
137 | # define MY_S_ISREG(x) ((x) & _S_IFREG) | ||
138 | # define MY_S_ISDIR(x) ((x) & _S_IFDIR) | ||
139 | |||
140 | # define APPEND_FLAG(root, name) \ | ||
141 | root=snocString((root), (name)) | ||
142 | |||
143 | # define APPEND_FILESPEC(root, name) \ | ||
144 | root = snocString ((root), (name)) | ||
145 | |||
146 | # define SET_BINARY_MODE(fd) \ | ||
147 | do { \ | ||
148 | int retVal = setmode ( fileno ( fd ), \ | ||
149 | O_BINARY ); \ | ||
150 | ERROR_IF_MINUS_ONE ( retVal ); \ | ||
151 | } while ( 0 ) | ||
152 | |||
153 | #endif /* BZ_LCCWIN32 */ | ||
154 | |||
155 | |||
156 | /*---------------------------------------------*/ | ||
157 | /*-- | ||
158 | Some more stuff for all platforms :-) | ||
159 | --*/ | ||
160 | |||
161 | typedef char Char; | ||
162 | typedef unsigned char Bool; | ||
163 | typedef unsigned char UChar; | ||
164 | typedef int Int32; | ||
165 | typedef unsigned int UInt32; | ||
166 | typedef short Int16; | ||
167 | typedef unsigned short UInt16; | ||
168 | |||
169 | #define True ((Bool)1) | ||
170 | #define False ((Bool)0) | ||
171 | |||
172 | /*-- | ||
173 | IntNative is your platform's `native' int size. | ||
174 | Only here to avoid probs with 64-bit platforms. | ||
175 | --*/ | ||
176 | typedef int IntNative; | ||
177 | |||
178 | |||
179 | /*---------------------------------------------------*/ | ||
180 | /*--- Misc (file handling) data decls ---*/ | ||
181 | /*---------------------------------------------------*/ | ||
182 | |||
183 | Int32 verbosity; | ||
184 | Bool keepInputFiles, smallMode, deleteOutputOnInterrupt; | ||
185 | Bool forceOverwrite, testFailsExist, unzFailsExist, noisy; | ||
186 | Int32 numFileNames, numFilesProcessed, blockSize100k; | ||
187 | Int32 exitValue; | ||
188 | |||
189 | /*-- source modes; F==file, I==stdin, O==stdout --*/ | ||
190 | #define SM_I2O 1 | ||
191 | #define SM_F2O 2 | ||
192 | #define SM_F2F 3 | ||
193 | |||
194 | /*-- operation modes --*/ | ||
195 | #define OM_Z 1 | ||
196 | #define OM_UNZ 2 | ||
197 | #define OM_TEST 3 | ||
198 | |||
199 | Int32 opMode; | ||
200 | Int32 srcMode; | ||
201 | |||
202 | #define FILE_NAME_LEN 1034 | ||
203 | |||
204 | Int32 longestFileName; | ||
205 | Char inName [FILE_NAME_LEN]; | ||
206 | Char outName[FILE_NAME_LEN]; | ||
207 | Char tmpName[FILE_NAME_LEN]; | ||
208 | Char *progName; | ||
209 | Char progNameReally[FILE_NAME_LEN]; | ||
210 | FILE *outputHandleJustInCase; | ||
211 | Int32 workFactor; | ||
212 | |||
213 | static void panic ( const Char* ) NORETURN; | ||
214 | static void ioError ( void ) NORETURN; | ||
215 | static void outOfMemory ( void ) NORETURN; | ||
216 | static void configError ( void ) NORETURN; | ||
217 | static void crcError ( void ) NORETURN; | ||
218 | static void cleanUpAndFail ( Int32 ) NORETURN; | ||
219 | static void compressedStreamEOF ( void ) NORETURN; | ||
220 | |||
221 | static void copyFileName ( Char*, Char* ); | ||
222 | static void* myMalloc ( Int32 ); | ||
223 | static void applySavedFileAttrToOutputFile ( IntNative fd ); | ||
224 | |||
225 | |||
226 | |||
227 | /*---------------------------------------------------*/ | ||
228 | /*--- An implementation of 64-bit ints. Sigh. ---*/ | ||
229 | /*--- Roll on widespread deployment of ANSI C9X ! ---*/ | ||
230 | /*---------------------------------------------------*/ | ||
231 | |||
232 | typedef | ||
233 | struct { UChar b[8]; } | ||
234 | UInt64; | ||
235 | |||
236 | |||
237 | static | ||
238 | void uInt64_from_UInt32s ( UInt64* n, UInt32 lo32, UInt32 hi32 ) | ||
239 | { | ||
240 | n->b[7] = (UChar)((hi32 >> 24) & 0xFF); | ||
241 | n->b[6] = (UChar)((hi32 >> 16) & 0xFF); | ||
242 | n->b[5] = (UChar)((hi32 >> 8) & 0xFF); | ||
243 | n->b[4] = (UChar) (hi32 & 0xFF); | ||
244 | n->b[3] = (UChar)((lo32 >> 24) & 0xFF); | ||
245 | n->b[2] = (UChar)((lo32 >> 16) & 0xFF); | ||
246 | n->b[1] = (UChar)((lo32 >> 8) & 0xFF); | ||
247 | n->b[0] = (UChar) (lo32 & 0xFF); | ||
248 | } | ||
249 | |||
250 | |||
251 | static | ||
252 | double uInt64_to_double ( UInt64* n ) | ||
253 | { | ||
254 | Int32 i; | ||
255 | double base = 1.0; | ||
256 | double sum = 0.0; | ||
257 | for (i = 0; i < 8; i++) { | ||
258 | sum += base * (double)(n->b[i]); | ||
259 | base *= 256.0; | ||
260 | } | ||
261 | return sum; | ||
262 | } | ||
263 | |||
264 | |||
265 | static | ||
266 | Bool uInt64_isZero ( UInt64* n ) | ||
267 | { | ||
268 | Int32 i; | ||
269 | for (i = 0; i < 8; i++) | ||
270 | if (n->b[i] != 0) return 0; | ||
271 | return 1; | ||
272 | } | ||
273 | |||
274 | |||
275 | /* Divide *n by 10, and return the remainder. */ | ||
276 | static | ||
277 | Int32 uInt64_qrm10 ( UInt64* n ) | ||
278 | { | ||
279 | UInt32 rem, tmp; | ||
280 | Int32 i; | ||
281 | rem = 0; | ||
282 | for (i = 7; i >= 0; i--) { | ||
283 | tmp = rem * 256 + n->b[i]; | ||
284 | n->b[i] = tmp / 10; | ||
285 | rem = tmp % 10; | ||
286 | } | ||
287 | return rem; | ||
288 | } | ||
289 | |||
290 | |||
291 | /* ... and the Whole Entire Point of all this UInt64 stuff is | ||
292 | so that we can supply the following function. | ||
293 | */ | ||
294 | static | ||
295 | void uInt64_toAscii ( char* outbuf, UInt64* n ) | ||
296 | { | ||
297 | Int32 i, q; | ||
298 | UChar buf[32]; | ||
299 | Int32 nBuf = 0; | ||
300 | UInt64 n_copy = *n; | ||
301 | do { | ||
302 | q = uInt64_qrm10 ( &n_copy ); | ||
303 | buf[nBuf] = q + '0'; | ||
304 | nBuf++; | ||
305 | } while (!uInt64_isZero(&n_copy)); | ||
306 | outbuf[nBuf] = 0; | ||
307 | for (i = 0; i < nBuf; i++) | ||
308 | outbuf[i] = buf[nBuf-i-1]; | ||
309 | } | ||
310 | |||
311 | |||
312 | /*---------------------------------------------------*/ | ||
313 | /*--- Processing of complete files and streams ---*/ | ||
314 | /*---------------------------------------------------*/ | ||
315 | |||
316 | /*---------------------------------------------*/ | ||
317 | static | ||
318 | Bool myfeof ( FILE* f ) | ||
319 | { | ||
320 | Int32 c = fgetc ( f ); | ||
321 | if (c == EOF) return True; | ||
322 | ungetc ( c, f ); | ||
323 | return False; | ||
324 | } | ||
325 | |||
326 | |||
327 | /*---------------------------------------------*/ | ||
328 | static | ||
329 | void compressStream ( FILE *stream, FILE *zStream ) | ||
330 | { | ||
331 | BZFILE* bzf = NULL; | ||
332 | UChar ibuf[5000]; | ||
333 | Int32 nIbuf; | ||
334 | UInt32 nbytes_in_lo32, nbytes_in_hi32; | ||
335 | UInt32 nbytes_out_lo32, nbytes_out_hi32; | ||
336 | Int32 bzerr, bzerr_dummy, ret; | ||
337 | |||
338 | SET_BINARY_MODE(stream); | ||
339 | SET_BINARY_MODE(zStream); | ||
340 | |||
341 | if (ferror(stream)) goto errhandler_io; | ||
342 | if (ferror(zStream)) goto errhandler_io; | ||
343 | |||
344 | bzf = BZ2_bzWriteOpen ( &bzerr, zStream, | ||
345 | blockSize100k, verbosity, workFactor ); | ||
346 | if (bzerr != BZ_OK) goto errhandler; | ||
347 | |||
348 | if (verbosity >= 2) fprintf ( stderr, "\n" ); | ||
349 | |||
350 | while (True) { | ||
351 | |||
352 | if (myfeof(stream)) break; | ||
353 | nIbuf = fread ( ibuf, sizeof(UChar), 5000, stream ); | ||
354 | if (ferror(stream)) goto errhandler_io; | ||
355 | if (nIbuf > 0) BZ2_bzWrite ( &bzerr, bzf, (void*)ibuf, nIbuf ); | ||
356 | if (bzerr != BZ_OK) goto errhandler; | ||
357 | |||
358 | } | ||
359 | |||
360 | BZ2_bzWriteClose64 ( &bzerr, bzf, 0, | ||
361 | &nbytes_in_lo32, &nbytes_in_hi32, | ||
362 | &nbytes_out_lo32, &nbytes_out_hi32 ); | ||
363 | if (bzerr != BZ_OK) goto errhandler; | ||
364 | |||
365 | if (ferror(zStream)) goto errhandler_io; | ||
366 | ret = fflush ( zStream ); | ||
367 | if (ret == EOF) goto errhandler_io; | ||
368 | if (zStream != stdout) { | ||
369 | Int32 fd = fileno ( zStream ); | ||
370 | if (fd < 0) goto errhandler_io; | ||
371 | applySavedFileAttrToOutputFile ( fd ); | ||
372 | ret = fclose ( zStream ); | ||
373 | outputHandleJustInCase = NULL; | ||
374 | if (ret == EOF) goto errhandler_io; | ||
375 | } | ||
376 | outputHandleJustInCase = NULL; | ||
377 | if (ferror(stream)) goto errhandler_io; | ||
378 | ret = fclose ( stream ); | ||
379 | if (ret == EOF) goto errhandler_io; | ||
380 | |||
381 | if (verbosity >= 1) { | ||
382 | if (nbytes_in_lo32 == 0 && nbytes_in_hi32 == 0) { | ||
383 | fprintf ( stderr, " no data compressed.\n"); | ||
384 | } else { | ||
385 | Char buf_nin[32], buf_nout[32]; | ||
386 | UInt64 nbytes_in, nbytes_out; | ||
387 | double nbytes_in_d, nbytes_out_d; | ||
388 | uInt64_from_UInt32s ( &nbytes_in, | ||
389 | nbytes_in_lo32, nbytes_in_hi32 ); | ||
390 | uInt64_from_UInt32s ( &nbytes_out, | ||
391 | nbytes_out_lo32, nbytes_out_hi32 ); | ||
392 | nbytes_in_d = uInt64_to_double ( &nbytes_in ); | ||
393 | nbytes_out_d = uInt64_to_double ( &nbytes_out ); | ||
394 | uInt64_toAscii ( buf_nin, &nbytes_in ); | ||
395 | uInt64_toAscii ( buf_nout, &nbytes_out ); | ||
396 | fprintf ( stderr, "%6.3f:1, %6.3f bits/byte, " | ||
397 | "%5.2f%% saved, %s in, %s out.\n", | ||
398 | nbytes_in_d / nbytes_out_d, | ||
399 | (8.0 * nbytes_out_d) / nbytes_in_d, | ||
400 | 100.0 * (1.0 - nbytes_out_d / nbytes_in_d), | ||
401 | buf_nin, | ||
402 | buf_nout | ||
403 | ); | ||
404 | } | ||
405 | } | ||
406 | |||
407 | return; | ||
408 | |||
409 | errhandler: | ||
410 | BZ2_bzWriteClose64 ( &bzerr_dummy, bzf, 1, | ||
411 | &nbytes_in_lo32, &nbytes_in_hi32, | ||
412 | &nbytes_out_lo32, &nbytes_out_hi32 ); | ||
413 | switch (bzerr) { | ||
414 | case BZ_CONFIG_ERROR: | ||
415 | configError(); break; | ||
416 | case BZ_MEM_ERROR: | ||
417 | outOfMemory (); break; | ||
418 | case BZ_IO_ERROR: | ||
419 | errhandler_io: | ||
420 | ioError(); break; | ||
421 | default: | ||
422 | panic ( "compress:unexpected error" ); | ||
423 | } | ||
424 | |||
425 | panic ( "compress:end" ); | ||
426 | /*notreached*/ | ||
427 | } | ||
428 | |||
429 | |||
430 | |||
431 | /*---------------------------------------------*/ | ||
432 | static | ||
433 | Bool uncompressStream ( FILE *zStream, FILE *stream ) | ||
434 | { | ||
435 | BZFILE* bzf = NULL; | ||
436 | Int32 bzerr, bzerr_dummy, ret, nread, streamNo, i; | ||
437 | UChar obuf[5000]; | ||
438 | UChar unused[BZ_MAX_UNUSED]; | ||
439 | Int32 nUnused; | ||
440 | void* unusedTmpV; | ||
441 | UChar* unusedTmp; | ||
442 | |||
443 | nUnused = 0; | ||
444 | streamNo = 0; | ||
445 | |||
446 | SET_BINARY_MODE(stream); | ||
447 | SET_BINARY_MODE(zStream); | ||
448 | |||
449 | if (ferror(stream)) goto errhandler_io; | ||
450 | if (ferror(zStream)) goto errhandler_io; | ||
451 | |||
452 | while (True) { | ||
453 | |||
454 | bzf = BZ2_bzReadOpen ( | ||
455 | &bzerr, zStream, verbosity, | ||
456 | (int)smallMode, unused, nUnused | ||
457 | ); | ||
458 | if (bzf == NULL || bzerr != BZ_OK) goto errhandler; | ||
459 | streamNo++; | ||
460 | |||
461 | while (bzerr == BZ_OK) { | ||
462 | nread = BZ2_bzRead ( &bzerr, bzf, obuf, 5000 ); | ||
463 | if (bzerr == BZ_DATA_ERROR_MAGIC) goto trycat; | ||
464 | if ((bzerr == BZ_OK || bzerr == BZ_STREAM_END) && nread > 0) | ||
465 | fwrite ( obuf, sizeof(UChar), nread, stream ); | ||
466 | if (ferror(stream)) goto errhandler_io; | ||
467 | } | ||
468 | if (bzerr != BZ_STREAM_END) goto errhandler; | ||
469 | |||
470 | BZ2_bzReadGetUnused ( &bzerr, bzf, &unusedTmpV, &nUnused ); | ||
471 | if (bzerr != BZ_OK) panic ( "decompress:bzReadGetUnused" ); | ||
472 | |||
473 | unusedTmp = (UChar*)unusedTmpV; | ||
474 | for (i = 0; i < nUnused; i++) unused[i] = unusedTmp[i]; | ||
475 | |||
476 | BZ2_bzReadClose ( &bzerr, bzf ); | ||
477 | if (bzerr != BZ_OK) panic ( "decompress:bzReadGetUnused" ); | ||
478 | |||
479 | if (nUnused == 0 && myfeof(zStream)) break; | ||
480 | } | ||
481 | |||
482 | closeok: | ||
483 | if (ferror(zStream)) goto errhandler_io; | ||
484 | if (stream != stdout) { | ||
485 | Int32 fd = fileno ( stream ); | ||
486 | if (fd < 0) goto errhandler_io; | ||
487 | applySavedFileAttrToOutputFile ( fd ); | ||
488 | } | ||
489 | ret = fclose ( zStream ); | ||
490 | if (ret == EOF) goto errhandler_io; | ||
491 | |||
492 | if (ferror(stream)) goto errhandler_io; | ||
493 | ret = fflush ( stream ); | ||
494 | if (ret != 0) goto errhandler_io; | ||
495 | if (stream != stdout) { | ||
496 | ret = fclose ( stream ); | ||
497 | outputHandleJustInCase = NULL; | ||
498 | if (ret == EOF) goto errhandler_io; | ||
499 | } | ||
500 | outputHandleJustInCase = NULL; | ||
501 | if (verbosity >= 2) fprintf ( stderr, "\n " ); | ||
502 | return True; | ||
503 | |||
504 | trycat: | ||
505 | if (forceOverwrite) { | ||
506 | rewind(zStream); | ||
507 | while (True) { | ||
508 | if (myfeof(zStream)) break; | ||
509 | nread = fread ( obuf, sizeof(UChar), 5000, zStream ); | ||
510 | if (ferror(zStream)) goto errhandler_io; | ||
511 | if (nread > 0) fwrite ( obuf, sizeof(UChar), nread, stream ); | ||
512 | if (ferror(stream)) goto errhandler_io; | ||
513 | } | ||
514 | goto closeok; | ||
515 | } | ||
516 | |||
517 | errhandler: | ||
518 | BZ2_bzReadClose ( &bzerr_dummy, bzf ); | ||
519 | switch (bzerr) { | ||
520 | case BZ_CONFIG_ERROR: | ||
521 | configError(); break; | ||
522 | case BZ_IO_ERROR: | ||
523 | errhandler_io: | ||
524 | ioError(); break; | ||
525 | case BZ_DATA_ERROR: | ||
526 | crcError(); | ||
527 | case BZ_MEM_ERROR: | ||
528 | outOfMemory(); | ||
529 | case BZ_UNEXPECTED_EOF: | ||
530 | compressedStreamEOF(); | ||
531 | case BZ_DATA_ERROR_MAGIC: | ||
532 | if (zStream != stdin) fclose(zStream); | ||
533 | if (stream != stdout) fclose(stream); | ||
534 | if (streamNo == 1) { | ||
535 | return False; | ||
536 | } else { | ||
537 | if (noisy) | ||
538 | fprintf ( stderr, | ||
539 | "\n%s: %s: trailing garbage after EOF ignored\n", | ||
540 | progName, inName ); | ||
541 | return True; | ||
542 | } | ||
543 | default: | ||
544 | panic ( "decompress:unexpected error" ); | ||
545 | } | ||
546 | |||
547 | panic ( "decompress:end" ); | ||
548 | return True; /*notreached*/ | ||
549 | } | ||
550 | |||
551 | |||
552 | /*---------------------------------------------*/ | ||
553 | static | ||
554 | Bool testStream ( FILE *zStream ) | ||
555 | { | ||
556 | BZFILE* bzf = NULL; | ||
557 | Int32 bzerr, bzerr_dummy, ret, nread, streamNo, i; | ||
558 | UChar obuf[5000]; | ||
559 | UChar unused[BZ_MAX_UNUSED]; | ||
560 | Int32 nUnused; | ||
561 | void* unusedTmpV; | ||
562 | UChar* unusedTmp; | ||
563 | |||
564 | nUnused = 0; | ||
565 | streamNo = 0; | ||
566 | |||
567 | SET_BINARY_MODE(zStream); | ||
568 | if (ferror(zStream)) goto errhandler_io; | ||
569 | |||
570 | while (True) { | ||
571 | |||
572 | bzf = BZ2_bzReadOpen ( | ||
573 | &bzerr, zStream, verbosity, | ||
574 | (int)smallMode, unused, nUnused | ||
575 | ); | ||
576 | if (bzf == NULL || bzerr != BZ_OK) goto errhandler; | ||
577 | streamNo++; | ||
578 | |||
579 | while (bzerr == BZ_OK) { | ||
580 | nread = BZ2_bzRead ( &bzerr, bzf, obuf, 5000 ); | ||
581 | if (bzerr == BZ_DATA_ERROR_MAGIC) goto errhandler; | ||
582 | } | ||
583 | if (bzerr != BZ_STREAM_END) goto errhandler; | ||
584 | |||
585 | BZ2_bzReadGetUnused ( &bzerr, bzf, &unusedTmpV, &nUnused ); | ||
586 | if (bzerr != BZ_OK) panic ( "test:bzReadGetUnused" ); | ||
587 | |||
588 | unusedTmp = (UChar*)unusedTmpV; | ||
589 | for (i = 0; i < nUnused; i++) unused[i] = unusedTmp[i]; | ||
590 | |||
591 | BZ2_bzReadClose ( &bzerr, bzf ); | ||
592 | if (bzerr != BZ_OK) panic ( "test:bzReadGetUnused" ); | ||
593 | if (nUnused == 0 && myfeof(zStream)) break; | ||
594 | |||
595 | } | ||
596 | |||
597 | if (ferror(zStream)) goto errhandler_io; | ||
598 | ret = fclose ( zStream ); | ||
599 | if (ret == EOF) goto errhandler_io; | ||
600 | |||
601 | if (verbosity >= 2) fprintf ( stderr, "\n " ); | ||
602 | return True; | ||
603 | |||
604 | errhandler: | ||
605 | BZ2_bzReadClose ( &bzerr_dummy, bzf ); | ||
606 | if (verbosity == 0) | ||
607 | fprintf ( stderr, "%s: %s: ", progName, inName ); | ||
608 | switch (bzerr) { | ||
609 | case BZ_CONFIG_ERROR: | ||
610 | configError(); break; | ||
611 | case BZ_IO_ERROR: | ||
612 | errhandler_io: | ||
613 | ioError(); break; | ||
614 | case BZ_DATA_ERROR: | ||
615 | fprintf ( stderr, | ||
616 | "data integrity (CRC) error in data\n" ); | ||
617 | return False; | ||
618 | case BZ_MEM_ERROR: | ||
619 | outOfMemory(); | ||
620 | case BZ_UNEXPECTED_EOF: | ||
621 | fprintf ( stderr, | ||
622 | "file ends unexpectedly\n" ); | ||
623 | return False; | ||
624 | case BZ_DATA_ERROR_MAGIC: | ||
625 | if (zStream != stdin) fclose(zStream); | ||
626 | if (streamNo == 1) { | ||
627 | fprintf ( stderr, | ||
628 | "bad magic number (file not created by bzip2)\n" ); | ||
629 | return False; | ||
630 | } else { | ||
631 | if (noisy) | ||
632 | fprintf ( stderr, | ||
633 | "trailing garbage after EOF ignored\n" ); | ||
634 | return True; | ||
635 | } | ||
636 | default: | ||
637 | panic ( "test:unexpected error" ); | ||
638 | } | ||
639 | |||
640 | panic ( "test:end" ); | ||
641 | return True; /*notreached*/ | ||
642 | } | ||
643 | |||
644 | |||
645 | /*---------------------------------------------------*/ | ||
646 | /*--- Error [non-] handling grunge ---*/ | ||
647 | /*---------------------------------------------------*/ | ||
648 | |||
649 | /*---------------------------------------------*/ | ||
650 | static | ||
651 | void setExit ( Int32 v ) | ||
652 | { | ||
653 | if (v > exitValue) exitValue = v; | ||
654 | } | ||
655 | |||
656 | |||
657 | /*---------------------------------------------*/ | ||
658 | static | ||
659 | void cadvise ( void ) | ||
660 | { | ||
661 | if (noisy) | ||
662 | fprintf ( | ||
663 | stderr, | ||
664 | "\nIt is possible that the compressed file(s) have become corrupted.\n" | ||
665 | "You can use the -tvv option to test integrity of such files.\n\n" | ||
666 | "You can use the `bzip2recover' program to attempt to recover\n" | ||
667 | "data from undamaged sections of corrupted files.\n\n" | ||
668 | ); | ||
669 | } | ||
670 | |||
671 | |||
672 | /*---------------------------------------------*/ | ||
673 | static | ||
674 | void showFileNames ( void ) | ||
675 | { | ||
676 | if (noisy) | ||
677 | fprintf ( | ||
678 | stderr, | ||
679 | "\tInput file = %s, output file = %s\n", | ||
680 | inName, outName | ||
681 | ); | ||
682 | } | ||
683 | |||
684 | |||
685 | /*---------------------------------------------*/ | ||
686 | static | ||
687 | void cleanUpAndFail ( Int32 ec ) | ||
688 | { | ||
689 | IntNative retVal; | ||
690 | struct MY_STAT statBuf; | ||
691 | |||
692 | if ( srcMode == SM_F2F | ||
693 | && opMode != OM_TEST | ||
694 | && deleteOutputOnInterrupt ) { | ||
695 | |||
696 | /* Check whether input file still exists. Delete output file | ||
697 | only if input exists to avoid loss of data. Joerg Prante, 5 | ||
698 | January 2002. (JRS 06-Jan-2002: other changes in 1.0.2 mean | ||
699 | this is less likely to happen. But to be ultra-paranoid, we | ||
700 | do the check anyway.) */ | ||
701 | retVal = MY_STAT ( inName, &statBuf ); | ||
702 | if (retVal == 0) { | ||
703 | if (noisy) | ||
704 | fprintf ( stderr, | ||
705 | "%s: Deleting output file %s, if it exists.\n", | ||
706 | progName, outName ); | ||
707 | if (outputHandleJustInCase != NULL) | ||
708 | fclose ( outputHandleJustInCase ); | ||
709 | retVal = remove ( outName ); | ||
710 | if (retVal != 0) | ||
711 | fprintf ( stderr, | ||
712 | "%s: WARNING: deletion of output file " | ||
713 | "(apparently) failed.\n", | ||
714 | progName ); | ||
715 | } else { | ||
716 | fprintf ( stderr, | ||
717 | "%s: WARNING: deletion of output file suppressed\n", | ||
718 | progName ); | ||
719 | fprintf ( stderr, | ||
720 | "%s: since input file no longer exists. Output file\n", | ||
721 | progName ); | ||
722 | fprintf ( stderr, | ||
723 | "%s: `%s' may be incomplete.\n", | ||
724 | progName, outName ); | ||
725 | fprintf ( stderr, | ||
726 | "%s: I suggest doing an integrity test (bzip2 -tv)" | ||
727 | " of it.\n", | ||
728 | progName ); | ||
729 | } | ||
730 | } | ||
731 | |||
732 | if (noisy && numFileNames > 0 && numFilesProcessed < numFileNames) { | ||
733 | fprintf ( stderr, | ||
734 | "%s: WARNING: some files have not been processed:\n" | ||
735 | "%s: %d specified on command line, %d not processed yet.\n\n", | ||
736 | progName, progName, | ||
737 | numFileNames, numFileNames - numFilesProcessed ); | ||
738 | } | ||
739 | setExit(ec); | ||
740 | exit(exitValue); | ||
741 | } | ||
742 | |||
743 | |||
744 | /*---------------------------------------------*/ | ||
745 | static | ||
746 | void panic ( const Char* s ) | ||
747 | { | ||
748 | fprintf ( stderr, | ||
749 | "\n%s: PANIC -- internal consistency error:\n" | ||
750 | "\t%s\n" | ||
751 | "\tThis is a BUG. Please report it to me at:\n" | ||
752 | "\tjseward@bzip.org\n", | ||
753 | progName, s ); | ||
754 | showFileNames(); | ||
755 | cleanUpAndFail( 3 ); | ||
756 | } | ||
757 | |||
758 | |||
759 | /*---------------------------------------------*/ | ||
760 | static | ||
761 | void crcError ( void ) | ||
762 | { | ||
763 | fprintf ( stderr, | ||
764 | "\n%s: Data integrity error when decompressing.\n", | ||
765 | progName ); | ||
766 | showFileNames(); | ||
767 | cadvise(); | ||
768 | cleanUpAndFail( 2 ); | ||
769 | } | ||
770 | |||
771 | |||
772 | /*---------------------------------------------*/ | ||
773 | static | ||
774 | void compressedStreamEOF ( void ) | ||
775 | { | ||
776 | if (noisy) { | ||
777 | fprintf ( stderr, | ||
778 | "\n%s: Compressed file ends unexpectedly;\n\t" | ||
779 | "perhaps it is corrupted? *Possible* reason follows.\n", | ||
780 | progName ); | ||
781 | perror ( progName ); | ||
782 | showFileNames(); | ||
783 | cadvise(); | ||
784 | } | ||
785 | cleanUpAndFail( 2 ); | ||
786 | } | ||
787 | |||
788 | |||
789 | /*---------------------------------------------*/ | ||
790 | static | ||
791 | void ioError ( void ) | ||
792 | { | ||
793 | fprintf ( stderr, | ||
794 | "\n%s: I/O or other error, bailing out. " | ||
795 | "Possible reason follows.\n", | ||
796 | progName ); | ||
797 | perror ( progName ); | ||
798 | showFileNames(); | ||
799 | cleanUpAndFail( 1 ); | ||
800 | } | ||
801 | |||
802 | |||
803 | /*---------------------------------------------*/ | ||
804 | static | ||
805 | void mySignalCatcher ( IntNative n ) | ||
806 | { | ||
807 | fprintf ( stderr, | ||
808 | "\n%s: Control-C or similar caught, quitting.\n", | ||
809 | progName ); | ||
810 | cleanUpAndFail(1); | ||
811 | } | ||
812 | |||
813 | |||
814 | /*---------------------------------------------*/ | ||
815 | static | ||
816 | void mySIGSEGVorSIGBUScatcher ( IntNative n ) | ||
817 | { | ||
818 | if (opMode == OM_Z) | ||
819 | fprintf ( | ||
820 | stderr, | ||
821 | "\n%s: Caught a SIGSEGV or SIGBUS whilst compressing.\n" | ||
822 | "\n" | ||
823 | " Possible causes are (most likely first):\n" | ||
824 | " (1) This computer has unreliable memory or cache hardware\n" | ||
825 | " (a surprisingly common problem; try a different machine.)\n" | ||
826 | " (2) A bug in the compiler used to create this executable\n" | ||
827 | " (unlikely, if you didn't compile bzip2 yourself.)\n" | ||
828 | " (3) A real bug in bzip2 -- I hope this should never be the case.\n" | ||
829 | " The user's manual, Section 4.3, has more info on (1) and (2).\n" | ||
830 | " \n" | ||
831 | " If you suspect this is a bug in bzip2, or are unsure about (1)\n" | ||
832 | " or (2), feel free to report it to me at: jseward@bzip.org.\n" | ||
833 | " Section 4.3 of the user's manual describes the info a useful\n" | ||
834 | " bug report should have. If the manual is available on your\n" | ||
835 | " system, please try and read it before mailing me. If you don't\n" | ||
836 | " have the manual or can't be bothered to read it, mail me anyway.\n" | ||
837 | "\n", | ||
838 | progName ); | ||
839 | else | ||
840 | fprintf ( | ||
841 | stderr, | ||
842 | "\n%s: Caught a SIGSEGV or SIGBUS whilst decompressing.\n" | ||
843 | "\n" | ||
844 | " Possible causes are (most likely first):\n" | ||
845 | " (1) The compressed data is corrupted, and bzip2's usual checks\n" | ||
846 | " failed to detect this. Try bzip2 -tvv my_file.bz2.\n" | ||
847 | " (2) This computer has unreliable memory or cache hardware\n" | ||
848 | " (a surprisingly common problem; try a different machine.)\n" | ||
849 | " (3) A bug in the compiler used to create this executable\n" | ||
850 | " (unlikely, if you didn't compile bzip2 yourself.)\n" | ||
851 | " (4) A real bug in bzip2 -- I hope this should never be the case.\n" | ||
852 | " The user's manual, Section 4.3, has more info on (2) and (3).\n" | ||
853 | " \n" | ||
854 | " If you suspect this is a bug in bzip2, or are unsure about (2)\n" | ||
855 | " or (3), feel free to report it to me at: jseward@bzip.org.\n" | ||
856 | " Section 4.3 of the user's manual describes the info a useful\n" | ||
857 | " bug report should have. If the manual is available on your\n" | ||
858 | " system, please try and read it before mailing me. If you don't\n" | ||
859 | " have the manual or can't be bothered to read it, mail me anyway.\n" | ||
860 | "\n", | ||
861 | progName ); | ||
862 | |||
863 | showFileNames(); | ||
864 | if (opMode == OM_Z) | ||
865 | cleanUpAndFail( 3 ); else | ||
866 | { cadvise(); cleanUpAndFail( 2 ); } | ||
867 | } | ||
868 | |||
869 | |||
870 | /*---------------------------------------------*/ | ||
871 | static | ||
872 | void outOfMemory ( void ) | ||
873 | { | ||
874 | fprintf ( stderr, | ||
875 | "\n%s: couldn't allocate enough memory\n", | ||
876 | progName ); | ||
877 | showFileNames(); | ||
878 | cleanUpAndFail(1); | ||
879 | } | ||
880 | |||
881 | |||
882 | /*---------------------------------------------*/ | ||
883 | static | ||
884 | void configError ( void ) | ||
885 | { | ||
886 | fprintf ( stderr, | ||
887 | "bzip2: I'm not configured correctly for this platform!\n" | ||
888 | "\tI require Int32, Int16 and Char to have sizes\n" | ||
889 | "\tof 4, 2 and 1 bytes to run properly, and they don't.\n" | ||
890 | "\tProbably you can fix this by defining them correctly,\n" | ||
891 | "\tand recompiling. Bye!\n" ); | ||
892 | setExit(3); | ||
893 | exit(exitValue); | ||
894 | } | ||
895 | |||
896 | |||
897 | /*---------------------------------------------------*/ | ||
898 | /*--- The main driver machinery ---*/ | ||
899 | /*---------------------------------------------------*/ | ||
900 | |||
901 | /* All rather crufty. The main problem is that input files | ||
902 | are stat()d multiple times before use. This should be | ||
903 | cleaned up. | ||
904 | */ | ||
905 | |||
906 | /*---------------------------------------------*/ | ||
907 | static | ||
908 | void pad ( Char *s ) | ||
909 | { | ||
910 | Int32 i; | ||
911 | if ( (Int32)strlen(s) >= longestFileName ) return; | ||
912 | for (i = 1; i <= longestFileName - (Int32)strlen(s); i++) | ||
913 | fprintf ( stderr, " " ); | ||
914 | } | ||
915 | |||
916 | |||
917 | /*---------------------------------------------*/ | ||
918 | static | ||
919 | void copyFileName ( Char* to, Char* from ) | ||
920 | { | ||
921 | if ( strlen(from) > FILE_NAME_LEN-10 ) { | ||
922 | fprintf ( | ||
923 | stderr, | ||
924 | "bzip2: file name\n`%s'\n" | ||
925 | "is suspiciously (more than %d chars) long.\n" | ||
926 | "Try using a reasonable file name instead. Sorry! :-)\n", | ||
927 | from, FILE_NAME_LEN-10 | ||
928 | ); | ||
929 | setExit(1); | ||
930 | exit(exitValue); | ||
931 | } | ||
932 | |||
933 | strncpy(to,from,FILE_NAME_LEN-10); | ||
934 | to[FILE_NAME_LEN-10]='\0'; | ||
935 | } | ||
936 | |||
937 | |||
938 | /*---------------------------------------------*/ | ||
939 | static | ||
940 | Bool fileExists ( Char* name ) | ||
941 | { | ||
942 | FILE *tmp = fopen ( name, "rb" ); | ||
943 | Bool exists = (tmp != NULL); | ||
944 | if (tmp != NULL) fclose ( tmp ); | ||
945 | return exists; | ||
946 | } | ||
947 | |||
948 | |||
949 | /*---------------------------------------------*/ | ||
950 | /* Open an output file safely with O_EXCL and good permissions. | ||
951 | This avoids a race condition in versions < 1.0.2, in which | ||
952 | the file was first opened and then had its interim permissions | ||
953 | set safely. We instead use open() to create the file with | ||
954 | the interim permissions required. (--- --- rw-). | ||
955 | |||
956 | For non-Unix platforms, if we are not worrying about | ||
957 | security issues, simple this simply behaves like fopen. | ||
958 | */ | ||
959 | static | ||
960 | FILE* fopen_output_safely ( Char* name, const char* mode ) | ||
961 | { | ||
962 | # if BZ_UNIX | ||
963 | FILE* fp; | ||
964 | IntNative fh; | ||
965 | fh = open(name, O_WRONLY|O_CREAT|O_EXCL, S_IWUSR|S_IRUSR); | ||
966 | if (fh == -1) return NULL; | ||
967 | fp = fdopen(fh, mode); | ||
968 | if (fp == NULL) close(fh); | ||
969 | return fp; | ||
970 | # else | ||
971 | return fopen(name, mode); | ||
972 | # endif | ||
973 | } | ||
974 | |||
975 | |||
976 | /*---------------------------------------------*/ | ||
977 | /*-- | ||
978 | if in doubt, return True | ||
979 | --*/ | ||
980 | static | ||
981 | Bool notAStandardFile ( Char* name ) | ||
982 | { | ||
983 | IntNative i; | ||
984 | struct MY_STAT statBuf; | ||
985 | |||
986 | i = MY_LSTAT ( name, &statBuf ); | ||
987 | if (i != 0) return True; | ||
988 | if (MY_S_ISREG(statBuf.st_mode)) return False; | ||
989 | return True; | ||
990 | } | ||
991 | |||
992 | |||
993 | /*---------------------------------------------*/ | ||
994 | /*-- | ||
995 | rac 11/21/98 see if file has hard links to it | ||
996 | --*/ | ||
997 | static | ||
998 | Int32 countHardLinks ( Char* name ) | ||
999 | { | ||
1000 | IntNative i; | ||
1001 | struct MY_STAT statBuf; | ||
1002 | |||
1003 | i = MY_LSTAT ( name, &statBuf ); | ||
1004 | if (i != 0) return 0; | ||
1005 | return (statBuf.st_nlink - 1); | ||
1006 | } | ||
1007 | |||
1008 | |||
1009 | /*---------------------------------------------*/ | ||
1010 | /* Copy modification date, access date, permissions and owner from the | ||
1011 | source to destination file. We have to copy this meta-info off | ||
1012 | into fileMetaInfo before starting to compress / decompress it, | ||
1013 | because doing it afterwards means we get the wrong access time. | ||
1014 | |||
1015 | To complicate matters, in compress() and decompress() below, the | ||
1016 | sequence of tests preceding the call to saveInputFileMetaInfo() | ||
1017 | involves calling fileExists(), which in turn establishes its result | ||
1018 | by attempting to fopen() the file, and if successful, immediately | ||
1019 | fclose()ing it again. So we have to assume that the fopen() call | ||
1020 | does not cause the access time field to be updated. | ||
1021 | |||
1022 | Reading of the man page for stat() (man 2 stat) on RedHat 7.2 seems | ||
1023 | to imply that merely doing open() will not affect the access time. | ||
1024 | Therefore we merely need to hope that the C library only does | ||
1025 | open() as a result of fopen(), and not any kind of read()-ahead | ||
1026 | cleverness. | ||
1027 | |||
1028 | It sounds pretty fragile to me. Whether this carries across | ||
1029 | robustly to arbitrary Unix-like platforms (or even works robustly | ||
1030 | on this one, RedHat 7.2) is unknown to me. Nevertheless ... | ||
1031 | */ | ||
1032 | #if BZ_UNIX | ||
1033 | static | ||
1034 | struct MY_STAT fileMetaInfo; | ||
1035 | #endif | ||
1036 | |||
1037 | static | ||
1038 | void saveInputFileMetaInfo ( Char *srcName ) | ||
1039 | { | ||
1040 | # if BZ_UNIX | ||
1041 | IntNative retVal; | ||
1042 | /* Note use of stat here, not lstat. */ | ||
1043 | retVal = MY_STAT( srcName, &fileMetaInfo ); | ||
1044 | ERROR_IF_NOT_ZERO ( retVal ); | ||
1045 | # endif | ||
1046 | } | ||
1047 | |||
1048 | |||
1049 | static | ||
1050 | void applySavedTimeInfoToOutputFile ( Char *dstName ) | ||
1051 | { | ||
1052 | # if BZ_UNIX | ||
1053 | IntNative retVal; | ||
1054 | struct utimbuf uTimBuf; | ||
1055 | |||
1056 | uTimBuf.actime = fileMetaInfo.st_atime; | ||
1057 | uTimBuf.modtime = fileMetaInfo.st_mtime; | ||
1058 | |||
1059 | retVal = utime ( dstName, &uTimBuf ); | ||
1060 | ERROR_IF_NOT_ZERO ( retVal ); | ||
1061 | # endif | ||
1062 | } | ||
1063 | |||
1064 | static | ||
1065 | void applySavedFileAttrToOutputFile ( IntNative fd ) | ||
1066 | { | ||
1067 | # if BZ_UNIX | ||
1068 | IntNative retVal; | ||
1069 | |||
1070 | retVal = fchmod ( fd, fileMetaInfo.st_mode ); | ||
1071 | ERROR_IF_NOT_ZERO ( retVal ); | ||
1072 | |||
1073 | (void) fchown ( fd, fileMetaInfo.st_uid, fileMetaInfo.st_gid ); | ||
1074 | /* chown() will in many cases return with EPERM, which can | ||
1075 | be safely ignored. | ||
1076 | */ | ||
1077 | # endif | ||
1078 | } | ||
1079 | |||
1080 | |||
1081 | /*---------------------------------------------*/ | ||
1082 | static | ||
1083 | Bool containsDubiousChars ( Char* name ) | ||
1084 | { | ||
1085 | # if BZ_UNIX | ||
1086 | /* On unix, files can contain any characters and the file expansion | ||
1087 | * is performed by the shell. | ||
1088 | */ | ||
1089 | return False; | ||
1090 | # else /* ! BZ_UNIX */ | ||
1091 | /* On non-unix (Win* platforms), wildcard characters are not allowed in | ||
1092 | * filenames. | ||
1093 | */ | ||
1094 | for (; *name != '\0'; name++) | ||
1095 | if (*name == '?' || *name == '*') return True; | ||
1096 | return False; | ||
1097 | # endif /* BZ_UNIX */ | ||
1098 | } | ||
1099 | |||
1100 | |||
1101 | /*---------------------------------------------*/ | ||
1102 | #define BZ_N_SUFFIX_PAIRS 4 | ||
1103 | |||
1104 | const Char* zSuffix[BZ_N_SUFFIX_PAIRS] | ||
1105 | = { ".bz2", ".bz", ".tbz2", ".tbz" }; | ||
1106 | const Char* unzSuffix[BZ_N_SUFFIX_PAIRS] | ||
1107 | = { "", "", ".tar", ".tar" }; | ||
1108 | |||
1109 | static | ||
1110 | Bool hasSuffix ( Char* s, const Char* suffix ) | ||
1111 | { | ||
1112 | Int32 ns = strlen(s); | ||
1113 | Int32 nx = strlen(suffix); | ||
1114 | if (ns < nx) return False; | ||
1115 | if (strcmp(s + ns - nx, suffix) == 0) return True; | ||
1116 | return False; | ||
1117 | } | ||
1118 | |||
1119 | static | ||
1120 | Bool mapSuffix ( Char* name, | ||
1121 | const Char* oldSuffix, | ||
1122 | const Char* newSuffix ) | ||
1123 | { | ||
1124 | if (!hasSuffix(name,oldSuffix)) return False; | ||
1125 | name[strlen(name)-strlen(oldSuffix)] = 0; | ||
1126 | strcat ( name, newSuffix ); | ||
1127 | return True; | ||
1128 | } | ||
1129 | |||
1130 | |||
1131 | /*---------------------------------------------*/ | ||
1132 | static | ||
1133 | void compress ( Char *name ) | ||
1134 | { | ||
1135 | FILE *inStr; | ||
1136 | FILE *outStr; | ||
1137 | Int32 n, i; | ||
1138 | struct MY_STAT statBuf; | ||
1139 | |||
1140 | deleteOutputOnInterrupt = False; | ||
1141 | |||
1142 | if (name == NULL && srcMode != SM_I2O) | ||
1143 | panic ( "compress: bad modes\n" ); | ||
1144 | |||
1145 | switch (srcMode) { | ||
1146 | case SM_I2O: | ||
1147 | copyFileName ( inName, (Char*)"(stdin)" ); | ||
1148 | copyFileName ( outName, (Char*)"(stdout)" ); | ||
1149 | break; | ||
1150 | case SM_F2F: | ||
1151 | copyFileName ( inName, name ); | ||
1152 | copyFileName ( outName, name ); | ||
1153 | strcat ( outName, ".bz2" ); | ||
1154 | break; | ||
1155 | case SM_F2O: | ||
1156 | copyFileName ( inName, name ); | ||
1157 | copyFileName ( outName, (Char*)"(stdout)" ); | ||
1158 | break; | ||
1159 | } | ||
1160 | |||
1161 | if ( srcMode != SM_I2O && containsDubiousChars ( inName ) ) { | ||
1162 | if (noisy) | ||
1163 | fprintf ( stderr, "%s: There are no files matching `%s'.\n", | ||
1164 | progName, inName ); | ||
1165 | setExit(1); | ||
1166 | return; | ||
1167 | } | ||
1168 | if ( srcMode != SM_I2O && !fileExists ( inName ) ) { | ||
1169 | fprintf ( stderr, "%s: Can't open input file %s: %s.\n", | ||
1170 | progName, inName, strerror(errno) ); | ||
1171 | setExit(1); | ||
1172 | return; | ||
1173 | } | ||
1174 | for (i = 0; i < BZ_N_SUFFIX_PAIRS; i++) { | ||
1175 | if (hasSuffix(inName, zSuffix[i])) { | ||
1176 | if (noisy) | ||
1177 | fprintf ( stderr, | ||
1178 | "%s: Input file %s already has %s suffix.\n", | ||
1179 | progName, inName, zSuffix[i] ); | ||
1180 | setExit(1); | ||
1181 | return; | ||
1182 | } | ||
1183 | } | ||
1184 | if ( srcMode == SM_F2F || srcMode == SM_F2O ) { | ||
1185 | MY_STAT(inName, &statBuf); | ||
1186 | if ( MY_S_ISDIR(statBuf.st_mode) ) { | ||
1187 | fprintf( stderr, | ||
1188 | "%s: Input file %s is a directory.\n", | ||
1189 | progName,inName); | ||
1190 | setExit(1); | ||
1191 | return; | ||
1192 | } | ||
1193 | } | ||
1194 | if ( srcMode == SM_F2F && !forceOverwrite && notAStandardFile ( inName )) { | ||
1195 | if (noisy) | ||
1196 | fprintf ( stderr, "%s: Input file %s is not a normal file.\n", | ||
1197 | progName, inName ); | ||
1198 | setExit(1); | ||
1199 | return; | ||
1200 | } | ||
1201 | if ( srcMode == SM_F2F && fileExists ( outName ) ) { | ||
1202 | if (forceOverwrite) { | ||
1203 | remove(outName); | ||
1204 | } else { | ||
1205 | fprintf ( stderr, "%s: Output file %s already exists.\n", | ||
1206 | progName, outName ); | ||
1207 | setExit(1); | ||
1208 | return; | ||
1209 | } | ||
1210 | } | ||
1211 | if ( srcMode == SM_F2F && !forceOverwrite && | ||
1212 | (n=countHardLinks ( inName )) > 0) { | ||
1213 | fprintf ( stderr, "%s: Input file %s has %d other link%s.\n", | ||
1214 | progName, inName, n, n > 1 ? "s" : "" ); | ||
1215 | setExit(1); | ||
1216 | return; | ||
1217 | } | ||
1218 | |||
1219 | if ( srcMode == SM_F2F ) { | ||
1220 | /* Save the file's meta-info before we open it. Doing it later | ||
1221 | means we mess up the access times. */ | ||
1222 | saveInputFileMetaInfo ( inName ); | ||
1223 | } | ||
1224 | |||
1225 | switch ( srcMode ) { | ||
1226 | |||
1227 | case SM_I2O: | ||
1228 | inStr = stdin; | ||
1229 | outStr = stdout; | ||
1230 | if ( isatty ( fileno ( stdout ) ) ) { | ||
1231 | fprintf ( stderr, | ||
1232 | "%s: I won't write compressed data to a terminal.\n", | ||
1233 | progName ); | ||
1234 | fprintf ( stderr, "%s: For help, type: `%s --help'.\n", | ||
1235 | progName, progName ); | ||
1236 | setExit(1); | ||
1237 | return; | ||
1238 | }; | ||
1239 | break; | ||
1240 | |||
1241 | case SM_F2O: | ||
1242 | inStr = fopen ( inName, "rb" ); | ||
1243 | outStr = stdout; | ||
1244 | if ( isatty ( fileno ( stdout ) ) ) { | ||
1245 | fprintf ( stderr, | ||
1246 | "%s: I won't write compressed data to a terminal.\n", | ||
1247 | progName ); | ||
1248 | fprintf ( stderr, "%s: For help, type: `%s --help'.\n", | ||
1249 | progName, progName ); | ||
1250 | if ( inStr != NULL ) fclose ( inStr ); | ||
1251 | setExit(1); | ||
1252 | return; | ||
1253 | }; | ||
1254 | if ( inStr == NULL ) { | ||
1255 | fprintf ( stderr, "%s: Can't open input file %s: %s.\n", | ||
1256 | progName, inName, strerror(errno) ); | ||
1257 | setExit(1); | ||
1258 | return; | ||
1259 | }; | ||
1260 | break; | ||
1261 | |||
1262 | case SM_F2F: | ||
1263 | inStr = fopen ( inName, "rb" ); | ||
1264 | outStr = fopen_output_safely ( outName, "wb" ); | ||
1265 | if ( outStr == NULL) { | ||
1266 | fprintf ( stderr, "%s: Can't create output file %s: %s.\n", | ||
1267 | progName, outName, strerror(errno) ); | ||
1268 | if ( inStr != NULL ) fclose ( inStr ); | ||
1269 | setExit(1); | ||
1270 | return; | ||
1271 | } | ||
1272 | if ( inStr == NULL ) { | ||
1273 | fprintf ( stderr, "%s: Can't open input file %s: %s.\n", | ||
1274 | progName, inName, strerror(errno) ); | ||
1275 | if ( outStr != NULL ) fclose ( outStr ); | ||
1276 | setExit(1); | ||
1277 | return; | ||
1278 | }; | ||
1279 | break; | ||
1280 | |||
1281 | default: | ||
1282 | panic ( "compress: bad srcMode" ); | ||
1283 | break; | ||
1284 | } | ||
1285 | |||
1286 | if (verbosity >= 1) { | ||
1287 | fprintf ( stderr, " %s: ", inName ); | ||
1288 | pad ( inName ); | ||
1289 | fflush ( stderr ); | ||
1290 | } | ||
1291 | |||
1292 | /*--- Now the input and output handles are sane. Do the Biz. ---*/ | ||
1293 | outputHandleJustInCase = outStr; | ||
1294 | deleteOutputOnInterrupt = True; | ||
1295 | compressStream ( inStr, outStr ); | ||
1296 | outputHandleJustInCase = NULL; | ||
1297 | |||
1298 | /*--- If there was an I/O error, we won't get here. ---*/ | ||
1299 | if ( srcMode == SM_F2F ) { | ||
1300 | applySavedTimeInfoToOutputFile ( outName ); | ||
1301 | deleteOutputOnInterrupt = False; | ||
1302 | if ( !keepInputFiles ) { | ||
1303 | IntNative retVal = remove ( inName ); | ||
1304 | ERROR_IF_NOT_ZERO ( retVal ); | ||
1305 | } | ||
1306 | } | ||
1307 | |||
1308 | deleteOutputOnInterrupt = False; | ||
1309 | } | ||
1310 | |||
1311 | |||
1312 | /*---------------------------------------------*/ | ||
1313 | static | ||
1314 | void uncompress ( Char *name ) | ||
1315 | { | ||
1316 | FILE *inStr; | ||
1317 | FILE *outStr; | ||
1318 | Int32 n, i; | ||
1319 | Bool magicNumberOK; | ||
1320 | Bool cantGuess; | ||
1321 | struct MY_STAT statBuf; | ||
1322 | |||
1323 | deleteOutputOnInterrupt = False; | ||
1324 | |||
1325 | if (name == NULL && srcMode != SM_I2O) | ||
1326 | panic ( "uncompress: bad modes\n" ); | ||
1327 | |||
1328 | cantGuess = False; | ||
1329 | switch (srcMode) { | ||
1330 | case SM_I2O: | ||
1331 | copyFileName ( inName, (Char*)"(stdin)" ); | ||
1332 | copyFileName ( outName, (Char*)"(stdout)" ); | ||
1333 | break; | ||
1334 | case SM_F2F: | ||
1335 | copyFileName ( inName, name ); | ||
1336 | copyFileName ( outName, name ); | ||
1337 | for (i = 0; i < BZ_N_SUFFIX_PAIRS; i++) | ||
1338 | if (mapSuffix(outName,zSuffix[i],unzSuffix[i])) | ||
1339 | goto zzz; | ||
1340 | cantGuess = True; | ||
1341 | strcat ( outName, ".out" ); | ||
1342 | break; | ||
1343 | case SM_F2O: | ||
1344 | copyFileName ( inName, name ); | ||
1345 | copyFileName ( outName, (Char*)"(stdout)" ); | ||
1346 | break; | ||
1347 | } | ||
1348 | |||
1349 | zzz: | ||
1350 | if ( srcMode != SM_I2O && containsDubiousChars ( inName ) ) { | ||
1351 | if (noisy) | ||
1352 | fprintf ( stderr, "%s: There are no files matching `%s'.\n", | ||
1353 | progName, inName ); | ||
1354 | setExit(1); | ||
1355 | return; | ||
1356 | } | ||
1357 | if ( srcMode != SM_I2O && !fileExists ( inName ) ) { | ||
1358 | fprintf ( stderr, "%s: Can't open input file %s: %s.\n", | ||
1359 | progName, inName, strerror(errno) ); | ||
1360 | setExit(1); | ||
1361 | return; | ||
1362 | } | ||
1363 | if ( srcMode == SM_F2F || srcMode == SM_F2O ) { | ||
1364 | MY_STAT(inName, &statBuf); | ||
1365 | if ( MY_S_ISDIR(statBuf.st_mode) ) { | ||
1366 | fprintf( stderr, | ||
1367 | "%s: Input file %s is a directory.\n", | ||
1368 | progName,inName); | ||
1369 | setExit(1); | ||
1370 | return; | ||
1371 | } | ||
1372 | } | ||
1373 | if ( srcMode == SM_F2F && !forceOverwrite && notAStandardFile ( inName )) { | ||
1374 | if (noisy) | ||
1375 | fprintf ( stderr, "%s: Input file %s is not a normal file.\n", | ||
1376 | progName, inName ); | ||
1377 | setExit(1); | ||
1378 | return; | ||
1379 | } | ||
1380 | if ( /* srcMode == SM_F2F implied && */ cantGuess ) { | ||
1381 | if (noisy) | ||
1382 | fprintf ( stderr, | ||
1383 | "%s: Can't guess original name for %s -- using %s\n", | ||
1384 | progName, inName, outName ); | ||
1385 | /* just a warning, no return */ | ||
1386 | } | ||
1387 | if ( srcMode == SM_F2F && fileExists ( outName ) ) { | ||
1388 | if (forceOverwrite) { | ||
1389 | remove(outName); | ||
1390 | } else { | ||
1391 | fprintf ( stderr, "%s: Output file %s already exists.\n", | ||
1392 | progName, outName ); | ||
1393 | setExit(1); | ||
1394 | return; | ||
1395 | } | ||
1396 | } | ||
1397 | if ( srcMode == SM_F2F && !forceOverwrite && | ||
1398 | (n=countHardLinks ( inName ) ) > 0) { | ||
1399 | fprintf ( stderr, "%s: Input file %s has %d other link%s.\n", | ||
1400 | progName, inName, n, n > 1 ? "s" : "" ); | ||
1401 | setExit(1); | ||
1402 | return; | ||
1403 | } | ||
1404 | |||
1405 | if ( srcMode == SM_F2F ) { | ||
1406 | /* Save the file's meta-info before we open it. Doing it later | ||
1407 | means we mess up the access times. */ | ||
1408 | saveInputFileMetaInfo ( inName ); | ||
1409 | } | ||
1410 | |||
1411 | switch ( srcMode ) { | ||
1412 | |||
1413 | case SM_I2O: | ||
1414 | inStr = stdin; | ||
1415 | outStr = stdout; | ||
1416 | if ( isatty ( fileno ( stdin ) ) ) { | ||
1417 | fprintf ( stderr, | ||
1418 | "%s: I won't read compressed data from a terminal.\n", | ||
1419 | progName ); | ||
1420 | fprintf ( stderr, "%s: For help, type: `%s --help'.\n", | ||
1421 | progName, progName ); | ||
1422 | setExit(1); | ||
1423 | return; | ||
1424 | }; | ||
1425 | break; | ||
1426 | |||
1427 | case SM_F2O: | ||
1428 | inStr = fopen ( inName, "rb" ); | ||
1429 | outStr = stdout; | ||
1430 | if ( inStr == NULL ) { | ||
1431 | fprintf ( stderr, "%s: Can't open input file %s:%s.\n", | ||
1432 | progName, inName, strerror(errno) ); | ||
1433 | if ( inStr != NULL ) fclose ( inStr ); | ||
1434 | setExit(1); | ||
1435 | return; | ||
1436 | }; | ||
1437 | break; | ||
1438 | |||
1439 | case SM_F2F: | ||
1440 | inStr = fopen ( inName, "rb" ); | ||
1441 | outStr = fopen_output_safely ( outName, "wb" ); | ||
1442 | if ( outStr == NULL) { | ||
1443 | fprintf ( stderr, "%s: Can't create output file %s: %s.\n", | ||
1444 | progName, outName, strerror(errno) ); | ||
1445 | if ( inStr != NULL ) fclose ( inStr ); | ||
1446 | setExit(1); | ||
1447 | return; | ||
1448 | } | ||
1449 | if ( inStr == NULL ) { | ||
1450 | fprintf ( stderr, "%s: Can't open input file %s: %s.\n", | ||
1451 | progName, inName, strerror(errno) ); | ||
1452 | if ( outStr != NULL ) fclose ( outStr ); | ||
1453 | setExit(1); | ||
1454 | return; | ||
1455 | }; | ||
1456 | break; | ||
1457 | |||
1458 | default: | ||
1459 | panic ( "uncompress: bad srcMode" ); | ||
1460 | break; | ||
1461 | } | ||
1462 | |||
1463 | if (verbosity >= 1) { | ||
1464 | fprintf ( stderr, " %s: ", inName ); | ||
1465 | pad ( inName ); | ||
1466 | fflush ( stderr ); | ||
1467 | } | ||
1468 | |||
1469 | /*--- Now the input and output handles are sane. Do the Biz. ---*/ | ||
1470 | outputHandleJustInCase = outStr; | ||
1471 | deleteOutputOnInterrupt = True; | ||
1472 | magicNumberOK = uncompressStream ( inStr, outStr ); | ||
1473 | outputHandleJustInCase = NULL; | ||
1474 | |||
1475 | /*--- If there was an I/O error, we won't get here. ---*/ | ||
1476 | if ( magicNumberOK ) { | ||
1477 | if ( srcMode == SM_F2F ) { | ||
1478 | applySavedTimeInfoToOutputFile ( outName ); | ||
1479 | deleteOutputOnInterrupt = False; | ||
1480 | if ( !keepInputFiles ) { | ||
1481 | IntNative retVal = remove ( inName ); | ||
1482 | ERROR_IF_NOT_ZERO ( retVal ); | ||
1483 | } | ||
1484 | } | ||
1485 | } else { | ||
1486 | unzFailsExist = True; | ||
1487 | deleteOutputOnInterrupt = False; | ||
1488 | if ( srcMode == SM_F2F ) { | ||
1489 | IntNative retVal = remove ( outName ); | ||
1490 | ERROR_IF_NOT_ZERO ( retVal ); | ||
1491 | } | ||
1492 | } | ||
1493 | deleteOutputOnInterrupt = False; | ||
1494 | |||
1495 | if ( magicNumberOK ) { | ||
1496 | if (verbosity >= 1) | ||
1497 | fprintf ( stderr, "done\n" ); | ||
1498 | } else { | ||
1499 | setExit(2); | ||
1500 | if (verbosity >= 1) | ||
1501 | fprintf ( stderr, "not a bzip2 file.\n" ); else | ||
1502 | fprintf ( stderr, | ||
1503 | "%s: %s is not a bzip2 file.\n", | ||
1504 | progName, inName ); | ||
1505 | } | ||
1506 | |||
1507 | } | ||
1508 | |||
1509 | |||
1510 | /*---------------------------------------------*/ | ||
1511 | static | ||
1512 | void testf ( Char *name ) | ||
1513 | { | ||
1514 | FILE *inStr; | ||
1515 | Bool allOK; | ||
1516 | struct MY_STAT statBuf; | ||
1517 | |||
1518 | deleteOutputOnInterrupt = False; | ||
1519 | |||
1520 | if (name == NULL && srcMode != SM_I2O) | ||
1521 | panic ( "testf: bad modes\n" ); | ||
1522 | |||
1523 | copyFileName ( outName, (Char*)"(none)" ); | ||
1524 | switch (srcMode) { | ||
1525 | case SM_I2O: copyFileName ( inName, (Char*)"(stdin)" ); break; | ||
1526 | case SM_F2F: copyFileName ( inName, name ); break; | ||
1527 | case SM_F2O: copyFileName ( inName, name ); break; | ||
1528 | } | ||
1529 | |||
1530 | if ( srcMode != SM_I2O && containsDubiousChars ( inName ) ) { | ||
1531 | if (noisy) | ||
1532 | fprintf ( stderr, "%s: There are no files matching `%s'.\n", | ||
1533 | progName, inName ); | ||
1534 | setExit(1); | ||
1535 | return; | ||
1536 | } | ||
1537 | if ( srcMode != SM_I2O && !fileExists ( inName ) ) { | ||
1538 | fprintf ( stderr, "%s: Can't open input %s: %s.\n", | ||
1539 | progName, inName, strerror(errno) ); | ||
1540 | setExit(1); | ||
1541 | return; | ||
1542 | } | ||
1543 | if ( srcMode != SM_I2O ) { | ||
1544 | MY_STAT(inName, &statBuf); | ||
1545 | if ( MY_S_ISDIR(statBuf.st_mode) ) { | ||
1546 | fprintf( stderr, | ||
1547 | "%s: Input file %s is a directory.\n", | ||
1548 | progName,inName); | ||
1549 | setExit(1); | ||
1550 | return; | ||
1551 | } | ||
1552 | } | ||
1553 | |||
1554 | switch ( srcMode ) { | ||
1555 | |||
1556 | case SM_I2O: | ||
1557 | if ( isatty ( fileno ( stdin ) ) ) { | ||
1558 | fprintf ( stderr, | ||
1559 | "%s: I won't read compressed data from a terminal.\n", | ||
1560 | progName ); | ||
1561 | fprintf ( stderr, "%s: For help, type: `%s --help'.\n", | ||
1562 | progName, progName ); | ||
1563 | setExit(1); | ||
1564 | return; | ||
1565 | }; | ||
1566 | inStr = stdin; | ||
1567 | break; | ||
1568 | |||
1569 | case SM_F2O: case SM_F2F: | ||
1570 | inStr = fopen ( inName, "rb" ); | ||
1571 | if ( inStr == NULL ) { | ||
1572 | fprintf ( stderr, "%s: Can't open input file %s:%s.\n", | ||
1573 | progName, inName, strerror(errno) ); | ||
1574 | setExit(1); | ||
1575 | return; | ||
1576 | }; | ||
1577 | break; | ||
1578 | |||
1579 | default: | ||
1580 | panic ( "testf: bad srcMode" ); | ||
1581 | break; | ||
1582 | } | ||
1583 | |||
1584 | if (verbosity >= 1) { | ||
1585 | fprintf ( stderr, " %s: ", inName ); | ||
1586 | pad ( inName ); | ||
1587 | fflush ( stderr ); | ||
1588 | } | ||
1589 | |||
1590 | /*--- Now the input handle is sane. Do the Biz. ---*/ | ||
1591 | outputHandleJustInCase = NULL; | ||
1592 | allOK = testStream ( inStr ); | ||
1593 | |||
1594 | if (allOK && verbosity >= 1) fprintf ( stderr, "ok\n" ); | ||
1595 | if (!allOK) testFailsExist = True; | ||
1596 | } | ||
1597 | |||
1598 | |||
1599 | /*---------------------------------------------*/ | ||
1600 | static | ||
1601 | void license ( void ) | ||
1602 | { | ||
1603 | fprintf ( stderr, | ||
1604 | |||
1605 | "bzip2, a block-sorting file compressor. " | ||
1606 | "Version %s.\n" | ||
1607 | " \n" | ||
1608 | " Copyright (C) 1996-2010 by Julian Seward.\n" | ||
1609 | " \n" | ||
1610 | " This program is free software; you can redistribute it and/or modify\n" | ||
1611 | " it under the terms set out in the LICENSE file, which is included\n" | ||
1612 | " in the bzip2-1.0.6 source distribution.\n" | ||
1613 | " \n" | ||
1614 | " This program is distributed in the hope that it will be useful,\n" | ||
1615 | " but WITHOUT ANY WARRANTY; without even the implied warranty of\n" | ||
1616 | " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" | ||
1617 | " LICENSE file for more details.\n" | ||
1618 | " \n", | ||
1619 | BZ2_bzlibVersion() | ||
1620 | ); | ||
1621 | } | ||
1622 | |||
1623 | |||
1624 | /*---------------------------------------------*/ | ||
1625 | static | ||
1626 | void usage ( Char *fullProgName ) | ||
1627 | { | ||
1628 | fprintf ( | ||
1629 | stderr, | ||
1630 | "bzip2, a block-sorting file compressor. " | ||
1631 | "Version %s.\n" | ||
1632 | "\n usage: %s [flags and input files in any order]\n" | ||
1633 | "\n" | ||
1634 | " -h --help print this message\n" | ||
1635 | " -d --decompress force decompression\n" | ||
1636 | " -z --compress force compression\n" | ||
1637 | " -k --keep keep (don't delete) input files\n" | ||
1638 | " -f --force overwrite existing output files\n" | ||
1639 | " -t --test test compressed file integrity\n" | ||
1640 | " -c --stdout output to standard out\n" | ||
1641 | " -q --quiet suppress noncritical error messages\n" | ||
1642 | " -v --verbose be verbose (a 2nd -v gives more)\n" | ||
1643 | " -L --license display software version & license\n" | ||
1644 | " -V --version display software version & license\n" | ||
1645 | " -s --small use less memory (at most 2500k)\n" | ||
1646 | " -1 .. -9 set block size to 100k .. 900k\n" | ||
1647 | " --fast alias for -1\n" | ||
1648 | " --best alias for -9\n" | ||
1649 | "\n" | ||
1650 | " If invoked as `bzip2', default action is to compress.\n" | ||
1651 | " as `bunzip2', default action is to decompress.\n" | ||
1652 | " as `bzcat', default action is to decompress to stdout.\n" | ||
1653 | "\n" | ||
1654 | " If no file names are given, bzip2 compresses or decompresses\n" | ||
1655 | " from standard input to standard output. You can combine\n" | ||
1656 | " short flags, so `-v -4' means the same as -v4 or -4v, &c.\n" | ||
1657 | # if BZ_UNIX | ||
1658 | "\n" | ||
1659 | # endif | ||
1660 | , | ||
1661 | |||
1662 | BZ2_bzlibVersion(), | ||
1663 | fullProgName | ||
1664 | ); | ||
1665 | } | ||
1666 | |||
1667 | |||
1668 | /*---------------------------------------------*/ | ||
1669 | static | ||
1670 | void redundant ( Char* flag ) | ||
1671 | { | ||
1672 | fprintf ( | ||
1673 | stderr, | ||
1674 | "%s: %s is redundant in versions 0.9.5 and above\n", | ||
1675 | progName, flag ); | ||
1676 | } | ||
1677 | |||
1678 | |||
1679 | /*---------------------------------------------*/ | ||
1680 | /*-- | ||
1681 | All the garbage from here to main() is purely to | ||
1682 | implement a linked list of command-line arguments, | ||
1683 | into which main() copies argv[1 .. argc-1]. | ||
1684 | |||
1685 | The purpose of this exercise is to facilitate | ||
1686 | the expansion of wildcard characters * and ? in | ||
1687 | filenames for OSs which don't know how to do it | ||
1688 | themselves, like MSDOS, Windows 95 and NT. | ||
1689 | |||
1690 | The actual Dirty Work is done by the platform- | ||
1691 | specific macro APPEND_FILESPEC. | ||
1692 | --*/ | ||
1693 | |||
1694 | typedef | ||
1695 | struct zzzz { | ||
1696 | Char *name; | ||
1697 | struct zzzz *link; | ||
1698 | } | ||
1699 | Cell; | ||
1700 | |||
1701 | |||
1702 | /*---------------------------------------------*/ | ||
1703 | static | ||
1704 | void *myMalloc ( Int32 n ) | ||
1705 | { | ||
1706 | void* p; | ||
1707 | |||
1708 | p = malloc ( (size_t)n ); | ||
1709 | if (p == NULL) outOfMemory (); | ||
1710 | return p; | ||
1711 | } | ||
1712 | |||
1713 | |||
1714 | /*---------------------------------------------*/ | ||
1715 | static | ||
1716 | Cell *mkCell ( void ) | ||
1717 | { | ||
1718 | Cell *c; | ||
1719 | |||
1720 | c = (Cell*) myMalloc ( sizeof ( Cell ) ); | ||
1721 | c->name = NULL; | ||
1722 | c->link = NULL; | ||
1723 | return c; | ||
1724 | } | ||
1725 | |||
1726 | |||
1727 | /*---------------------------------------------*/ | ||
1728 | static | ||
1729 | Cell *snocString ( Cell *root, Char *name ) | ||
1730 | { | ||
1731 | if (root == NULL) { | ||
1732 | Cell *tmp = mkCell(); | ||
1733 | tmp->name = (Char*) myMalloc ( 5 + strlen(name) ); | ||
1734 | strcpy ( tmp->name, name ); | ||
1735 | return tmp; | ||
1736 | } else { | ||
1737 | Cell *tmp = root; | ||
1738 | while (tmp->link != NULL) tmp = tmp->link; | ||
1739 | tmp->link = snocString ( tmp->link, name ); | ||
1740 | return root; | ||
1741 | } | ||
1742 | } | ||
1743 | |||
1744 | |||
1745 | /*---------------------------------------------*/ | ||
1746 | static | ||
1747 | void addFlagsFromEnvVar ( Cell** argList, Char* varName ) | ||
1748 | { | ||
1749 | Int32 i, j, k; | ||
1750 | Char *envbase, *p; | ||
1751 | |||
1752 | envbase = getenv(varName); | ||
1753 | if (envbase != NULL) { | ||
1754 | p = envbase; | ||
1755 | i = 0; | ||
1756 | while (True) { | ||
1757 | if (p[i] == 0) break; | ||
1758 | p += i; | ||
1759 | i = 0; | ||
1760 | while (isspace((Int32)(p[0]))) p++; | ||
1761 | while (p[i] != 0 && !isspace((Int32)(p[i]))) i++; | ||
1762 | if (i > 0) { | ||
1763 | k = i; if (k > FILE_NAME_LEN-10) k = FILE_NAME_LEN-10; | ||
1764 | for (j = 0; j < k; j++) tmpName[j] = p[j]; | ||
1765 | tmpName[k] = 0; | ||
1766 | APPEND_FLAG(*argList, tmpName); | ||
1767 | } | ||
1768 | } | ||
1769 | } | ||
1770 | } | ||
1771 | |||
1772 | |||
1773 | /*---------------------------------------------*/ | ||
1774 | #define ISFLAG(s) (strcmp(aa->name, (s))==0) | ||
1775 | |||
1776 | IntNative main ( IntNative argc, Char *argv[] ) | ||
1777 | { | ||
1778 | Int32 i, j; | ||
1779 | Char *tmp; | ||
1780 | Cell *argList; | ||
1781 | Cell *aa; | ||
1782 | Bool decode; | ||
1783 | |||
1784 | /*-- Be really really really paranoid :-) --*/ | ||
1785 | if (sizeof(Int32) != 4 || sizeof(UInt32) != 4 || | ||
1786 | sizeof(Int16) != 2 || sizeof(UInt16) != 2 || | ||
1787 | sizeof(Char) != 1 || sizeof(UChar) != 1) | ||
1788 | configError(); | ||
1789 | |||
1790 | /*-- Initialise --*/ | ||
1791 | outputHandleJustInCase = NULL; | ||
1792 | smallMode = False; | ||
1793 | keepInputFiles = False; | ||
1794 | forceOverwrite = False; | ||
1795 | noisy = True; | ||
1796 | verbosity = 0; | ||
1797 | blockSize100k = 9; | ||
1798 | testFailsExist = False; | ||
1799 | unzFailsExist = False; | ||
1800 | numFileNames = 0; | ||
1801 | numFilesProcessed = 0; | ||
1802 | workFactor = 30; | ||
1803 | deleteOutputOnInterrupt = False; | ||
1804 | exitValue = 0; | ||
1805 | i = j = 0; /* avoid bogus warning from egcs-1.1.X */ | ||
1806 | |||
1807 | /*-- Set up signal handlers for mem access errors --*/ | ||
1808 | signal (SIGSEGV, mySIGSEGVorSIGBUScatcher); | ||
1809 | # if BZ_UNIX | ||
1810 | # ifndef __DJGPP__ | ||
1811 | signal (SIGBUS, mySIGSEGVorSIGBUScatcher); | ||
1812 | # endif | ||
1813 | # endif | ||
1814 | |||
1815 | copyFileName ( inName, (Char*)"(none)" ); | ||
1816 | copyFileName ( outName, (Char*)"(none)" ); | ||
1817 | |||
1818 | copyFileName ( progNameReally, argv[0] ); | ||
1819 | progName = &progNameReally[0]; | ||
1820 | for (tmp = &progNameReally[0]; *tmp != '\0'; tmp++) | ||
1821 | if (*tmp == PATH_SEP) progName = tmp + 1; | ||
1822 | |||
1823 | |||
1824 | /*-- Copy flags from env var BZIP2, and | ||
1825 | expand filename wildcards in arg list. | ||
1826 | --*/ | ||
1827 | argList = NULL; | ||
1828 | addFlagsFromEnvVar ( &argList, (Char*)"BZIP2" ); | ||
1829 | addFlagsFromEnvVar ( &argList, (Char*)"BZIP" ); | ||
1830 | for (i = 1; i <= argc-1; i++) | ||
1831 | APPEND_FILESPEC(argList, argv[i]); | ||
1832 | |||
1833 | |||
1834 | /*-- Find the length of the longest filename --*/ | ||
1835 | longestFileName = 7; | ||
1836 | numFileNames = 0; | ||
1837 | decode = True; | ||
1838 | for (aa = argList; aa != NULL; aa = aa->link) { | ||
1839 | if (ISFLAG("--")) { decode = False; continue; } | ||
1840 | if (aa->name[0] == '-' && decode) continue; | ||
1841 | numFileNames++; | ||
1842 | if (longestFileName < (Int32)strlen(aa->name) ) | ||
1843 | longestFileName = (Int32)strlen(aa->name); | ||
1844 | } | ||
1845 | |||
1846 | |||
1847 | /*-- Determine source modes; flag handling may change this too. --*/ | ||
1848 | if (numFileNames == 0) | ||
1849 | srcMode = SM_I2O; else srcMode = SM_F2F; | ||
1850 | |||
1851 | |||
1852 | /*-- Determine what to do (compress/uncompress/test/cat). --*/ | ||
1853 | /*-- Note that subsequent flag handling may change this. --*/ | ||
1854 | opMode = OM_Z; | ||
1855 | |||
1856 | if ( (strstr ( progName, "unzip" ) != 0) || | ||
1857 | (strstr ( progName, "UNZIP" ) != 0) ) | ||
1858 | opMode = OM_UNZ; | ||
1859 | |||
1860 | if ( (strstr ( progName, "z2cat" ) != 0) || | ||
1861 | (strstr ( progName, "Z2CAT" ) != 0) || | ||
1862 | (strstr ( progName, "zcat" ) != 0) || | ||
1863 | (strstr ( progName, "ZCAT" ) != 0) ) { | ||
1864 | opMode = OM_UNZ; | ||
1865 | srcMode = (numFileNames == 0) ? SM_I2O : SM_F2O; | ||
1866 | } | ||
1867 | |||
1868 | |||
1869 | /*-- Look at the flags. --*/ | ||
1870 | for (aa = argList; aa != NULL; aa = aa->link) { | ||
1871 | if (ISFLAG("--")) break; | ||
1872 | if (aa->name[0] == '-' && aa->name[1] != '-') { | ||
1873 | for (j = 1; aa->name[j] != '\0'; j++) { | ||
1874 | switch (aa->name[j]) { | ||
1875 | case 'c': srcMode = SM_F2O; break; | ||
1876 | case 'd': opMode = OM_UNZ; break; | ||
1877 | case 'z': opMode = OM_Z; break; | ||
1878 | case 'f': forceOverwrite = True; break; | ||
1879 | case 't': opMode = OM_TEST; break; | ||
1880 | case 'k': keepInputFiles = True; break; | ||
1881 | case 's': smallMode = True; break; | ||
1882 | case 'q': noisy = False; break; | ||
1883 | case '1': blockSize100k = 1; break; | ||
1884 | case '2': blockSize100k = 2; break; | ||
1885 | case '3': blockSize100k = 3; break; | ||
1886 | case '4': blockSize100k = 4; break; | ||
1887 | case '5': blockSize100k = 5; break; | ||
1888 | case '6': blockSize100k = 6; break; | ||
1889 | case '7': blockSize100k = 7; break; | ||
1890 | case '8': blockSize100k = 8; break; | ||
1891 | case '9': blockSize100k = 9; break; | ||
1892 | case 'V': | ||
1893 | case 'L': license(); break; | ||
1894 | case 'v': verbosity++; break; | ||
1895 | case 'h': usage ( progName ); | ||
1896 | exit ( 0 ); | ||
1897 | break; | ||
1898 | default: fprintf ( stderr, "%s: Bad flag `%s'\n", | ||
1899 | progName, aa->name ); | ||
1900 | usage ( progName ); | ||
1901 | exit ( 1 ); | ||
1902 | break; | ||
1903 | } | ||
1904 | } | ||
1905 | } | ||
1906 | } | ||
1907 | |||
1908 | /*-- And again ... --*/ | ||
1909 | for (aa = argList; aa != NULL; aa = aa->link) { | ||
1910 | if (ISFLAG("--")) break; | ||
1911 | if (ISFLAG("--stdout")) srcMode = SM_F2O; else | ||
1912 | if (ISFLAG("--decompress")) opMode = OM_UNZ; else | ||
1913 | if (ISFLAG("--compress")) opMode = OM_Z; else | ||
1914 | if (ISFLAG("--force")) forceOverwrite = True; else | ||
1915 | if (ISFLAG("--test")) opMode = OM_TEST; else | ||
1916 | if (ISFLAG("--keep")) keepInputFiles = True; else | ||
1917 | if (ISFLAG("--small")) smallMode = True; else | ||
1918 | if (ISFLAG("--quiet")) noisy = False; else | ||
1919 | if (ISFLAG("--version")) license(); else | ||
1920 | if (ISFLAG("--license")) license(); else | ||
1921 | if (ISFLAG("--exponential")) workFactor = 1; else | ||
1922 | if (ISFLAG("--repetitive-best")) redundant(aa->name); else | ||
1923 | if (ISFLAG("--repetitive-fast")) redundant(aa->name); else | ||
1924 | if (ISFLAG("--fast")) blockSize100k = 1; else | ||
1925 | if (ISFLAG("--best")) blockSize100k = 9; else | ||
1926 | if (ISFLAG("--verbose")) verbosity++; else | ||
1927 | if (ISFLAG("--help")) { usage ( progName ); exit ( 0 ); } | ||
1928 | else | ||
1929 | if (strncmp ( aa->name, "--", 2) == 0) { | ||
1930 | fprintf ( stderr, "%s: Bad flag `%s'\n", progName, aa->name ); | ||
1931 | usage ( progName ); | ||
1932 | exit ( 1 ); | ||
1933 | } | ||
1934 | } | ||
1935 | |||
1936 | if (verbosity > 4) verbosity = 4; | ||
1937 | if (opMode == OM_Z && smallMode && blockSize100k > 2) | ||
1938 | blockSize100k = 2; | ||
1939 | |||
1940 | if (opMode == OM_TEST && srcMode == SM_F2O) { | ||
1941 | fprintf ( stderr, "%s: -c and -t cannot be used together.\n", | ||
1942 | progName ); | ||
1943 | exit ( 1 ); | ||
1944 | } | ||
1945 | |||
1946 | if (srcMode == SM_F2O && numFileNames == 0) | ||
1947 | srcMode = SM_I2O; | ||
1948 | |||
1949 | if (opMode != OM_Z) blockSize100k = 0; | ||
1950 | |||
1951 | if (srcMode == SM_F2F) { | ||
1952 | signal (SIGINT, mySignalCatcher); | ||
1953 | signal (SIGTERM, mySignalCatcher); | ||
1954 | # if BZ_UNIX | ||
1955 | signal (SIGHUP, mySignalCatcher); | ||
1956 | # endif | ||
1957 | } | ||
1958 | |||
1959 | if (opMode == OM_Z) { | ||
1960 | if (srcMode == SM_I2O) { | ||
1961 | compress ( NULL ); | ||
1962 | } else { | ||
1963 | decode = True; | ||
1964 | for (aa = argList; aa != NULL; aa = aa->link) { | ||
1965 | if (ISFLAG("--")) { decode = False; continue; } | ||
1966 | if (aa->name[0] == '-' && decode) continue; | ||
1967 | numFilesProcessed++; | ||
1968 | compress ( aa->name ); | ||
1969 | } | ||
1970 | } | ||
1971 | } | ||
1972 | else | ||
1973 | |||
1974 | if (opMode == OM_UNZ) { | ||
1975 | unzFailsExist = False; | ||
1976 | if (srcMode == SM_I2O) { | ||
1977 | uncompress ( NULL ); | ||
1978 | } else { | ||
1979 | decode = True; | ||
1980 | for (aa = argList; aa != NULL; aa = aa->link) { | ||
1981 | if (ISFLAG("--")) { decode = False; continue; } | ||
1982 | if (aa->name[0] == '-' && decode) continue; | ||
1983 | numFilesProcessed++; | ||
1984 | uncompress ( aa->name ); | ||
1985 | } | ||
1986 | } | ||
1987 | if (unzFailsExist) { | ||
1988 | setExit(2); | ||
1989 | exit(exitValue); | ||
1990 | } | ||
1991 | } | ||
1992 | |||
1993 | else { | ||
1994 | testFailsExist = False; | ||
1995 | if (srcMode == SM_I2O) { | ||
1996 | testf ( NULL ); | ||
1997 | } else { | ||
1998 | decode = True; | ||
1999 | for (aa = argList; aa != NULL; aa = aa->link) { | ||
2000 | if (ISFLAG("--")) { decode = False; continue; } | ||
2001 | if (aa->name[0] == '-' && decode) continue; | ||
2002 | numFilesProcessed++; | ||
2003 | testf ( aa->name ); | ||
2004 | } | ||
2005 | } | ||
2006 | if (testFailsExist && noisy) { | ||
2007 | fprintf ( stderr, | ||
2008 | "\n" | ||
2009 | "You can use the `bzip2recover' program to attempt to recover\n" | ||
2010 | "data from undamaged sections of corrupted files.\n\n" | ||
2011 | ); | ||
2012 | setExit(2); | ||
2013 | exit(exitValue); | ||
2014 | } | ||
2015 | } | ||
2016 | |||
2017 | /* Free the argument list memory to mollify leak detectors | ||
2018 | (eg) Purify, Checker. Serves no other useful purpose. | ||
2019 | */ | ||
2020 | aa = argList; | ||
2021 | while (aa != NULL) { | ||
2022 | Cell* aa2 = aa->link; | ||
2023 | if (aa->name != NULL) free(aa->name); | ||
2024 | free(aa); | ||
2025 | aa = aa2; | ||
2026 | } | ||
2027 | |||
2028 | return exitValue; | ||
2029 | } | ||
2030 | |||
2031 | |||
2032 | /*-----------------------------------------------------------*/ | ||
2033 | /*--- end bzip2.c ---*/ | ||
2034 | /*-----------------------------------------------------------*/ | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzip2.txt b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzip2.txt new file mode 100644 index 0000000..d2deb39 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzip2.txt | |||
@@ -0,0 +1,391 @@ | |||
1 | |||
2 | NAME | ||
3 | bzip2, bunzip2 - a block-sorting file compressor, v1.0.6 | ||
4 | bzcat - decompresses files to stdout | ||
5 | bzip2recover - recovers data from damaged bzip2 files | ||
6 | |||
7 | |||
8 | SYNOPSIS | ||
9 | bzip2 [ -cdfkqstvzVL123456789 ] [ filenames ... ] | ||
10 | bunzip2 [ -fkvsVL ] [ filenames ... ] | ||
11 | bzcat [ -s ] [ filenames ... ] | ||
12 | bzip2recover filename | ||
13 | |||
14 | |||
15 | DESCRIPTION | ||
16 | bzip2 compresses files using the Burrows-Wheeler block | ||
17 | sorting text compression algorithm, and Huffman coding. | ||
18 | Compression is generally considerably better than that | ||
19 | achieved by more conventional LZ77/LZ78-based compressors, | ||
20 | and approaches the performance of the PPM family of sta- | ||
21 | tistical compressors. | ||
22 | |||
23 | The command-line options are deliberately very similar to | ||
24 | those of GNU gzip, but they are not identical. | ||
25 | |||
26 | bzip2 expects a list of file names to accompany the com- | ||
27 | mand-line flags. Each file is replaced by a compressed | ||
28 | version of itself, with the name "original_name.bz2". | ||
29 | Each compressed file has the same modification date, per- | ||
30 | missions, and, when possible, ownership as the correspond- | ||
31 | ing original, so that these properties can be correctly | ||
32 | restored at decompression time. File name handling is | ||
33 | naive in the sense that there is no mechanism for preserv- | ||
34 | ing original file names, permissions, ownerships or dates | ||
35 | in filesystems which lack these concepts, or have serious | ||
36 | file name length restrictions, such as MS-DOS. | ||
37 | |||
38 | bzip2 and bunzip2 will by default not overwrite existing | ||
39 | files. If you want this to happen, specify the -f flag. | ||
40 | |||
41 | If no file names are specified, bzip2 compresses from | ||
42 | standard input to standard output. In this case, bzip2 | ||
43 | will decline to write compressed output to a terminal, as | ||
44 | this would be entirely incomprehensible and therefore | ||
45 | pointless. | ||
46 | |||
47 | bunzip2 (or bzip2 -d) decompresses all specified files. | ||
48 | Files which were not created by bzip2 will be detected and | ||
49 | ignored, and a warning issued. bzip2 attempts to guess | ||
50 | the filename for the decompressed file from that of the | ||
51 | compressed file as follows: | ||
52 | |||
53 | filename.bz2 becomes filename | ||
54 | filename.bz becomes filename | ||
55 | filename.tbz2 becomes filename.tar | ||
56 | filename.tbz becomes filename.tar | ||
57 | anyothername becomes anyothername.out | ||
58 | |||
59 | If the file does not end in one of the recognised endings, | ||
60 | .bz2, .bz, .tbz2 or .tbz, bzip2 complains that it cannot | ||
61 | guess the name of the original file, and uses the original | ||
62 | name with .out appended. | ||
63 | |||
64 | As with compression, supplying no filenames causes decom- | ||
65 | pression from standard input to standard output. | ||
66 | |||
67 | bunzip2 will correctly decompress a file which is the con- | ||
68 | catenation of two or more compressed files. The result is | ||
69 | the concatenation of the corresponding uncompressed files. | ||
70 | Integrity testing (-t) of concatenated compressed files is | ||
71 | also supported. | ||
72 | |||
73 | You can also compress or decompress files to the standard | ||
74 | output by giving the -c flag. Multiple files may be com- | ||
75 | pressed and decompressed like this. The resulting outputs | ||
76 | are fed sequentially to stdout. Compression of multiple | ||
77 | files in this manner generates a stream containing multi- | ||
78 | ple compressed file representations. Such a stream can be | ||
79 | decompressed correctly only by bzip2 version 0.9.0 or | ||
80 | later. Earlier versions of bzip2 will stop after decom- | ||
81 | pressing the first file in the stream. | ||
82 | |||
83 | bzcat (or bzip2 -dc) decompresses all specified files to | ||
84 | the standard output. | ||
85 | |||
86 | bzip2 will read arguments from the environment variables | ||
87 | BZIP2 and BZIP, in that order, and will process them | ||
88 | before any arguments read from the command line. This | ||
89 | gives a convenient way to supply default arguments. | ||
90 | |||
91 | Compression is always performed, even if the compressed | ||
92 | file is slightly larger than the original. Files of less | ||
93 | than about one hundred bytes tend to get larger, since the | ||
94 | compression mechanism has a constant overhead in the | ||
95 | region of 50 bytes. Random data (including the output of | ||
96 | most file compressors) is coded at about 8.05 bits per | ||
97 | byte, giving an expansion of around 0.5%. | ||
98 | |||
99 | As a self-check for your protection, bzip2 uses 32-bit | ||
100 | CRCs to make sure that the decompressed version of a file | ||
101 | is identical to the original. This guards against corrup- | ||
102 | tion of the compressed data, and against undetected bugs | ||
103 | in bzip2 (hopefully very unlikely). The chances of data | ||
104 | corruption going undetected is microscopic, about one | ||
105 | chance in four billion for each file processed. Be aware, | ||
106 | though, that the check occurs upon decompression, so it | ||
107 | can only tell you that something is wrong. It can't help | ||
108 | you recover the original uncompressed data. You can use | ||
109 | bzip2recover to try to recover data from damaged files. | ||
110 | |||
111 | Return values: 0 for a normal exit, 1 for environmental | ||
112 | problems (file not found, invalid flags, I/O errors, &c), | ||
113 | 2 to indicate a corrupt compressed file, 3 for an internal | ||
114 | consistency error (eg, bug) which caused bzip2 to panic. | ||
115 | |||
116 | |||
117 | OPTIONS | ||
118 | -c --stdout | ||
119 | Compress or decompress to standard output. | ||
120 | |||
121 | -d --decompress | ||
122 | Force decompression. bzip2, bunzip2 and bzcat are | ||
123 | really the same program, and the decision about | ||
124 | what actions to take is done on the basis of which | ||
125 | name is used. This flag overrides that mechanism, | ||
126 | and forces bzip2 to decompress. | ||
127 | |||
128 | -z --compress | ||
129 | The complement to -d: forces compression, | ||
130 | regardless of the invocation name. | ||
131 | |||
132 | -t --test | ||
133 | Check integrity of the specified file(s), but don't | ||
134 | decompress them. This really performs a trial | ||
135 | decompression and throws away the result. | ||
136 | |||
137 | -f --force | ||
138 | Force overwrite of output files. Normally, bzip2 | ||
139 | will not overwrite existing output files. Also | ||
140 | forces bzip2 to break hard links to files, which it | ||
141 | otherwise wouldn't do. | ||
142 | |||
143 | bzip2 normally declines to decompress files which | ||
144 | don't have the correct magic header bytes. If | ||
145 | forced (-f), however, it will pass such files | ||
146 | through unmodified. This is how GNU gzip behaves. | ||
147 | |||
148 | -k --keep | ||
149 | Keep (don't delete) input files during compression | ||
150 | or decompression. | ||
151 | |||
152 | -s --small | ||
153 | Reduce memory usage, for compression, decompression | ||
154 | and testing. Files are decompressed and tested | ||
155 | using a modified algorithm which only requires 2.5 | ||
156 | bytes per block byte. This means any file can be | ||
157 | decompressed in 2300k of memory, albeit at about | ||
158 | half the normal speed. | ||
159 | |||
160 | During compression, -s selects a block size of | ||
161 | 200k, which limits memory use to around the same | ||
162 | figure, at the expense of your compression ratio. | ||
163 | In short, if your machine is low on memory (8 | ||
164 | megabytes or less), use -s for everything. See | ||
165 | MEMORY MANAGEMENT below. | ||
166 | |||
167 | -q --quiet | ||
168 | Suppress non-essential warning messages. Messages | ||
169 | pertaining to I/O errors and other critical events | ||
170 | will not be suppressed. | ||
171 | |||
172 | -v --verbose | ||
173 | Verbose mode -- show the compression ratio for each | ||
174 | file processed. Further -v's increase the ver- | ||
175 | bosity level, spewing out lots of information which | ||
176 | is primarily of interest for diagnostic purposes. | ||
177 | |||
178 | -L --license -V --version | ||
179 | Display the software version, license terms and | ||
180 | conditions. | ||
181 | |||
182 | -1 (or --fast) to -9 (or --best) | ||
183 | Set the block size to 100 k, 200 k .. 900 k when | ||
184 | compressing. Has no effect when decompressing. | ||
185 | See MEMORY MANAGEMENT below. The --fast and --best | ||
186 | aliases are primarily for GNU gzip compatibility. | ||
187 | In particular, --fast doesn't make things signifi- | ||
188 | cantly faster. And --best merely selects the | ||
189 | default behaviour. | ||
190 | |||
191 | -- Treats all subsequent arguments as file names, even | ||
192 | if they start with a dash. This is so you can han- | ||
193 | dle files with names beginning with a dash, for | ||
194 | example: bzip2 -- -myfilename. | ||
195 | |||
196 | --repetitive-fast --repetitive-best | ||
197 | These flags are redundant in versions 0.9.5 and | ||
198 | above. They provided some coarse control over the | ||
199 | behaviour of the sorting algorithm in earlier ver- | ||
200 | sions, which was sometimes useful. 0.9.5 and above | ||
201 | have an improved algorithm which renders these | ||
202 | flags irrelevant. | ||
203 | |||
204 | |||
205 | MEMORY MANAGEMENT | ||
206 | bzip2 compresses large files in blocks. The block size | ||
207 | affects both the compression ratio achieved, and the | ||
208 | amount of memory needed for compression and decompression. | ||
209 | The flags -1 through -9 specify the block size to be | ||
210 | 100,000 bytes through 900,000 bytes (the default) respec- | ||
211 | tively. At decompression time, the block size used for | ||
212 | compression is read from the header of the compressed | ||
213 | file, and bunzip2 then allocates itself just enough memory | ||
214 | to decompress the file. Since block sizes are stored in | ||
215 | compressed files, it follows that the flags -1 to -9 are | ||
216 | irrelevant to and so ignored during decompression. | ||
217 | |||
218 | Compression and decompression requirements, in bytes, can | ||
219 | be estimated as: | ||
220 | |||
221 | Compression: 400k + ( 8 x block size ) | ||
222 | |||
223 | Decompression: 100k + ( 4 x block size ), or | ||
224 | 100k + ( 2.5 x block size ) | ||
225 | |||
226 | Larger block sizes give rapidly diminishing marginal | ||
227 | returns. Most of the compression comes from the first two | ||
228 | or three hundred k of block size, a fact worth bearing in | ||
229 | mind when using bzip2 on small machines. It is also | ||
230 | important to appreciate that the decompression memory | ||
231 | requirement is set at compression time by the choice of | ||
232 | block size. | ||
233 | |||
234 | For files compressed with the default 900k block size, | ||
235 | bunzip2 will require about 3700 kbytes to decompress. To | ||
236 | support decompression of any file on a 4 megabyte machine, | ||
237 | bunzip2 has an option to decompress using approximately | ||
238 | half this amount of memory, about 2300 kbytes. Decompres- | ||
239 | sion speed is also halved, so you should use this option | ||
240 | only where necessary. The relevant flag is -s. | ||
241 | |||
242 | In general, try and use the largest block size memory con- | ||
243 | straints allow, since that maximises the compression | ||
244 | achieved. Compression and decompression speed are virtu- | ||
245 | ally unaffected by block size. | ||
246 | |||
247 | Another significant point applies to files which fit in a | ||
248 | single block -- that means most files you'd encounter | ||
249 | using a large block size. The amount of real memory | ||
250 | touched is proportional to the size of the file, since the | ||
251 | file is smaller than a block. For example, compressing a | ||
252 | file 20,000 bytes long with the flag -9 will cause the | ||
253 | compressor to allocate around 7600k of memory, but only | ||
254 | touch 400k + 20000 * 8 = 560 kbytes of it. Similarly, the | ||
255 | decompressor will allocate 3700k but only touch 100k + | ||
256 | 20000 * 4 = 180 kbytes. | ||
257 | |||
258 | Here is a table which summarises the maximum memory usage | ||
259 | for different block sizes. Also recorded is the total | ||
260 | compressed size for 14 files of the Calgary Text Compres- | ||
261 | sion Corpus totalling 3,141,622 bytes. This column gives | ||
262 | some feel for how compression varies with block size. | ||
263 | These figures tend to understate the advantage of larger | ||
264 | block sizes for larger files, since the Corpus is domi- | ||
265 | nated by smaller files. | ||
266 | |||
267 | Compress Decompress Decompress Corpus | ||
268 | Flag usage usage -s usage Size | ||
269 | |||
270 | -1 1200k 500k 350k 914704 | ||
271 | -2 2000k 900k 600k 877703 | ||
272 | -3 2800k 1300k 850k 860338 | ||
273 | -4 3600k 1700k 1100k 846899 | ||
274 | -5 4400k 2100k 1350k 845160 | ||
275 | -6 5200k 2500k 1600k 838626 | ||
276 | -7 6100k 2900k 1850k 834096 | ||
277 | -8 6800k 3300k 2100k 828642 | ||
278 | -9 7600k 3700k 2350k 828642 | ||
279 | |||
280 | |||
281 | RECOVERING DATA FROM DAMAGED FILES | ||
282 | bzip2 compresses files in blocks, usually 900kbytes long. | ||
283 | Each block is handled independently. If a media or trans- | ||
284 | mission error causes a multi-block .bz2 file to become | ||
285 | damaged, it may be possible to recover data from the | ||
286 | undamaged blocks in the file. | ||
287 | |||
288 | The compressed representation of each block is delimited | ||
289 | by a 48-bit pattern, which makes it possible to find the | ||
290 | block boundaries with reasonable certainty. Each block | ||
291 | also carries its own 32-bit CRC, so damaged blocks can be | ||
292 | distinguished from undamaged ones. | ||
293 | |||
294 | bzip2recover is a simple program whose purpose is to | ||
295 | search for blocks in .bz2 files, and write each block out | ||
296 | into its own .bz2 file. You can then use bzip2 -t to test | ||
297 | the integrity of the resulting files, and decompress those | ||
298 | which are undamaged. | ||
299 | |||
300 | bzip2recover takes a single argument, the name of the dam- | ||
301 | aged file, and writes a number of files | ||
302 | "rec00001file.bz2", "rec00002file.bz2", etc, containing | ||
303 | the extracted blocks. The output filenames are | ||
304 | designed so that the use of wildcards in subsequent pro- | ||
305 | cessing -- for example, "bzip2 -dc rec*file.bz2 > recov- | ||
306 | ered_data" -- processes the files in the correct order. | ||
307 | |||
308 | bzip2recover should be of most use dealing with large .bz2 | ||
309 | files, as these will contain many blocks. It is clearly | ||
310 | futile to use it on damaged single-block files, since a | ||
311 | damaged block cannot be recovered. If you wish to min- | ||
312 | imise any potential data loss through media or transmis- | ||
313 | sion errors, you might consider compressing with a smaller | ||
314 | block size. | ||
315 | |||
316 | |||
317 | PERFORMANCE NOTES | ||
318 | The sorting phase of compression gathers together similar | ||
319 | strings in the file. Because of this, files containing | ||
320 | very long runs of repeated symbols, like "aabaabaabaab | ||
321 | ..." (repeated several hundred times) may compress more | ||
322 | slowly than normal. Versions 0.9.5 and above fare much | ||
323 | better than previous versions in this respect. The ratio | ||
324 | between worst-case and average-case compression time is in | ||
325 | the region of 10:1. For previous versions, this figure | ||
326 | was more like 100:1. You can use the -vvvv option to mon- | ||
327 | itor progress in great detail, if you want. | ||
328 | |||
329 | Decompression speed is unaffected by these phenomena. | ||
330 | |||
331 | bzip2 usually allocates several megabytes of memory to | ||
332 | operate in, and then charges all over it in a fairly ran- | ||
333 | dom fashion. This means that performance, both for com- | ||
334 | pressing and decompressing, is largely determined by the | ||
335 | speed at which your machine can service cache misses. | ||
336 | Because of this, small changes to the code to reduce the | ||
337 | miss rate have been observed to give disproportionately | ||
338 | large performance improvements. I imagine bzip2 will per- | ||
339 | form best on machines with very large caches. | ||
340 | |||
341 | |||
342 | CAVEATS | ||
343 | I/O error messages are not as helpful as they could be. | ||
344 | bzip2 tries hard to detect I/O errors and exit cleanly, | ||
345 | but the details of what the problem is sometimes seem | ||
346 | rather misleading. | ||
347 | |||
348 | This manual page pertains to version 1.0.6 of bzip2. Com- | ||
349 | pressed data created by this version is entirely forwards | ||
350 | and backwards compatible with the previous public | ||
351 | releases, versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1, | ||
352 | 1.0.2 and above, but with the following exception: 0.9.0 | ||
353 | and above can correctly decompress multiple concatenated | ||
354 | compressed files. 0.1pl2 cannot do this; it will stop | ||
355 | after decompressing just the first file in the stream. | ||
356 | |||
357 | bzip2recover versions prior to 1.0.2 used 32-bit integers | ||
358 | to represent bit positions in compressed files, so they | ||
359 | could not handle compressed files more than 512 megabytes | ||
360 | long. Versions 1.0.2 and above use 64-bit ints on some | ||
361 | platforms which support them (GNU supported targets, and | ||
362 | Windows). To establish whether or not bzip2recover was | ||
363 | built with such a limitation, run it without arguments. | ||
364 | In any event you can build yourself an unlimited version | ||
365 | if you can recompile it with MaybeUInt64 set to be an | ||
366 | unsigned 64-bit integer. | ||
367 | |||
368 | |||
369 | AUTHOR | ||
370 | Julian Seward, jsewardbzip.org. | ||
371 | |||
372 | http://www.bzip.org | ||
373 | |||
374 | The ideas embodied in bzip2 are due to (at least) the fol- | ||
375 | lowing people: Michael Burrows and David Wheeler (for the | ||
376 | block sorting transformation), David Wheeler (again, for | ||
377 | the Huffman coder), Peter Fenwick (for the structured cod- | ||
378 | ing model in the original bzip, and many refinements), and | ||
379 | Alistair Moffat, Radford Neal and Ian Witten (for the | ||
380 | arithmetic coder in the original bzip). I am much | ||
381 | indebted for their help, support and advice. See the man- | ||
382 | ual in the source distribution for pointers to sources of | ||
383 | documentation. Christian von Roques encouraged me to look | ||
384 | for faster sorting algorithms, so as to speed up compres- | ||
385 | sion. Bela Lubkin encouraged me to improve the worst-case | ||
386 | compression performance. Donna Robinson XMLised the docu- | ||
387 | mentation. The bz* scripts are derived from those of GNU | ||
388 | gzip. Many people sent patches, helped with portability | ||
389 | problems, lent machines, gave advice and were generally | ||
390 | helpful. | ||
391 | |||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzip2recover.c b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzip2recover.c new file mode 100644 index 0000000..f9de049 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzip2recover.c | |||
@@ -0,0 +1,514 @@ | |||
1 | /*-----------------------------------------------------------*/ | ||
2 | /*--- Block recoverer program for bzip2 ---*/ | ||
3 | /*--- bzip2recover.c ---*/ | ||
4 | /*-----------------------------------------------------------*/ | ||
5 | |||
6 | /* ------------------------------------------------------------------ | ||
7 | This file is part of bzip2/libbzip2, a program and library for | ||
8 | lossless, block-sorting data compression. | ||
9 | |||
10 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | ||
11 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | ||
12 | |||
13 | Please read the WARNING, DISCLAIMER and PATENTS sections in the | ||
14 | README file. | ||
15 | |||
16 | This program is released under the terms of the license contained | ||
17 | in the file LICENSE. | ||
18 | ------------------------------------------------------------------ */ | ||
19 | |||
20 | /* This program is a complete hack and should be rewritten properly. | ||
21 | It isn't very complicated. */ | ||
22 | |||
23 | #include <stdio.h> | ||
24 | #include <errno.h> | ||
25 | #include <stdlib.h> | ||
26 | #include <string.h> | ||
27 | |||
28 | |||
29 | /* This program records bit locations in the file to be recovered. | ||
30 | That means that if 64-bit ints are not supported, we will not | ||
31 | be able to recover .bz2 files over 512MB (2^32 bits) long. | ||
32 | On GNU supported platforms, we take advantage of the 64-bit | ||
33 | int support to circumvent this problem. Ditto MSVC. | ||
34 | |||
35 | This change occurred in version 1.0.2; all prior versions have | ||
36 | the 512MB limitation. | ||
37 | */ | ||
38 | #ifdef __GNUC__ | ||
39 | typedef unsigned long long int MaybeUInt64; | ||
40 | # define MaybeUInt64_FMT "%Lu" | ||
41 | #else | ||
42 | #ifdef _MSC_VER | ||
43 | typedef unsigned __int64 MaybeUInt64; | ||
44 | # define MaybeUInt64_FMT "%I64u" | ||
45 | #else | ||
46 | typedef unsigned int MaybeUInt64; | ||
47 | # define MaybeUInt64_FMT "%u" | ||
48 | #endif | ||
49 | #endif | ||
50 | |||
51 | typedef unsigned int UInt32; | ||
52 | typedef int Int32; | ||
53 | typedef unsigned char UChar; | ||
54 | typedef char Char; | ||
55 | typedef unsigned char Bool; | ||
56 | #define True ((Bool)1) | ||
57 | #define False ((Bool)0) | ||
58 | |||
59 | |||
60 | #define BZ_MAX_FILENAME 2000 | ||
61 | |||
62 | Char inFileName[BZ_MAX_FILENAME]; | ||
63 | Char outFileName[BZ_MAX_FILENAME]; | ||
64 | Char progName[BZ_MAX_FILENAME]; | ||
65 | |||
66 | MaybeUInt64 bytesOut = 0; | ||
67 | MaybeUInt64 bytesIn = 0; | ||
68 | |||
69 | |||
70 | /*---------------------------------------------------*/ | ||
71 | /*--- Header bytes ---*/ | ||
72 | /*---------------------------------------------------*/ | ||
73 | |||
74 | #define BZ_HDR_B 0x42 /* 'B' */ | ||
75 | #define BZ_HDR_Z 0x5a /* 'Z' */ | ||
76 | #define BZ_HDR_h 0x68 /* 'h' */ | ||
77 | #define BZ_HDR_0 0x30 /* '0' */ | ||
78 | |||
79 | |||
80 | /*---------------------------------------------------*/ | ||
81 | /*--- I/O errors ---*/ | ||
82 | /*---------------------------------------------------*/ | ||
83 | |||
84 | /*---------------------------------------------*/ | ||
85 | static void readError ( void ) | ||
86 | { | ||
87 | fprintf ( stderr, | ||
88 | "%s: I/O error reading `%s', possible reason follows.\n", | ||
89 | progName, inFileName ); | ||
90 | perror ( progName ); | ||
91 | fprintf ( stderr, "%s: warning: output file(s) may be incomplete.\n", | ||
92 | progName ); | ||
93 | exit ( 1 ); | ||
94 | } | ||
95 | |||
96 | |||
97 | /*---------------------------------------------*/ | ||
98 | static void writeError ( void ) | ||
99 | { | ||
100 | fprintf ( stderr, | ||
101 | "%s: I/O error reading `%s', possible reason follows.\n", | ||
102 | progName, inFileName ); | ||
103 | perror ( progName ); | ||
104 | fprintf ( stderr, "%s: warning: output file(s) may be incomplete.\n", | ||
105 | progName ); | ||
106 | exit ( 1 ); | ||
107 | } | ||
108 | |||
109 | |||
110 | /*---------------------------------------------*/ | ||
111 | static void mallocFail ( Int32 n ) | ||
112 | { | ||
113 | fprintf ( stderr, | ||
114 | "%s: malloc failed on request for %d bytes.\n", | ||
115 | progName, n ); | ||
116 | fprintf ( stderr, "%s: warning: output file(s) may be incomplete.\n", | ||
117 | progName ); | ||
118 | exit ( 1 ); | ||
119 | } | ||
120 | |||
121 | |||
122 | /*---------------------------------------------*/ | ||
123 | static void tooManyBlocks ( Int32 max_handled_blocks ) | ||
124 | { | ||
125 | fprintf ( stderr, | ||
126 | "%s: `%s' appears to contain more than %d blocks\n", | ||
127 | progName, inFileName, max_handled_blocks ); | ||
128 | fprintf ( stderr, | ||
129 | "%s: and cannot be handled. To fix, increase\n", | ||
130 | progName ); | ||
131 | fprintf ( stderr, | ||
132 | "%s: BZ_MAX_HANDLED_BLOCKS in bzip2recover.c, and recompile.\n", | ||
133 | progName ); | ||
134 | exit ( 1 ); | ||
135 | } | ||
136 | |||
137 | |||
138 | |||
139 | /*---------------------------------------------------*/ | ||
140 | /*--- Bit stream I/O ---*/ | ||
141 | /*---------------------------------------------------*/ | ||
142 | |||
143 | typedef | ||
144 | struct { | ||
145 | FILE* handle; | ||
146 | Int32 buffer; | ||
147 | Int32 buffLive; | ||
148 | Char mode; | ||
149 | } | ||
150 | BitStream; | ||
151 | |||
152 | |||
153 | /*---------------------------------------------*/ | ||
154 | static BitStream* bsOpenReadStream ( FILE* stream ) | ||
155 | { | ||
156 | BitStream *bs = malloc ( sizeof(BitStream) ); | ||
157 | if (bs == NULL) mallocFail ( sizeof(BitStream) ); | ||
158 | bs->handle = stream; | ||
159 | bs->buffer = 0; | ||
160 | bs->buffLive = 0; | ||
161 | bs->mode = 'r'; | ||
162 | return bs; | ||
163 | } | ||
164 | |||
165 | |||
166 | /*---------------------------------------------*/ | ||
167 | static BitStream* bsOpenWriteStream ( FILE* stream ) | ||
168 | { | ||
169 | BitStream *bs = malloc ( sizeof(BitStream) ); | ||
170 | if (bs == NULL) mallocFail ( sizeof(BitStream) ); | ||
171 | bs->handle = stream; | ||
172 | bs->buffer = 0; | ||
173 | bs->buffLive = 0; | ||
174 | bs->mode = 'w'; | ||
175 | return bs; | ||
176 | } | ||
177 | |||
178 | |||
179 | /*---------------------------------------------*/ | ||
180 | static void bsPutBit ( BitStream* bs, Int32 bit ) | ||
181 | { | ||
182 | if (bs->buffLive == 8) { | ||
183 | Int32 retVal = putc ( (UChar) bs->buffer, bs->handle ); | ||
184 | if (retVal == EOF) writeError(); | ||
185 | bytesOut++; | ||
186 | bs->buffLive = 1; | ||
187 | bs->buffer = bit & 0x1; | ||
188 | } else { | ||
189 | bs->buffer = ( (bs->buffer << 1) | (bit & 0x1) ); | ||
190 | bs->buffLive++; | ||
191 | }; | ||
192 | } | ||
193 | |||
194 | |||
195 | /*---------------------------------------------*/ | ||
196 | /*-- | ||
197 | Returns 0 or 1, or 2 to indicate EOF. | ||
198 | --*/ | ||
199 | static Int32 bsGetBit ( BitStream* bs ) | ||
200 | { | ||
201 | if (bs->buffLive > 0) { | ||
202 | bs->buffLive --; | ||
203 | return ( ((bs->buffer) >> (bs->buffLive)) & 0x1 ); | ||
204 | } else { | ||
205 | Int32 retVal = getc ( bs->handle ); | ||
206 | if ( retVal == EOF ) { | ||
207 | if (errno != 0) readError(); | ||
208 | return 2; | ||
209 | } | ||
210 | bs->buffLive = 7; | ||
211 | bs->buffer = retVal; | ||
212 | return ( ((bs->buffer) >> 7) & 0x1 ); | ||
213 | } | ||
214 | } | ||
215 | |||
216 | |||
217 | /*---------------------------------------------*/ | ||
218 | static void bsClose ( BitStream* bs ) | ||
219 | { | ||
220 | Int32 retVal; | ||
221 | |||
222 | if ( bs->mode == 'w' ) { | ||
223 | while ( bs->buffLive < 8 ) { | ||
224 | bs->buffLive++; | ||
225 | bs->buffer <<= 1; | ||
226 | }; | ||
227 | retVal = putc ( (UChar) (bs->buffer), bs->handle ); | ||
228 | if (retVal == EOF) writeError(); | ||
229 | bytesOut++; | ||
230 | retVal = fflush ( bs->handle ); | ||
231 | if (retVal == EOF) writeError(); | ||
232 | } | ||
233 | retVal = fclose ( bs->handle ); | ||
234 | if (retVal == EOF) { | ||
235 | if (bs->mode == 'w') writeError(); else readError(); | ||
236 | } | ||
237 | free ( bs ); | ||
238 | } | ||
239 | |||
240 | |||
241 | /*---------------------------------------------*/ | ||
242 | static void bsPutUChar ( BitStream* bs, UChar c ) | ||
243 | { | ||
244 | Int32 i; | ||
245 | for (i = 7; i >= 0; i--) | ||
246 | bsPutBit ( bs, (((UInt32) c) >> i) & 0x1 ); | ||
247 | } | ||
248 | |||
249 | |||
250 | /*---------------------------------------------*/ | ||
251 | static void bsPutUInt32 ( BitStream* bs, UInt32 c ) | ||
252 | { | ||
253 | Int32 i; | ||
254 | |||
255 | for (i = 31; i >= 0; i--) | ||
256 | bsPutBit ( bs, (c >> i) & 0x1 ); | ||
257 | } | ||
258 | |||
259 | |||
260 | /*---------------------------------------------*/ | ||
261 | static Bool endsInBz2 ( Char* name ) | ||
262 | { | ||
263 | Int32 n = strlen ( name ); | ||
264 | if (n <= 4) return False; | ||
265 | return | ||
266 | (name[n-4] == '.' && | ||
267 | name[n-3] == 'b' && | ||
268 | name[n-2] == 'z' && | ||
269 | name[n-1] == '2'); | ||
270 | } | ||
271 | |||
272 | |||
273 | /*---------------------------------------------------*/ | ||
274 | /*--- ---*/ | ||
275 | /*---------------------------------------------------*/ | ||
276 | |||
277 | /* This logic isn't really right when it comes to Cygwin. */ | ||
278 | #ifdef _WIN32 | ||
279 | # define BZ_SPLIT_SYM '\\' /* path splitter on Windows platform */ | ||
280 | #else | ||
281 | # define BZ_SPLIT_SYM '/' /* path splitter on Unix platform */ | ||
282 | #endif | ||
283 | |||
284 | #define BLOCK_HEADER_HI 0x00003141UL | ||
285 | #define BLOCK_HEADER_LO 0x59265359UL | ||
286 | |||
287 | #define BLOCK_ENDMARK_HI 0x00001772UL | ||
288 | #define BLOCK_ENDMARK_LO 0x45385090UL | ||
289 | |||
290 | /* Increase if necessary. However, a .bz2 file with > 50000 blocks | ||
291 | would have an uncompressed size of at least 40GB, so the chances | ||
292 | are low you'll need to up this. | ||
293 | */ | ||
294 | #define BZ_MAX_HANDLED_BLOCKS 50000 | ||
295 | |||
296 | MaybeUInt64 bStart [BZ_MAX_HANDLED_BLOCKS]; | ||
297 | MaybeUInt64 bEnd [BZ_MAX_HANDLED_BLOCKS]; | ||
298 | MaybeUInt64 rbStart[BZ_MAX_HANDLED_BLOCKS]; | ||
299 | MaybeUInt64 rbEnd [BZ_MAX_HANDLED_BLOCKS]; | ||
300 | |||
301 | Int32 main ( Int32 argc, Char** argv ) | ||
302 | { | ||
303 | FILE* inFile; | ||
304 | FILE* outFile; | ||
305 | BitStream* bsIn, *bsWr; | ||
306 | Int32 b, wrBlock, currBlock, rbCtr; | ||
307 | MaybeUInt64 bitsRead; | ||
308 | |||
309 | UInt32 buffHi, buffLo, blockCRC; | ||
310 | Char* p; | ||
311 | |||
312 | strcpy ( progName, argv[0] ); | ||
313 | inFileName[0] = outFileName[0] = 0; | ||
314 | |||
315 | fprintf ( stderr, | ||
316 | "bzip2recover 1.0.6: extracts blocks from damaged .bz2 files.\n" ); | ||
317 | |||
318 | if (argc != 2) { | ||
319 | fprintf ( stderr, "%s: usage is `%s damaged_file_name'.\n", | ||
320 | progName, progName ); | ||
321 | switch (sizeof(MaybeUInt64)) { | ||
322 | case 8: | ||
323 | fprintf(stderr, | ||
324 | "\trestrictions on size of recovered file: None\n"); | ||
325 | break; | ||
326 | case 4: | ||
327 | fprintf(stderr, | ||
328 | "\trestrictions on size of recovered file: 512 MB\n"); | ||
329 | fprintf(stderr, | ||
330 | "\tto circumvent, recompile with MaybeUInt64 as an\n" | ||
331 | "\tunsigned 64-bit int.\n"); | ||
332 | break; | ||
333 | default: | ||
334 | fprintf(stderr, | ||
335 | "\tsizeof(MaybeUInt64) is not 4 or 8 -- " | ||
336 | "configuration error.\n"); | ||
337 | break; | ||
338 | } | ||
339 | exit(1); | ||
340 | } | ||
341 | |||
342 | if (strlen(argv[1]) >= BZ_MAX_FILENAME-20) { | ||
343 | fprintf ( stderr, | ||
344 | "%s: supplied filename is suspiciously (>= %d chars) long. Bye!\n", | ||
345 | progName, (int)strlen(argv[1]) ); | ||
346 | exit(1); | ||
347 | } | ||
348 | |||
349 | strcpy ( inFileName, argv[1] ); | ||
350 | |||
351 | inFile = fopen ( inFileName, "rb" ); | ||
352 | if (inFile == NULL) { | ||
353 | fprintf ( stderr, "%s: can't read `%s'\n", progName, inFileName ); | ||
354 | exit(1); | ||
355 | } | ||
356 | |||
357 | bsIn = bsOpenReadStream ( inFile ); | ||
358 | fprintf ( stderr, "%s: searching for block boundaries ...\n", progName ); | ||
359 | |||
360 | bitsRead = 0; | ||
361 | buffHi = buffLo = 0; | ||
362 | currBlock = 0; | ||
363 | bStart[currBlock] = 0; | ||
364 | |||
365 | rbCtr = 0; | ||
366 | |||
367 | while (True) { | ||
368 | b = bsGetBit ( bsIn ); | ||
369 | bitsRead++; | ||
370 | if (b == 2) { | ||
371 | if (bitsRead >= bStart[currBlock] && | ||
372 | (bitsRead - bStart[currBlock]) >= 40) { | ||
373 | bEnd[currBlock] = bitsRead-1; | ||
374 | if (currBlock > 0) | ||
375 | fprintf ( stderr, " block %d runs from " MaybeUInt64_FMT | ||
376 | " to " MaybeUInt64_FMT " (incomplete)\n", | ||
377 | currBlock, bStart[currBlock], bEnd[currBlock] ); | ||
378 | } else | ||
379 | currBlock--; | ||
380 | break; | ||
381 | } | ||
382 | buffHi = (buffHi << 1) | (buffLo >> 31); | ||
383 | buffLo = (buffLo << 1) | (b & 1); | ||
384 | if ( ( (buffHi & 0x0000ffff) == BLOCK_HEADER_HI | ||
385 | && buffLo == BLOCK_HEADER_LO) | ||
386 | || | ||
387 | ( (buffHi & 0x0000ffff) == BLOCK_ENDMARK_HI | ||
388 | && buffLo == BLOCK_ENDMARK_LO) | ||
389 | ) { | ||
390 | if (bitsRead > 49) { | ||
391 | bEnd[currBlock] = bitsRead-49; | ||
392 | } else { | ||
393 | bEnd[currBlock] = 0; | ||
394 | } | ||
395 | if (currBlock > 0 && | ||
396 | (bEnd[currBlock] - bStart[currBlock]) >= 130) { | ||
397 | fprintf ( stderr, " block %d runs from " MaybeUInt64_FMT | ||
398 | " to " MaybeUInt64_FMT "\n", | ||
399 | rbCtr+1, bStart[currBlock], bEnd[currBlock] ); | ||
400 | rbStart[rbCtr] = bStart[currBlock]; | ||
401 | rbEnd[rbCtr] = bEnd[currBlock]; | ||
402 | rbCtr++; | ||
403 | } | ||
404 | if (currBlock >= BZ_MAX_HANDLED_BLOCKS) | ||
405 | tooManyBlocks(BZ_MAX_HANDLED_BLOCKS); | ||
406 | currBlock++; | ||
407 | |||
408 | bStart[currBlock] = bitsRead; | ||
409 | } | ||
410 | } | ||
411 | |||
412 | bsClose ( bsIn ); | ||
413 | |||
414 | /*-- identified blocks run from 1 to rbCtr inclusive. --*/ | ||
415 | |||
416 | if (rbCtr < 1) { | ||
417 | fprintf ( stderr, | ||
418 | "%s: sorry, I couldn't find any block boundaries.\n", | ||
419 | progName ); | ||
420 | exit(1); | ||
421 | }; | ||
422 | |||
423 | fprintf ( stderr, "%s: splitting into blocks\n", progName ); | ||
424 | |||
425 | inFile = fopen ( inFileName, "rb" ); | ||
426 | if (inFile == NULL) { | ||
427 | fprintf ( stderr, "%s: can't open `%s'\n", progName, inFileName ); | ||
428 | exit(1); | ||
429 | } | ||
430 | bsIn = bsOpenReadStream ( inFile ); | ||
431 | |||
432 | /*-- placate gcc's dataflow analyser --*/ | ||
433 | blockCRC = 0; bsWr = 0; | ||
434 | |||
435 | bitsRead = 0; | ||
436 | outFile = NULL; | ||
437 | wrBlock = 0; | ||
438 | while (True) { | ||
439 | b = bsGetBit(bsIn); | ||
440 | if (b == 2) break; | ||
441 | buffHi = (buffHi << 1) | (buffLo >> 31); | ||
442 | buffLo = (buffLo << 1) | (b & 1); | ||
443 | if (bitsRead == 47+rbStart[wrBlock]) | ||
444 | blockCRC = (buffHi << 16) | (buffLo >> 16); | ||
445 | |||
446 | if (outFile != NULL && bitsRead >= rbStart[wrBlock] | ||
447 | && bitsRead <= rbEnd[wrBlock]) { | ||
448 | bsPutBit ( bsWr, b ); | ||
449 | } | ||
450 | |||
451 | bitsRead++; | ||
452 | |||
453 | if (bitsRead == rbEnd[wrBlock]+1) { | ||
454 | if (outFile != NULL) { | ||
455 | bsPutUChar ( bsWr, 0x17 ); bsPutUChar ( bsWr, 0x72 ); | ||
456 | bsPutUChar ( bsWr, 0x45 ); bsPutUChar ( bsWr, 0x38 ); | ||
457 | bsPutUChar ( bsWr, 0x50 ); bsPutUChar ( bsWr, 0x90 ); | ||
458 | bsPutUInt32 ( bsWr, blockCRC ); | ||
459 | bsClose ( bsWr ); | ||
460 | } | ||
461 | if (wrBlock >= rbCtr) break; | ||
462 | wrBlock++; | ||
463 | } else | ||
464 | if (bitsRead == rbStart[wrBlock]) { | ||
465 | /* Create the output file name, correctly handling leading paths. | ||
466 | (31.10.2001 by Sergey E. Kusikov) */ | ||
467 | Char* split; | ||
468 | Int32 ofs, k; | ||
469 | for (k = 0; k < BZ_MAX_FILENAME; k++) | ||
470 | outFileName[k] = 0; | ||
471 | strcpy (outFileName, inFileName); | ||
472 | split = strrchr (outFileName, BZ_SPLIT_SYM); | ||
473 | if (split == NULL) { | ||
474 | split = outFileName; | ||
475 | } else { | ||
476 | ++split; | ||
477 | } | ||
478 | /* Now split points to the start of the basename. */ | ||
479 | ofs = split - outFileName; | ||
480 | sprintf (split, "rec%5d", wrBlock+1); | ||
481 | for (p = split; *p != 0; p++) if (*p == ' ') *p = '0'; | ||
482 | strcat (outFileName, inFileName + ofs); | ||
483 | |||
484 | if ( !endsInBz2(outFileName)) strcat ( outFileName, ".bz2" ); | ||
485 | |||
486 | fprintf ( stderr, " writing block %d to `%s' ...\n", | ||
487 | wrBlock+1, outFileName ); | ||
488 | |||
489 | outFile = fopen ( outFileName, "wb" ); | ||
490 | if (outFile == NULL) { | ||
491 | fprintf ( stderr, "%s: can't write `%s'\n", | ||
492 | progName, outFileName ); | ||
493 | exit(1); | ||
494 | } | ||
495 | bsWr = bsOpenWriteStream ( outFile ); | ||
496 | bsPutUChar ( bsWr, BZ_HDR_B ); | ||
497 | bsPutUChar ( bsWr, BZ_HDR_Z ); | ||
498 | bsPutUChar ( bsWr, BZ_HDR_h ); | ||
499 | bsPutUChar ( bsWr, BZ_HDR_0 + 9 ); | ||
500 | bsPutUChar ( bsWr, 0x31 ); bsPutUChar ( bsWr, 0x41 ); | ||
501 | bsPutUChar ( bsWr, 0x59 ); bsPutUChar ( bsWr, 0x26 ); | ||
502 | bsPutUChar ( bsWr, 0x53 ); bsPutUChar ( bsWr, 0x59 ); | ||
503 | } | ||
504 | } | ||
505 | |||
506 | fprintf ( stderr, "%s: finished\n", progName ); | ||
507 | return 0; | ||
508 | } | ||
509 | |||
510 | |||
511 | |||
512 | /*-----------------------------------------------------------*/ | ||
513 | /*--- end bzip2recover.c ---*/ | ||
514 | /*-----------------------------------------------------------*/ | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzlib.c b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzlib.c new file mode 100644 index 0000000..d85e734 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzlib.c | |||
@@ -0,0 +1,1580 @@ | |||
1 | |||
2 | /*-------------------------------------------------------------*/ | ||
3 | /*--- Library top-level functions. ---*/ | ||
4 | /*--- bzlib.c ---*/ | ||
5 | /*-------------------------------------------------------------*/ | ||
6 | |||
7 | /* ------------------------------------------------------------------ | ||
8 | This file is part of bzip2/libbzip2, a program and library for | ||
9 | lossless, block-sorting data compression. | ||
10 | |||
11 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | ||
12 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | ||
13 | |||
14 | Please read the WARNING, DISCLAIMER and PATENTS sections in the | ||
15 | README file. | ||
16 | |||
17 | This program is released under the terms of the license contained | ||
18 | in the file LICENSE. | ||
19 | ------------------------------------------------------------------ */ | ||
20 | |||
21 | /* CHANGES | ||
22 | 0.9.0 -- original version. | ||
23 | 0.9.0a/b -- no changes in this file. | ||
24 | 0.9.0c -- made zero-length BZ_FLUSH work correctly in bzCompress(). | ||
25 | fixed bzWrite/bzRead to ignore zero-length requests. | ||
26 | fixed bzread to correctly handle read requests after EOF. | ||
27 | wrong parameter order in call to bzDecompressInit in | ||
28 | bzBuffToBuffDecompress. Fixed. | ||
29 | */ | ||
30 | |||
31 | #include "bzlib_private.h" | ||
32 | |||
33 | |||
34 | /*---------------------------------------------------*/ | ||
35 | /*--- Compression stuff ---*/ | ||
36 | /*---------------------------------------------------*/ | ||
37 | |||
38 | |||
39 | /*---------------------------------------------------*/ | ||
40 | #ifndef BZ_NO_STDIO | ||
41 | void BZ2_bz__AssertH__fail ( int errcode ) | ||
42 | { | ||
43 | fprintf(stderr, | ||
44 | "\n\nbzip2/libbzip2: internal error number %d.\n" | ||
45 | "This is a bug in bzip2/libbzip2, %s.\n" | ||
46 | "Please report it to me at: jseward@bzip.org. If this happened\n" | ||
47 | "when you were using some program which uses libbzip2 as a\n" | ||
48 | "component, you should also report this bug to the author(s)\n" | ||
49 | "of that program. Please make an effort to report this bug;\n" | ||
50 | "timely and accurate bug reports eventually lead to higher\n" | ||
51 | "quality software. Thanks. Julian Seward, 10 December 2007.\n\n", | ||
52 | errcode, | ||
53 | BZ2_bzlibVersion() | ||
54 | ); | ||
55 | |||
56 | if (errcode == 1007) { | ||
57 | fprintf(stderr, | ||
58 | "\n*** A special note about internal error number 1007 ***\n" | ||
59 | "\n" | ||
60 | "Experience suggests that a common cause of i.e. 1007\n" | ||
61 | "is unreliable memory or other hardware. The 1007 assertion\n" | ||
62 | "just happens to cross-check the results of huge numbers of\n" | ||
63 | "memory reads/writes, and so acts (unintendedly) as a stress\n" | ||
64 | "test of your memory system.\n" | ||
65 | "\n" | ||
66 | "I suggest the following: try compressing the file again,\n" | ||
67 | "possibly monitoring progress in detail with the -vv flag.\n" | ||
68 | "\n" | ||
69 | "* If the error cannot be reproduced, and/or happens at different\n" | ||
70 | " points in compression, you may have a flaky memory system.\n" | ||
71 | " Try a memory-test program. I have used Memtest86\n" | ||
72 | " (www.memtest86.com). At the time of writing it is free (GPLd).\n" | ||
73 | " Memtest86 tests memory much more thorougly than your BIOSs\n" | ||
74 | " power-on test, and may find failures that the BIOS doesn't.\n" | ||
75 | "\n" | ||
76 | "* If the error can be repeatably reproduced, this is a bug in\n" | ||
77 | " bzip2, and I would very much like to hear about it. Please\n" | ||
78 | " let me know, and, ideally, save a copy of the file causing the\n" | ||
79 | " problem -- without which I will be unable to investigate it.\n" | ||
80 | "\n" | ||
81 | ); | ||
82 | } | ||
83 | |||
84 | exit(3); | ||
85 | } | ||
86 | #endif | ||
87 | |||
88 | |||
89 | /*---------------------------------------------------*/ | ||
90 | static | ||
91 | int bz_config_ok ( void ) | ||
92 | { | ||
93 | if (sizeof(int) != 4) return 0; | ||
94 | if (sizeof(short) != 2) return 0; | ||
95 | if (sizeof(char) != 1) return 0; | ||
96 | return 1; | ||
97 | } | ||
98 | |||
99 | |||
100 | /*---------------------------------------------------*/ | ||
101 | static | ||
102 | void* default_bzalloc ( void* opaque, Int32 items, Int32 size ) | ||
103 | { | ||
104 | void* v = malloc ( items * size ); | ||
105 | return v; | ||
106 | } | ||
107 | |||
108 | static | ||
109 | void default_bzfree ( void* opaque, void* addr ) | ||
110 | { | ||
111 | if (addr != NULL) free ( addr ); | ||
112 | } | ||
113 | |||
114 | |||
115 | /*---------------------------------------------------*/ | ||
116 | static | ||
117 | void prepare_new_block ( EState* s ) | ||
118 | { | ||
119 | Int32 i; | ||
120 | s->nblock = 0; | ||
121 | s->numZ = 0; | ||
122 | s->state_out_pos = 0; | ||
123 | BZ_INITIALISE_CRC ( s->blockCRC ); | ||
124 | for (i = 0; i < 256; i++) s->inUse[i] = False; | ||
125 | s->blockNo++; | ||
126 | } | ||
127 | |||
128 | |||
129 | /*---------------------------------------------------*/ | ||
130 | static | ||
131 | void init_RL ( EState* s ) | ||
132 | { | ||
133 | s->state_in_ch = 256; | ||
134 | s->state_in_len = 0; | ||
135 | } | ||
136 | |||
137 | |||
138 | static | ||
139 | Bool isempty_RL ( EState* s ) | ||
140 | { | ||
141 | if (s->state_in_ch < 256 && s->state_in_len > 0) | ||
142 | return False; else | ||
143 | return True; | ||
144 | } | ||
145 | |||
146 | |||
147 | /*---------------------------------------------------*/ | ||
148 | int BZ_API(BZ2_bzCompressInit) | ||
149 | ( bz_stream* strm, | ||
150 | int blockSize100k, | ||
151 | int verbosity, | ||
152 | int workFactor ) | ||
153 | { | ||
154 | Int32 n; | ||
155 | EState* s; | ||
156 | |||
157 | if (!bz_config_ok()) return BZ_CONFIG_ERROR; | ||
158 | |||
159 | if (strm == NULL || | ||
160 | blockSize100k < 1 || blockSize100k > 9 || | ||
161 | workFactor < 0 || workFactor > 250) | ||
162 | return BZ_PARAM_ERROR; | ||
163 | |||
164 | if (workFactor == 0) workFactor = 30; | ||
165 | if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc; | ||
166 | if (strm->bzfree == NULL) strm->bzfree = default_bzfree; | ||
167 | |||
168 | s = BZALLOC( sizeof(EState) ); | ||
169 | if (s == NULL) return BZ_MEM_ERROR; | ||
170 | s->strm = strm; | ||
171 | |||
172 | s->arr1 = NULL; | ||
173 | s->arr2 = NULL; | ||
174 | s->ftab = NULL; | ||
175 | |||
176 | n = 100000 * blockSize100k; | ||
177 | s->arr1 = BZALLOC( n * sizeof(UInt32) ); | ||
178 | s->arr2 = BZALLOC( (n+BZ_N_OVERSHOOT) * sizeof(UInt32) ); | ||
179 | s->ftab = BZALLOC( 65537 * sizeof(UInt32) ); | ||
180 | |||
181 | if (s->arr1 == NULL || s->arr2 == NULL || s->ftab == NULL) { | ||
182 | if (s->arr1 != NULL) BZFREE(s->arr1); | ||
183 | if (s->arr2 != NULL) BZFREE(s->arr2); | ||
184 | if (s->ftab != NULL) BZFREE(s->ftab); | ||
185 | if (s != NULL) BZFREE(s); | ||
186 | return BZ_MEM_ERROR; | ||
187 | } | ||
188 | |||
189 | s->blockNo = 0; | ||
190 | s->state = BZ_S_INPUT; | ||
191 | s->mode = BZ_M_RUNNING; | ||
192 | s->combinedCRC = 0; | ||
193 | s->blockSize100k = blockSize100k; | ||
194 | s->nblockMAX = 100000 * blockSize100k - 19; | ||
195 | s->verbosity = verbosity; | ||
196 | s->workFactor = workFactor; | ||
197 | |||
198 | s->block = (UChar*)s->arr2; | ||
199 | s->mtfv = (UInt16*)s->arr1; | ||
200 | s->zbits = NULL; | ||
201 | s->ptr = (UInt32*)s->arr1; | ||
202 | |||
203 | strm->state = s; | ||
204 | strm->total_in_lo32 = 0; | ||
205 | strm->total_in_hi32 = 0; | ||
206 | strm->total_out_lo32 = 0; | ||
207 | strm->total_out_hi32 = 0; | ||
208 | init_RL ( s ); | ||
209 | prepare_new_block ( s ); | ||
210 | return BZ_OK; | ||
211 | } | ||
212 | |||
213 | |||
214 | /*---------------------------------------------------*/ | ||
215 | static | ||
216 | void add_pair_to_block ( EState* s ) | ||
217 | { | ||
218 | Int32 i; | ||
219 | UChar ch = (UChar)(s->state_in_ch); | ||
220 | for (i = 0; i < s->state_in_len; i++) { | ||
221 | BZ_UPDATE_CRC( s->blockCRC, ch ); | ||
222 | } | ||
223 | s->inUse[s->state_in_ch] = True; | ||
224 | switch (s->state_in_len) { | ||
225 | case 1: | ||
226 | s->block[s->nblock] = (UChar)ch; s->nblock++; | ||
227 | break; | ||
228 | case 2: | ||
229 | s->block[s->nblock] = (UChar)ch; s->nblock++; | ||
230 | s->block[s->nblock] = (UChar)ch; s->nblock++; | ||
231 | break; | ||
232 | case 3: | ||
233 | s->block[s->nblock] = (UChar)ch; s->nblock++; | ||
234 | s->block[s->nblock] = (UChar)ch; s->nblock++; | ||
235 | s->block[s->nblock] = (UChar)ch; s->nblock++; | ||
236 | break; | ||
237 | default: | ||
238 | s->inUse[s->state_in_len-4] = True; | ||
239 | s->block[s->nblock] = (UChar)ch; s->nblock++; | ||
240 | s->block[s->nblock] = (UChar)ch; s->nblock++; | ||
241 | s->block[s->nblock] = (UChar)ch; s->nblock++; | ||
242 | s->block[s->nblock] = (UChar)ch; s->nblock++; | ||
243 | s->block[s->nblock] = ((UChar)(s->state_in_len-4)); | ||
244 | s->nblock++; | ||
245 | break; | ||
246 | } | ||
247 | } | ||
248 | |||
249 | |||
250 | /*---------------------------------------------------*/ | ||
251 | static | ||
252 | void flush_RL ( EState* s ) | ||
253 | { | ||
254 | if (s->state_in_ch < 256) add_pair_to_block ( s ); | ||
255 | init_RL ( s ); | ||
256 | } | ||
257 | |||
258 | |||
259 | /*---------------------------------------------------*/ | ||
260 | #define ADD_CHAR_TO_BLOCK(zs,zchh0) \ | ||
261 | { \ | ||
262 | UInt32 zchh = (UInt32)(zchh0); \ | ||
263 | /*-- fast track the common case --*/ \ | ||
264 | if (zchh != zs->state_in_ch && \ | ||
265 | zs->state_in_len == 1) { \ | ||
266 | UChar ch = (UChar)(zs->state_in_ch); \ | ||
267 | BZ_UPDATE_CRC( zs->blockCRC, ch ); \ | ||
268 | zs->inUse[zs->state_in_ch] = True; \ | ||
269 | zs->block[zs->nblock] = (UChar)ch; \ | ||
270 | zs->nblock++; \ | ||
271 | zs->state_in_ch = zchh; \ | ||
272 | } \ | ||
273 | else \ | ||
274 | /*-- general, uncommon cases --*/ \ | ||
275 | if (zchh != zs->state_in_ch || \ | ||
276 | zs->state_in_len == 255) { \ | ||
277 | if (zs->state_in_ch < 256) \ | ||
278 | add_pair_to_block ( zs ); \ | ||
279 | zs->state_in_ch = zchh; \ | ||
280 | zs->state_in_len = 1; \ | ||
281 | } else { \ | ||
282 | zs->state_in_len++; \ | ||
283 | } \ | ||
284 | } | ||
285 | |||
286 | |||
287 | /*---------------------------------------------------*/ | ||
288 | static | ||
289 | Bool copy_input_until_stop ( EState* s ) | ||
290 | { | ||
291 | Bool progress_in = False; | ||
292 | |||
293 | if (s->mode == BZ_M_RUNNING) { | ||
294 | |||
295 | /*-- fast track the common case --*/ | ||
296 | while (True) { | ||
297 | /*-- block full? --*/ | ||
298 | if (s->nblock >= s->nblockMAX) break; | ||
299 | /*-- no input? --*/ | ||
300 | if (s->strm->avail_in == 0) break; | ||
301 | progress_in = True; | ||
302 | ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); | ||
303 | s->strm->next_in++; | ||
304 | s->strm->avail_in--; | ||
305 | s->strm->total_in_lo32++; | ||
306 | if (s->strm->total_in_lo32 == 0) s->strm->total_in_hi32++; | ||
307 | } | ||
308 | |||
309 | } else { | ||
310 | |||
311 | /*-- general, uncommon case --*/ | ||
312 | while (True) { | ||
313 | /*-- block full? --*/ | ||
314 | if (s->nblock >= s->nblockMAX) break; | ||
315 | /*-- no input? --*/ | ||
316 | if (s->strm->avail_in == 0) break; | ||
317 | /*-- flush/finish end? --*/ | ||
318 | if (s->avail_in_expect == 0) break; | ||
319 | progress_in = True; | ||
320 | ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); | ||
321 | s->strm->next_in++; | ||
322 | s->strm->avail_in--; | ||
323 | s->strm->total_in_lo32++; | ||
324 | if (s->strm->total_in_lo32 == 0) s->strm->total_in_hi32++; | ||
325 | s->avail_in_expect--; | ||
326 | } | ||
327 | } | ||
328 | return progress_in; | ||
329 | } | ||
330 | |||
331 | |||
332 | /*---------------------------------------------------*/ | ||
333 | static | ||
334 | Bool copy_output_until_stop ( EState* s ) | ||
335 | { | ||
336 | Bool progress_out = False; | ||
337 | |||
338 | while (True) { | ||
339 | |||
340 | /*-- no output space? --*/ | ||
341 | if (s->strm->avail_out == 0) break; | ||
342 | |||
343 | /*-- block done? --*/ | ||
344 | if (s->state_out_pos >= s->numZ) break; | ||
345 | |||
346 | progress_out = True; | ||
347 | *(s->strm->next_out) = s->zbits[s->state_out_pos]; | ||
348 | s->state_out_pos++; | ||
349 | s->strm->avail_out--; | ||
350 | s->strm->next_out++; | ||
351 | s->strm->total_out_lo32++; | ||
352 | if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; | ||
353 | } | ||
354 | |||
355 | return progress_out; | ||
356 | } | ||
357 | |||
358 | |||
359 | /*---------------------------------------------------*/ | ||
360 | static | ||
361 | Bool handle_compress ( bz_stream* strm ) | ||
362 | { | ||
363 | Bool progress_in = False; | ||
364 | Bool progress_out = False; | ||
365 | EState* s = strm->state; | ||
366 | |||
367 | while (True) { | ||
368 | |||
369 | if (s->state == BZ_S_OUTPUT) { | ||
370 | progress_out |= copy_output_until_stop ( s ); | ||
371 | if (s->state_out_pos < s->numZ) break; | ||
372 | if (s->mode == BZ_M_FINISHING && | ||
373 | s->avail_in_expect == 0 && | ||
374 | isempty_RL(s)) break; | ||
375 | prepare_new_block ( s ); | ||
376 | s->state = BZ_S_INPUT; | ||
377 | if (s->mode == BZ_M_FLUSHING && | ||
378 | s->avail_in_expect == 0 && | ||
379 | isempty_RL(s)) break; | ||
380 | } | ||
381 | |||
382 | if (s->state == BZ_S_INPUT) { | ||
383 | progress_in |= copy_input_until_stop ( s ); | ||
384 | if (s->mode != BZ_M_RUNNING && s->avail_in_expect == 0) { | ||
385 | flush_RL ( s ); | ||
386 | BZ2_compressBlock ( s, (Bool)(s->mode == BZ_M_FINISHING) ); | ||
387 | s->state = BZ_S_OUTPUT; | ||
388 | } | ||
389 | else | ||
390 | if (s->nblock >= s->nblockMAX) { | ||
391 | BZ2_compressBlock ( s, False ); | ||
392 | s->state = BZ_S_OUTPUT; | ||
393 | } | ||
394 | else | ||
395 | if (s->strm->avail_in == 0) { | ||
396 | break; | ||
397 | } | ||
398 | } | ||
399 | |||
400 | } | ||
401 | |||
402 | return progress_in || progress_out; | ||
403 | } | ||
404 | |||
405 | |||
406 | /*---------------------------------------------------*/ | ||
407 | int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action ) | ||
408 | { | ||
409 | Bool progress; | ||
410 | EState* s; | ||
411 | if (strm == NULL) return BZ_PARAM_ERROR; | ||
412 | s = strm->state; | ||
413 | if (s == NULL) return BZ_PARAM_ERROR; | ||
414 | if (s->strm != strm) return BZ_PARAM_ERROR; | ||
415 | |||
416 | preswitch: | ||
417 | switch (s->mode) { | ||
418 | |||
419 | case BZ_M_IDLE: | ||
420 | return BZ_SEQUENCE_ERROR; | ||
421 | |||
422 | case BZ_M_RUNNING: | ||
423 | if (action == BZ_RUN) { | ||
424 | progress = handle_compress ( strm ); | ||
425 | return progress ? BZ_RUN_OK : BZ_PARAM_ERROR; | ||
426 | } | ||
427 | else | ||
428 | if (action == BZ_FLUSH) { | ||
429 | s->avail_in_expect = strm->avail_in; | ||
430 | s->mode = BZ_M_FLUSHING; | ||
431 | goto preswitch; | ||
432 | } | ||
433 | else | ||
434 | if (action == BZ_FINISH) { | ||
435 | s->avail_in_expect = strm->avail_in; | ||
436 | s->mode = BZ_M_FINISHING; | ||
437 | goto preswitch; | ||
438 | } | ||
439 | else | ||
440 | return BZ_PARAM_ERROR; | ||
441 | |||
442 | case BZ_M_FLUSHING: | ||
443 | if (action != BZ_FLUSH) return BZ_SEQUENCE_ERROR; | ||
444 | if (s->avail_in_expect != s->strm->avail_in) | ||
445 | return BZ_SEQUENCE_ERROR; | ||
446 | progress = handle_compress ( strm ); | ||
447 | if (s->avail_in_expect > 0 || !isempty_RL(s) || | ||
448 | s->state_out_pos < s->numZ) return BZ_FLUSH_OK; | ||
449 | s->mode = BZ_M_RUNNING; | ||
450 | return BZ_RUN_OK; | ||
451 | |||
452 | case BZ_M_FINISHING: | ||
453 | if (action != BZ_FINISH) return BZ_SEQUENCE_ERROR; | ||
454 | if (s->avail_in_expect != s->strm->avail_in) | ||
455 | return BZ_SEQUENCE_ERROR; | ||
456 | progress = handle_compress ( strm ); | ||
457 | if (!progress) return BZ_SEQUENCE_ERROR; | ||
458 | if (s->avail_in_expect > 0 || !isempty_RL(s) || | ||
459 | s->state_out_pos < s->numZ) return BZ_FINISH_OK; | ||
460 | s->mode = BZ_M_IDLE; | ||
461 | return BZ_STREAM_END; | ||
462 | } | ||
463 | return BZ_OK; /*--not reached--*/ | ||
464 | } | ||
465 | |||
466 | |||
467 | /*---------------------------------------------------*/ | ||
468 | int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm ) | ||
469 | { | ||
470 | EState* s; | ||
471 | if (strm == NULL) return BZ_PARAM_ERROR; | ||
472 | s = strm->state; | ||
473 | if (s == NULL) return BZ_PARAM_ERROR; | ||
474 | if (s->strm != strm) return BZ_PARAM_ERROR; | ||
475 | |||
476 | if (s->arr1 != NULL) BZFREE(s->arr1); | ||
477 | if (s->arr2 != NULL) BZFREE(s->arr2); | ||
478 | if (s->ftab != NULL) BZFREE(s->ftab); | ||
479 | BZFREE(strm->state); | ||
480 | |||
481 | strm->state = NULL; | ||
482 | |||
483 | return BZ_OK; | ||
484 | } | ||
485 | |||
486 | |||
487 | /*---------------------------------------------------*/ | ||
488 | /*--- Decompression stuff ---*/ | ||
489 | /*---------------------------------------------------*/ | ||
490 | |||
491 | /*---------------------------------------------------*/ | ||
492 | int BZ_API(BZ2_bzDecompressInit) | ||
493 | ( bz_stream* strm, | ||
494 | int verbosity, | ||
495 | int small ) | ||
496 | { | ||
497 | DState* s; | ||
498 | |||
499 | if (!bz_config_ok()) return BZ_CONFIG_ERROR; | ||
500 | |||
501 | if (strm == NULL) return BZ_PARAM_ERROR; | ||
502 | if (small != 0 && small != 1) return BZ_PARAM_ERROR; | ||
503 | if (verbosity < 0 || verbosity > 4) return BZ_PARAM_ERROR; | ||
504 | |||
505 | if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc; | ||
506 | if (strm->bzfree == NULL) strm->bzfree = default_bzfree; | ||
507 | |||
508 | s = BZALLOC( sizeof(DState) ); | ||
509 | if (s == NULL) return BZ_MEM_ERROR; | ||
510 | s->strm = strm; | ||
511 | strm->state = s; | ||
512 | s->state = BZ_X_MAGIC_1; | ||
513 | s->bsLive = 0; | ||
514 | s->bsBuff = 0; | ||
515 | s->calculatedCombinedCRC = 0; | ||
516 | strm->total_in_lo32 = 0; | ||
517 | strm->total_in_hi32 = 0; | ||
518 | strm->total_out_lo32 = 0; | ||
519 | strm->total_out_hi32 = 0; | ||
520 | s->smallDecompress = (Bool)small; | ||
521 | s->ll4 = NULL; | ||
522 | s->ll16 = NULL; | ||
523 | s->tt = NULL; | ||
524 | s->currBlockNo = 0; | ||
525 | s->verbosity = verbosity; | ||
526 | |||
527 | return BZ_OK; | ||
528 | } | ||
529 | |||
530 | |||
531 | /*---------------------------------------------------*/ | ||
532 | /* Return True iff data corruption is discovered. | ||
533 | Returns False if there is no problem. | ||
534 | */ | ||
535 | static | ||
536 | Bool unRLE_obuf_to_output_FAST ( DState* s ) | ||
537 | { | ||
538 | UChar k1; | ||
539 | |||
540 | if (s->blockRandomised) { | ||
541 | |||
542 | while (True) { | ||
543 | /* try to finish existing run */ | ||
544 | while (True) { | ||
545 | if (s->strm->avail_out == 0) return False; | ||
546 | if (s->state_out_len == 0) break; | ||
547 | *( (UChar*)(s->strm->next_out) ) = s->state_out_ch; | ||
548 | BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch ); | ||
549 | s->state_out_len--; | ||
550 | s->strm->next_out++; | ||
551 | s->strm->avail_out--; | ||
552 | s->strm->total_out_lo32++; | ||
553 | if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; | ||
554 | } | ||
555 | |||
556 | /* can a new run be started? */ | ||
557 | if (s->nblock_used == s->save_nblock+1) return False; | ||
558 | |||
559 | /* Only caused by corrupt data stream? */ | ||
560 | if (s->nblock_used > s->save_nblock+1) | ||
561 | return True; | ||
562 | |||
563 | s->state_out_len = 1; | ||
564 | s->state_out_ch = s->k0; | ||
565 | BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; | ||
566 | k1 ^= BZ_RAND_MASK; s->nblock_used++; | ||
567 | if (s->nblock_used == s->save_nblock+1) continue; | ||
568 | if (k1 != s->k0) { s->k0 = k1; continue; }; | ||
569 | |||
570 | s->state_out_len = 2; | ||
571 | BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; | ||
572 | k1 ^= BZ_RAND_MASK; s->nblock_used++; | ||
573 | if (s->nblock_used == s->save_nblock+1) continue; | ||
574 | if (k1 != s->k0) { s->k0 = k1; continue; }; | ||
575 | |||
576 | s->state_out_len = 3; | ||
577 | BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; | ||
578 | k1 ^= BZ_RAND_MASK; s->nblock_used++; | ||
579 | if (s->nblock_used == s->save_nblock+1) continue; | ||
580 | if (k1 != s->k0) { s->k0 = k1; continue; }; | ||
581 | |||
582 | BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; | ||
583 | k1 ^= BZ_RAND_MASK; s->nblock_used++; | ||
584 | s->state_out_len = ((Int32)k1) + 4; | ||
585 | BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK; | ||
586 | s->k0 ^= BZ_RAND_MASK; s->nblock_used++; | ||
587 | } | ||
588 | |||
589 | } else { | ||
590 | |||
591 | /* restore */ | ||
592 | UInt32 c_calculatedBlockCRC = s->calculatedBlockCRC; | ||
593 | UChar c_state_out_ch = s->state_out_ch; | ||
594 | Int32 c_state_out_len = s->state_out_len; | ||
595 | Int32 c_nblock_used = s->nblock_used; | ||
596 | Int32 c_k0 = s->k0; | ||
597 | UInt32* c_tt = s->tt; | ||
598 | UInt32 c_tPos = s->tPos; | ||
599 | char* cs_next_out = s->strm->next_out; | ||
600 | unsigned int cs_avail_out = s->strm->avail_out; | ||
601 | Int32 ro_blockSize100k = s->blockSize100k; | ||
602 | /* end restore */ | ||
603 | |||
604 | UInt32 avail_out_INIT = cs_avail_out; | ||
605 | Int32 s_save_nblockPP = s->save_nblock+1; | ||
606 | unsigned int total_out_lo32_old; | ||
607 | |||
608 | while (True) { | ||
609 | |||
610 | /* try to finish existing run */ | ||
611 | if (c_state_out_len > 0) { | ||
612 | while (True) { | ||
613 | if (cs_avail_out == 0) goto return_notr; | ||
614 | if (c_state_out_len == 1) break; | ||
615 | *( (UChar*)(cs_next_out) ) = c_state_out_ch; | ||
616 | BZ_UPDATE_CRC ( c_calculatedBlockCRC, c_state_out_ch ); | ||
617 | c_state_out_len--; | ||
618 | cs_next_out++; | ||
619 | cs_avail_out--; | ||
620 | } | ||
621 | s_state_out_len_eq_one: | ||
622 | { | ||
623 | if (cs_avail_out == 0) { | ||
624 | c_state_out_len = 1; goto return_notr; | ||
625 | }; | ||
626 | *( (UChar*)(cs_next_out) ) = c_state_out_ch; | ||
627 | BZ_UPDATE_CRC ( c_calculatedBlockCRC, c_state_out_ch ); | ||
628 | cs_next_out++; | ||
629 | cs_avail_out--; | ||
630 | } | ||
631 | } | ||
632 | /* Only caused by corrupt data stream? */ | ||
633 | if (c_nblock_used > s_save_nblockPP) | ||
634 | return True; | ||
635 | |||
636 | /* can a new run be started? */ | ||
637 | if (c_nblock_used == s_save_nblockPP) { | ||
638 | c_state_out_len = 0; goto return_notr; | ||
639 | }; | ||
640 | c_state_out_ch = c_k0; | ||
641 | BZ_GET_FAST_C(k1); c_nblock_used++; | ||
642 | if (k1 != c_k0) { | ||
643 | c_k0 = k1; goto s_state_out_len_eq_one; | ||
644 | }; | ||
645 | if (c_nblock_used == s_save_nblockPP) | ||
646 | goto s_state_out_len_eq_one; | ||
647 | |||
648 | c_state_out_len = 2; | ||
649 | BZ_GET_FAST_C(k1); c_nblock_used++; | ||
650 | if (c_nblock_used == s_save_nblockPP) continue; | ||
651 | if (k1 != c_k0) { c_k0 = k1; continue; }; | ||
652 | |||
653 | c_state_out_len = 3; | ||
654 | BZ_GET_FAST_C(k1); c_nblock_used++; | ||
655 | if (c_nblock_used == s_save_nblockPP) continue; | ||
656 | if (k1 != c_k0) { c_k0 = k1; continue; }; | ||
657 | |||
658 | BZ_GET_FAST_C(k1); c_nblock_used++; | ||
659 | c_state_out_len = ((Int32)k1) + 4; | ||
660 | BZ_GET_FAST_C(c_k0); c_nblock_used++; | ||
661 | } | ||
662 | |||
663 | return_notr: | ||
664 | total_out_lo32_old = s->strm->total_out_lo32; | ||
665 | s->strm->total_out_lo32 += (avail_out_INIT - cs_avail_out); | ||
666 | if (s->strm->total_out_lo32 < total_out_lo32_old) | ||
667 | s->strm->total_out_hi32++; | ||
668 | |||
669 | /* save */ | ||
670 | s->calculatedBlockCRC = c_calculatedBlockCRC; | ||
671 | s->state_out_ch = c_state_out_ch; | ||
672 | s->state_out_len = c_state_out_len; | ||
673 | s->nblock_used = c_nblock_used; | ||
674 | s->k0 = c_k0; | ||
675 | s->tt = c_tt; | ||
676 | s->tPos = c_tPos; | ||
677 | s->strm->next_out = cs_next_out; | ||
678 | s->strm->avail_out = cs_avail_out; | ||
679 | /* end save */ | ||
680 | } | ||
681 | return False; | ||
682 | } | ||
683 | |||
684 | |||
685 | |||
686 | /*---------------------------------------------------*/ | ||
687 | __inline__ Int32 BZ2_indexIntoF ( Int32 indx, Int32 *cftab ) | ||
688 | { | ||
689 | Int32 nb, na, mid; | ||
690 | nb = 0; | ||
691 | na = 256; | ||
692 | do { | ||
693 | mid = (nb + na) >> 1; | ||
694 | if (indx >= cftab[mid]) nb = mid; else na = mid; | ||
695 | } | ||
696 | while (na - nb != 1); | ||
697 | return nb; | ||
698 | } | ||
699 | |||
700 | |||
701 | /*---------------------------------------------------*/ | ||
702 | /* Return True iff data corruption is discovered. | ||
703 | Returns False if there is no problem. | ||
704 | */ | ||
705 | static | ||
706 | Bool unRLE_obuf_to_output_SMALL ( DState* s ) | ||
707 | { | ||
708 | UChar k1; | ||
709 | |||
710 | if (s->blockRandomised) { | ||
711 | |||
712 | while (True) { | ||
713 | /* try to finish existing run */ | ||
714 | while (True) { | ||
715 | if (s->strm->avail_out == 0) return False; | ||
716 | if (s->state_out_len == 0) break; | ||
717 | *( (UChar*)(s->strm->next_out) ) = s->state_out_ch; | ||
718 | BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch ); | ||
719 | s->state_out_len--; | ||
720 | s->strm->next_out++; | ||
721 | s->strm->avail_out--; | ||
722 | s->strm->total_out_lo32++; | ||
723 | if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; | ||
724 | } | ||
725 | |||
726 | /* can a new run be started? */ | ||
727 | if (s->nblock_used == s->save_nblock+1) return False; | ||
728 | |||
729 | /* Only caused by corrupt data stream? */ | ||
730 | if (s->nblock_used > s->save_nblock+1) | ||
731 | return True; | ||
732 | |||
733 | s->state_out_len = 1; | ||
734 | s->state_out_ch = s->k0; | ||
735 | BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; | ||
736 | k1 ^= BZ_RAND_MASK; s->nblock_used++; | ||
737 | if (s->nblock_used == s->save_nblock+1) continue; | ||
738 | if (k1 != s->k0) { s->k0 = k1; continue; }; | ||
739 | |||
740 | s->state_out_len = 2; | ||
741 | BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; | ||
742 | k1 ^= BZ_RAND_MASK; s->nblock_used++; | ||
743 | if (s->nblock_used == s->save_nblock+1) continue; | ||
744 | if (k1 != s->k0) { s->k0 = k1; continue; }; | ||
745 | |||
746 | s->state_out_len = 3; | ||
747 | BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; | ||
748 | k1 ^= BZ_RAND_MASK; s->nblock_used++; | ||
749 | if (s->nblock_used == s->save_nblock+1) continue; | ||
750 | if (k1 != s->k0) { s->k0 = k1; continue; }; | ||
751 | |||
752 | BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; | ||
753 | k1 ^= BZ_RAND_MASK; s->nblock_used++; | ||
754 | s->state_out_len = ((Int32)k1) + 4; | ||
755 | BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK; | ||
756 | s->k0 ^= BZ_RAND_MASK; s->nblock_used++; | ||
757 | } | ||
758 | |||
759 | } else { | ||
760 | |||
761 | while (True) { | ||
762 | /* try to finish existing run */ | ||
763 | while (True) { | ||
764 | if (s->strm->avail_out == 0) return False; | ||
765 | if (s->state_out_len == 0) break; | ||
766 | *( (UChar*)(s->strm->next_out) ) = s->state_out_ch; | ||
767 | BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch ); | ||
768 | s->state_out_len--; | ||
769 | s->strm->next_out++; | ||
770 | s->strm->avail_out--; | ||
771 | s->strm->total_out_lo32++; | ||
772 | if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; | ||
773 | } | ||
774 | |||
775 | /* can a new run be started? */ | ||
776 | if (s->nblock_used == s->save_nblock+1) return False; | ||
777 | |||
778 | /* Only caused by corrupt data stream? */ | ||
779 | if (s->nblock_used > s->save_nblock+1) | ||
780 | return True; | ||
781 | |||
782 | s->state_out_len = 1; | ||
783 | s->state_out_ch = s->k0; | ||
784 | BZ_GET_SMALL(k1); s->nblock_used++; | ||
785 | if (s->nblock_used == s->save_nblock+1) continue; | ||
786 | if (k1 != s->k0) { s->k0 = k1; continue; }; | ||
787 | |||
788 | s->state_out_len = 2; | ||
789 | BZ_GET_SMALL(k1); s->nblock_used++; | ||
790 | if (s->nblock_used == s->save_nblock+1) continue; | ||
791 | if (k1 != s->k0) { s->k0 = k1; continue; }; | ||
792 | |||
793 | s->state_out_len = 3; | ||
794 | BZ_GET_SMALL(k1); s->nblock_used++; | ||
795 | if (s->nblock_used == s->save_nblock+1) continue; | ||
796 | if (k1 != s->k0) { s->k0 = k1; continue; }; | ||
797 | |||
798 | BZ_GET_SMALL(k1); s->nblock_used++; | ||
799 | s->state_out_len = ((Int32)k1) + 4; | ||
800 | BZ_GET_SMALL(s->k0); s->nblock_used++; | ||
801 | } | ||
802 | |||
803 | } | ||
804 | } | ||
805 | |||
806 | |||
807 | /*---------------------------------------------------*/ | ||
808 | int BZ_API(BZ2_bzDecompress) ( bz_stream *strm ) | ||
809 | { | ||
810 | Bool corrupt; | ||
811 | DState* s; | ||
812 | if (strm == NULL) return BZ_PARAM_ERROR; | ||
813 | s = strm->state; | ||
814 | if (s == NULL) return BZ_PARAM_ERROR; | ||
815 | if (s->strm != strm) return BZ_PARAM_ERROR; | ||
816 | |||
817 | while (True) { | ||
818 | if (s->state == BZ_X_IDLE) return BZ_SEQUENCE_ERROR; | ||
819 | if (s->state == BZ_X_OUTPUT) { | ||
820 | if (s->smallDecompress) | ||
821 | corrupt = unRLE_obuf_to_output_SMALL ( s ); else | ||
822 | corrupt = unRLE_obuf_to_output_FAST ( s ); | ||
823 | if (corrupt) return BZ_DATA_ERROR; | ||
824 | if (s->nblock_used == s->save_nblock+1 && s->state_out_len == 0) { | ||
825 | BZ_FINALISE_CRC ( s->calculatedBlockCRC ); | ||
826 | if (s->verbosity >= 3) | ||
827 | VPrintf2 ( " {0x%08x, 0x%08x}", s->storedBlockCRC, | ||
828 | s->calculatedBlockCRC ); | ||
829 | if (s->verbosity >= 2) VPrintf0 ( "]" ); | ||
830 | if (s->calculatedBlockCRC != s->storedBlockCRC) | ||
831 | return BZ_DATA_ERROR; | ||
832 | s->calculatedCombinedCRC | ||
833 | = (s->calculatedCombinedCRC << 1) | | ||
834 | (s->calculatedCombinedCRC >> 31); | ||
835 | s->calculatedCombinedCRC ^= s->calculatedBlockCRC; | ||
836 | s->state = BZ_X_BLKHDR_1; | ||
837 | } else { | ||
838 | return BZ_OK; | ||
839 | } | ||
840 | } | ||
841 | if (s->state >= BZ_X_MAGIC_1) { | ||
842 | Int32 r = BZ2_decompress ( s ); | ||
843 | if (r == BZ_STREAM_END) { | ||
844 | if (s->verbosity >= 3) | ||
845 | VPrintf2 ( "\n combined CRCs: stored = 0x%08x, computed = 0x%08x", | ||
846 | s->storedCombinedCRC, s->calculatedCombinedCRC ); | ||
847 | if (s->calculatedCombinedCRC != s->storedCombinedCRC) | ||
848 | return BZ_DATA_ERROR; | ||
849 | return r; | ||
850 | } | ||
851 | if (s->state != BZ_X_OUTPUT) return r; | ||
852 | } | ||
853 | } | ||
854 | |||
855 | AssertH ( 0, 6001 ); | ||
856 | |||
857 | return 0; /*NOTREACHED*/ | ||
858 | } | ||
859 | |||
860 | |||
861 | /*---------------------------------------------------*/ | ||
862 | int BZ_API(BZ2_bzDecompressEnd) ( bz_stream *strm ) | ||
863 | { | ||
864 | DState* s; | ||
865 | if (strm == NULL) return BZ_PARAM_ERROR; | ||
866 | s = strm->state; | ||
867 | if (s == NULL) return BZ_PARAM_ERROR; | ||
868 | if (s->strm != strm) return BZ_PARAM_ERROR; | ||
869 | |||
870 | if (s->tt != NULL) BZFREE(s->tt); | ||
871 | if (s->ll16 != NULL) BZFREE(s->ll16); | ||
872 | if (s->ll4 != NULL) BZFREE(s->ll4); | ||
873 | |||
874 | BZFREE(strm->state); | ||
875 | strm->state = NULL; | ||
876 | |||
877 | return BZ_OK; | ||
878 | } | ||
879 | |||
880 | |||
881 | #ifndef BZ_NO_STDIO | ||
882 | /*---------------------------------------------------*/ | ||
883 | /*--- File I/O stuff ---*/ | ||
884 | /*---------------------------------------------------*/ | ||
885 | |||
886 | #define BZ_SETERR(eee) \ | ||
887 | { \ | ||
888 | if (bzerror != NULL) *bzerror = eee; \ | ||
889 | if (bzf != NULL) bzf->lastErr = eee; \ | ||
890 | } | ||
891 | |||
892 | typedef | ||
893 | struct { | ||
894 | FILE* handle; | ||
895 | Char buf[BZ_MAX_UNUSED]; | ||
896 | Int32 bufN; | ||
897 | Bool writing; | ||
898 | bz_stream strm; | ||
899 | Int32 lastErr; | ||
900 | Bool initialisedOk; | ||
901 | } | ||
902 | bzFile; | ||
903 | |||
904 | |||
905 | /*---------------------------------------------*/ | ||
906 | static Bool myfeof ( FILE* f ) | ||
907 | { | ||
908 | Int32 c = fgetc ( f ); | ||
909 | if (c == EOF) return True; | ||
910 | ungetc ( c, f ); | ||
911 | return False; | ||
912 | } | ||
913 | |||
914 | |||
915 | /*---------------------------------------------------*/ | ||
916 | BZFILE* BZ_API(BZ2_bzWriteOpen) | ||
917 | ( int* bzerror, | ||
918 | FILE* f, | ||
919 | int blockSize100k, | ||
920 | int verbosity, | ||
921 | int workFactor ) | ||
922 | { | ||
923 | Int32 ret; | ||
924 | bzFile* bzf = NULL; | ||
925 | |||
926 | BZ_SETERR(BZ_OK); | ||
927 | |||
928 | if (f == NULL || | ||
929 | (blockSize100k < 1 || blockSize100k > 9) || | ||
930 | (workFactor < 0 || workFactor > 250) || | ||
931 | (verbosity < 0 || verbosity > 4)) | ||
932 | { BZ_SETERR(BZ_PARAM_ERROR); return NULL; }; | ||
933 | |||
934 | if (ferror(f)) | ||
935 | { BZ_SETERR(BZ_IO_ERROR); return NULL; }; | ||
936 | |||
937 | bzf = malloc ( sizeof(bzFile) ); | ||
938 | if (bzf == NULL) | ||
939 | { BZ_SETERR(BZ_MEM_ERROR); return NULL; }; | ||
940 | |||
941 | BZ_SETERR(BZ_OK); | ||
942 | bzf->initialisedOk = False; | ||
943 | bzf->bufN = 0; | ||
944 | bzf->handle = f; | ||
945 | bzf->writing = True; | ||
946 | bzf->strm.bzalloc = NULL; | ||
947 | bzf->strm.bzfree = NULL; | ||
948 | bzf->strm.opaque = NULL; | ||
949 | |||
950 | if (workFactor == 0) workFactor = 30; | ||
951 | ret = BZ2_bzCompressInit ( &(bzf->strm), blockSize100k, | ||
952 | verbosity, workFactor ); | ||
953 | if (ret != BZ_OK) | ||
954 | { BZ_SETERR(ret); free(bzf); return NULL; }; | ||
955 | |||
956 | bzf->strm.avail_in = 0; | ||
957 | bzf->initialisedOk = True; | ||
958 | return bzf; | ||
959 | } | ||
960 | |||
961 | |||
962 | |||
963 | /*---------------------------------------------------*/ | ||
964 | void BZ_API(BZ2_bzWrite) | ||
965 | ( int* bzerror, | ||
966 | BZFILE* b, | ||
967 | void* buf, | ||
968 | int len ) | ||
969 | { | ||
970 | Int32 n, n2, ret; | ||
971 | bzFile* bzf = (bzFile*)b; | ||
972 | |||
973 | BZ_SETERR(BZ_OK); | ||
974 | if (bzf == NULL || buf == NULL || len < 0) | ||
975 | { BZ_SETERR(BZ_PARAM_ERROR); return; }; | ||
976 | if (!(bzf->writing)) | ||
977 | { BZ_SETERR(BZ_SEQUENCE_ERROR); return; }; | ||
978 | if (ferror(bzf->handle)) | ||
979 | { BZ_SETERR(BZ_IO_ERROR); return; }; | ||
980 | |||
981 | if (len == 0) | ||
982 | { BZ_SETERR(BZ_OK); return; }; | ||
983 | |||
984 | bzf->strm.avail_in = len; | ||
985 | bzf->strm.next_in = buf; | ||
986 | |||
987 | while (True) { | ||
988 | bzf->strm.avail_out = BZ_MAX_UNUSED; | ||
989 | bzf->strm.next_out = bzf->buf; | ||
990 | ret = BZ2_bzCompress ( &(bzf->strm), BZ_RUN ); | ||
991 | if (ret != BZ_RUN_OK) | ||
992 | { BZ_SETERR(ret); return; }; | ||
993 | |||
994 | if (bzf->strm.avail_out < BZ_MAX_UNUSED) { | ||
995 | n = BZ_MAX_UNUSED - bzf->strm.avail_out; | ||
996 | n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), | ||
997 | n, bzf->handle ); | ||
998 | if (n != n2 || ferror(bzf->handle)) | ||
999 | { BZ_SETERR(BZ_IO_ERROR); return; }; | ||
1000 | } | ||
1001 | |||
1002 | if (bzf->strm.avail_in == 0) | ||
1003 | { BZ_SETERR(BZ_OK); return; }; | ||
1004 | } | ||
1005 | } | ||
1006 | |||
1007 | |||
1008 | /*---------------------------------------------------*/ | ||
1009 | void BZ_API(BZ2_bzWriteClose) | ||
1010 | ( int* bzerror, | ||
1011 | BZFILE* b, | ||
1012 | int abandon, | ||
1013 | unsigned int* nbytes_in, | ||
1014 | unsigned int* nbytes_out ) | ||
1015 | { | ||
1016 | BZ2_bzWriteClose64 ( bzerror, b, abandon, | ||
1017 | nbytes_in, NULL, nbytes_out, NULL ); | ||
1018 | } | ||
1019 | |||
1020 | |||
1021 | void BZ_API(BZ2_bzWriteClose64) | ||
1022 | ( int* bzerror, | ||
1023 | BZFILE* b, | ||
1024 | int abandon, | ||
1025 | unsigned int* nbytes_in_lo32, | ||
1026 | unsigned int* nbytes_in_hi32, | ||
1027 | unsigned int* nbytes_out_lo32, | ||
1028 | unsigned int* nbytes_out_hi32 ) | ||
1029 | { | ||
1030 | Int32 n, n2, ret; | ||
1031 | bzFile* bzf = (bzFile*)b; | ||
1032 | |||
1033 | if (bzf == NULL) | ||
1034 | { BZ_SETERR(BZ_OK); return; }; | ||
1035 | if (!(bzf->writing)) | ||
1036 | { BZ_SETERR(BZ_SEQUENCE_ERROR); return; }; | ||
1037 | if (ferror(bzf->handle)) | ||
1038 | { BZ_SETERR(BZ_IO_ERROR); return; }; | ||
1039 | |||
1040 | if (nbytes_in_lo32 != NULL) *nbytes_in_lo32 = 0; | ||
1041 | if (nbytes_in_hi32 != NULL) *nbytes_in_hi32 = 0; | ||
1042 | if (nbytes_out_lo32 != NULL) *nbytes_out_lo32 = 0; | ||
1043 | if (nbytes_out_hi32 != NULL) *nbytes_out_hi32 = 0; | ||
1044 | |||
1045 | if ((!abandon) && bzf->lastErr == BZ_OK) { | ||
1046 | while (True) { | ||
1047 | bzf->strm.avail_out = BZ_MAX_UNUSED; | ||
1048 | bzf->strm.next_out = bzf->buf; | ||
1049 | ret = BZ2_bzCompress ( &(bzf->strm), BZ_FINISH ); | ||
1050 | if (ret != BZ_FINISH_OK && ret != BZ_STREAM_END) | ||
1051 | { BZ_SETERR(ret); return; }; | ||
1052 | |||
1053 | if (bzf->strm.avail_out < BZ_MAX_UNUSED) { | ||
1054 | n = BZ_MAX_UNUSED - bzf->strm.avail_out; | ||
1055 | n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), | ||
1056 | n, bzf->handle ); | ||
1057 | if (n != n2 || ferror(bzf->handle)) | ||
1058 | { BZ_SETERR(BZ_IO_ERROR); return; }; | ||
1059 | } | ||
1060 | |||
1061 | if (ret == BZ_STREAM_END) break; | ||
1062 | } | ||
1063 | } | ||
1064 | |||
1065 | if ( !abandon && !ferror ( bzf->handle ) ) { | ||
1066 | fflush ( bzf->handle ); | ||
1067 | if (ferror(bzf->handle)) | ||
1068 | { BZ_SETERR(BZ_IO_ERROR); return; }; | ||
1069 | } | ||
1070 | |||
1071 | if (nbytes_in_lo32 != NULL) | ||
1072 | *nbytes_in_lo32 = bzf->strm.total_in_lo32; | ||
1073 | if (nbytes_in_hi32 != NULL) | ||
1074 | *nbytes_in_hi32 = bzf->strm.total_in_hi32; | ||
1075 | if (nbytes_out_lo32 != NULL) | ||
1076 | *nbytes_out_lo32 = bzf->strm.total_out_lo32; | ||
1077 | if (nbytes_out_hi32 != NULL) | ||
1078 | *nbytes_out_hi32 = bzf->strm.total_out_hi32; | ||
1079 | |||
1080 | BZ_SETERR(BZ_OK); | ||
1081 | BZ2_bzCompressEnd ( &(bzf->strm) ); | ||
1082 | free ( bzf ); | ||
1083 | } | ||
1084 | |||
1085 | |||
1086 | /*---------------------------------------------------*/ | ||
1087 | BZFILE* BZ_API(BZ2_bzReadOpen) | ||
1088 | ( int* bzerror, | ||
1089 | FILE* f, | ||
1090 | int verbosity, | ||
1091 | int small, | ||
1092 | void* unused, | ||
1093 | int nUnused ) | ||
1094 | { | ||
1095 | bzFile* bzf = NULL; | ||
1096 | int ret; | ||
1097 | |||
1098 | BZ_SETERR(BZ_OK); | ||
1099 | |||
1100 | if (f == NULL || | ||
1101 | (small != 0 && small != 1) || | ||
1102 | (verbosity < 0 || verbosity > 4) || | ||
1103 | (unused == NULL && nUnused != 0) || | ||
1104 | (unused != NULL && (nUnused < 0 || nUnused > BZ_MAX_UNUSED))) | ||
1105 | { BZ_SETERR(BZ_PARAM_ERROR); return NULL; }; | ||
1106 | |||
1107 | if (ferror(f)) | ||
1108 | { BZ_SETERR(BZ_IO_ERROR); return NULL; }; | ||
1109 | |||
1110 | bzf = malloc ( sizeof(bzFile) ); | ||
1111 | if (bzf == NULL) | ||
1112 | { BZ_SETERR(BZ_MEM_ERROR); return NULL; }; | ||
1113 | |||
1114 | BZ_SETERR(BZ_OK); | ||
1115 | |||
1116 | bzf->initialisedOk = False; | ||
1117 | bzf->handle = f; | ||
1118 | bzf->bufN = 0; | ||
1119 | bzf->writing = False; | ||
1120 | bzf->strm.bzalloc = NULL; | ||
1121 | bzf->strm.bzfree = NULL; | ||
1122 | bzf->strm.opaque = NULL; | ||
1123 | |||
1124 | while (nUnused > 0) { | ||
1125 | bzf->buf[bzf->bufN] = *((UChar*)(unused)); bzf->bufN++; | ||
1126 | unused = ((void*)( 1 + ((UChar*)(unused)) )); | ||
1127 | nUnused--; | ||
1128 | } | ||
1129 | |||
1130 | ret = BZ2_bzDecompressInit ( &(bzf->strm), verbosity, small ); | ||
1131 | if (ret != BZ_OK) | ||
1132 | { BZ_SETERR(ret); free(bzf); return NULL; }; | ||
1133 | |||
1134 | bzf->strm.avail_in = bzf->bufN; | ||
1135 | bzf->strm.next_in = bzf->buf; | ||
1136 | |||
1137 | bzf->initialisedOk = True; | ||
1138 | return bzf; | ||
1139 | } | ||
1140 | |||
1141 | |||
1142 | /*---------------------------------------------------*/ | ||
1143 | void BZ_API(BZ2_bzReadClose) ( int *bzerror, BZFILE *b ) | ||
1144 | { | ||
1145 | bzFile* bzf = (bzFile*)b; | ||
1146 | |||
1147 | BZ_SETERR(BZ_OK); | ||
1148 | if (bzf == NULL) | ||
1149 | { BZ_SETERR(BZ_OK); return; }; | ||
1150 | |||
1151 | if (bzf->writing) | ||
1152 | { BZ_SETERR(BZ_SEQUENCE_ERROR); return; }; | ||
1153 | |||
1154 | if (bzf->initialisedOk) | ||
1155 | (void)BZ2_bzDecompressEnd ( &(bzf->strm) ); | ||
1156 | free ( bzf ); | ||
1157 | } | ||
1158 | |||
1159 | |||
1160 | /*---------------------------------------------------*/ | ||
1161 | int BZ_API(BZ2_bzRead) | ||
1162 | ( int* bzerror, | ||
1163 | BZFILE* b, | ||
1164 | void* buf, | ||
1165 | int len ) | ||
1166 | { | ||
1167 | Int32 n, ret; | ||
1168 | bzFile* bzf = (bzFile*)b; | ||
1169 | |||
1170 | BZ_SETERR(BZ_OK); | ||
1171 | |||
1172 | if (bzf == NULL || buf == NULL || len < 0) | ||
1173 | { BZ_SETERR(BZ_PARAM_ERROR); return 0; }; | ||
1174 | |||
1175 | if (bzf->writing) | ||
1176 | { BZ_SETERR(BZ_SEQUENCE_ERROR); return 0; }; | ||
1177 | |||
1178 | if (len == 0) | ||
1179 | { BZ_SETERR(BZ_OK); return 0; }; | ||
1180 | |||
1181 | bzf->strm.avail_out = len; | ||
1182 | bzf->strm.next_out = buf; | ||
1183 | |||
1184 | while (True) { | ||
1185 | |||
1186 | if (ferror(bzf->handle)) | ||
1187 | { BZ_SETERR(BZ_IO_ERROR); return 0; }; | ||
1188 | |||
1189 | if (bzf->strm.avail_in == 0 && !myfeof(bzf->handle)) { | ||
1190 | n = fread ( bzf->buf, sizeof(UChar), | ||
1191 | BZ_MAX_UNUSED, bzf->handle ); | ||
1192 | if (ferror(bzf->handle)) | ||
1193 | { BZ_SETERR(BZ_IO_ERROR); return 0; }; | ||
1194 | bzf->bufN = n; | ||
1195 | bzf->strm.avail_in = bzf->bufN; | ||
1196 | bzf->strm.next_in = bzf->buf; | ||
1197 | } | ||
1198 | |||
1199 | ret = BZ2_bzDecompress ( &(bzf->strm) ); | ||
1200 | |||
1201 | if (ret != BZ_OK && ret != BZ_STREAM_END) | ||
1202 | { BZ_SETERR(ret); return 0; }; | ||
1203 | |||
1204 | if (ret == BZ_OK && myfeof(bzf->handle) && | ||
1205 | bzf->strm.avail_in == 0 && bzf->strm.avail_out > 0) | ||
1206 | { BZ_SETERR(BZ_UNEXPECTED_EOF); return 0; }; | ||
1207 | |||
1208 | if (ret == BZ_STREAM_END) | ||
1209 | { BZ_SETERR(BZ_STREAM_END); | ||
1210 | return len - bzf->strm.avail_out; }; | ||
1211 | if (bzf->strm.avail_out == 0) | ||
1212 | { BZ_SETERR(BZ_OK); return len; }; | ||
1213 | |||
1214 | } | ||
1215 | |||
1216 | return 0; /*not reached*/ | ||
1217 | } | ||
1218 | |||
1219 | |||
1220 | /*---------------------------------------------------*/ | ||
1221 | void BZ_API(BZ2_bzReadGetUnused) | ||
1222 | ( int* bzerror, | ||
1223 | BZFILE* b, | ||
1224 | void** unused, | ||
1225 | int* nUnused ) | ||
1226 | { | ||
1227 | bzFile* bzf = (bzFile*)b; | ||
1228 | if (bzf == NULL) | ||
1229 | { BZ_SETERR(BZ_PARAM_ERROR); return; }; | ||
1230 | if (bzf->lastErr != BZ_STREAM_END) | ||
1231 | { BZ_SETERR(BZ_SEQUENCE_ERROR); return; }; | ||
1232 | if (unused == NULL || nUnused == NULL) | ||
1233 | { BZ_SETERR(BZ_PARAM_ERROR); return; }; | ||
1234 | |||
1235 | BZ_SETERR(BZ_OK); | ||
1236 | *nUnused = bzf->strm.avail_in; | ||
1237 | *unused = bzf->strm.next_in; | ||
1238 | } | ||
1239 | #endif | ||
1240 | |||
1241 | |||
1242 | /*---------------------------------------------------*/ | ||
1243 | /*--- Misc convenience stuff ---*/ | ||
1244 | /*---------------------------------------------------*/ | ||
1245 | |||
1246 | /*---------------------------------------------------*/ | ||
1247 | int BZ_API(BZ2_bzBuffToBuffCompress) | ||
1248 | ( char* dest, | ||
1249 | unsigned int* destLen, | ||
1250 | char* source, | ||
1251 | unsigned int sourceLen, | ||
1252 | int blockSize100k, | ||
1253 | int verbosity, | ||
1254 | int workFactor ) | ||
1255 | { | ||
1256 | bz_stream strm; | ||
1257 | int ret; | ||
1258 | |||
1259 | if (dest == NULL || destLen == NULL || | ||
1260 | source == NULL || | ||
1261 | blockSize100k < 1 || blockSize100k > 9 || | ||
1262 | verbosity < 0 || verbosity > 4 || | ||
1263 | workFactor < 0 || workFactor > 250) | ||
1264 | return BZ_PARAM_ERROR; | ||
1265 | |||
1266 | if (workFactor == 0) workFactor = 30; | ||
1267 | strm.bzalloc = NULL; | ||
1268 | strm.bzfree = NULL; | ||
1269 | strm.opaque = NULL; | ||
1270 | ret = BZ2_bzCompressInit ( &strm, blockSize100k, | ||
1271 | verbosity, workFactor ); | ||
1272 | if (ret != BZ_OK) return ret; | ||
1273 | |||
1274 | strm.next_in = source; | ||
1275 | strm.next_out = dest; | ||
1276 | strm.avail_in = sourceLen; | ||
1277 | strm.avail_out = *destLen; | ||
1278 | |||
1279 | ret = BZ2_bzCompress ( &strm, BZ_FINISH ); | ||
1280 | if (ret == BZ_FINISH_OK) goto output_overflow; | ||
1281 | if (ret != BZ_STREAM_END) goto errhandler; | ||
1282 | |||
1283 | /* normal termination */ | ||
1284 | *destLen -= strm.avail_out; | ||
1285 | BZ2_bzCompressEnd ( &strm ); | ||
1286 | return BZ_OK; | ||
1287 | |||
1288 | output_overflow: | ||
1289 | BZ2_bzCompressEnd ( &strm ); | ||
1290 | return BZ_OUTBUFF_FULL; | ||
1291 | |||
1292 | errhandler: | ||
1293 | BZ2_bzCompressEnd ( &strm ); | ||
1294 | return ret; | ||
1295 | } | ||
1296 | |||
1297 | |||
1298 | /*---------------------------------------------------*/ | ||
1299 | int BZ_API(BZ2_bzBuffToBuffDecompress) | ||
1300 | ( char* dest, | ||
1301 | unsigned int* destLen, | ||
1302 | char* source, | ||
1303 | unsigned int sourceLen, | ||
1304 | int small, | ||
1305 | int verbosity ) | ||
1306 | { | ||
1307 | bz_stream strm; | ||
1308 | int ret; | ||
1309 | |||
1310 | if (dest == NULL || destLen == NULL || | ||
1311 | source == NULL || | ||
1312 | (small != 0 && small != 1) || | ||
1313 | verbosity < 0 || verbosity > 4) | ||
1314 | return BZ_PARAM_ERROR; | ||
1315 | |||
1316 | strm.bzalloc = NULL; | ||
1317 | strm.bzfree = NULL; | ||
1318 | strm.opaque = NULL; | ||
1319 | ret = BZ2_bzDecompressInit ( &strm, verbosity, small ); | ||
1320 | if (ret != BZ_OK) return ret; | ||
1321 | |||
1322 | strm.next_in = source; | ||
1323 | strm.next_out = dest; | ||
1324 | strm.avail_in = sourceLen; | ||
1325 | strm.avail_out = *destLen; | ||
1326 | |||
1327 | ret = BZ2_bzDecompress ( &strm ); | ||
1328 | if (ret == BZ_OK) goto output_overflow_or_eof; | ||
1329 | if (ret != BZ_STREAM_END) goto errhandler; | ||
1330 | |||
1331 | /* normal termination */ | ||
1332 | *destLen -= strm.avail_out; | ||
1333 | BZ2_bzDecompressEnd ( &strm ); | ||
1334 | return BZ_OK; | ||
1335 | |||
1336 | output_overflow_or_eof: | ||
1337 | if (strm.avail_out > 0) { | ||
1338 | BZ2_bzDecompressEnd ( &strm ); | ||
1339 | return BZ_UNEXPECTED_EOF; | ||
1340 | } else { | ||
1341 | BZ2_bzDecompressEnd ( &strm ); | ||
1342 | return BZ_OUTBUFF_FULL; | ||
1343 | }; | ||
1344 | |||
1345 | errhandler: | ||
1346 | BZ2_bzDecompressEnd ( &strm ); | ||
1347 | return ret; | ||
1348 | } | ||
1349 | |||
1350 | |||
1351 | /*---------------------------------------------------*/ | ||
1352 | /*-- | ||
1353 | Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp) | ||
1354 | to support better zlib compatibility. | ||
1355 | This code is not _officially_ part of libbzip2 (yet); | ||
1356 | I haven't tested it, documented it, or considered the | ||
1357 | threading-safeness of it. | ||
1358 | If this code breaks, please contact both Yoshioka and me. | ||
1359 | --*/ | ||
1360 | /*---------------------------------------------------*/ | ||
1361 | |||
1362 | /*---------------------------------------------------*/ | ||
1363 | /*-- | ||
1364 | return version like "0.9.5d, 4-Sept-1999". | ||
1365 | --*/ | ||
1366 | const char * BZ_API(BZ2_bzlibVersion)(void) | ||
1367 | { | ||
1368 | return BZ_VERSION; | ||
1369 | } | ||
1370 | |||
1371 | |||
1372 | #ifndef BZ_NO_STDIO | ||
1373 | /*---------------------------------------------------*/ | ||
1374 | |||
1375 | #if defined(_WIN32) || defined(OS2) || defined(MSDOS) | ||
1376 | # include <fcntl.h> | ||
1377 | # include <io.h> | ||
1378 | #if _MSC_VER > 1410 | ||
1379 | # define SET_BINARY_MODE(file) _setmode(_fileno(file),O_BINARY) | ||
1380 | #else | ||
1381 | # define SET_BINARY_MODE(file) setmode(fileno(file),O_BINARY) | ||
1382 | #endif | ||
1383 | #else | ||
1384 | # define SET_BINARY_MODE(file) | ||
1385 | #endif | ||
1386 | static | ||
1387 | BZFILE * bzopen_or_bzdopen | ||
1388 | ( const char *path, /* no use when bzdopen */ | ||
1389 | int fd, /* no use when bzdopen */ | ||
1390 | const char *mode, | ||
1391 | int open_mode) /* bzopen: 0, bzdopen:1 */ | ||
1392 | { | ||
1393 | int bzerr; | ||
1394 | char unused[BZ_MAX_UNUSED]; | ||
1395 | int blockSize100k = 9; | ||
1396 | int writing = 0; | ||
1397 | char mode2[10] = ""; | ||
1398 | FILE *fp = NULL; | ||
1399 | BZFILE *bzfp = NULL; | ||
1400 | int verbosity = 0; | ||
1401 | int workFactor = 30; | ||
1402 | int smallMode = 0; | ||
1403 | int nUnused = 0; | ||
1404 | |||
1405 | if (mode == NULL) return NULL; | ||
1406 | while (*mode) { | ||
1407 | switch (*mode) { | ||
1408 | case 'r': | ||
1409 | writing = 0; break; | ||
1410 | case 'w': | ||
1411 | writing = 1; break; | ||
1412 | case 's': | ||
1413 | smallMode = 1; break; | ||
1414 | default: | ||
1415 | if (isdigit((int)(*mode))) { | ||
1416 | blockSize100k = *mode-BZ_HDR_0; | ||
1417 | } | ||
1418 | } | ||
1419 | mode++; | ||
1420 | } | ||
1421 | strcat(mode2, writing ? "w" : "r" ); | ||
1422 | strcat(mode2,"b"); /* binary mode */ | ||
1423 | |||
1424 | if (open_mode==0) { | ||
1425 | if (path==NULL || strcmp(path,"")==0) { | ||
1426 | fp = (writing ? stdout : stdin); | ||
1427 | SET_BINARY_MODE(fp); | ||
1428 | } else { | ||
1429 | fp = fopen(path,mode2); | ||
1430 | } | ||
1431 | } else { | ||
1432 | #ifdef BZ_STRICT_ANSI | ||
1433 | fp = NULL; | ||
1434 | #else | ||
1435 | #if _MSC_VER > 1410 | ||
1436 | fp = _fdopen(fd,mode2); | ||
1437 | #else | ||
1438 | fp = fdopen(fd,mode2); | ||
1439 | #endif | ||
1440 | #endif | ||
1441 | } | ||
1442 | if (fp == NULL) return NULL; | ||
1443 | |||
1444 | if (writing) { | ||
1445 | /* Guard against total chaos and anarchy -- JRS */ | ||
1446 | if (blockSize100k < 1) blockSize100k = 1; | ||
1447 | if (blockSize100k > 9) blockSize100k = 9; | ||
1448 | bzfp = BZ2_bzWriteOpen(&bzerr,fp,blockSize100k, | ||
1449 | verbosity,workFactor); | ||
1450 | } else { | ||
1451 | bzfp = BZ2_bzReadOpen(&bzerr,fp,verbosity,smallMode, | ||
1452 | unused,nUnused); | ||
1453 | } | ||
1454 | if (bzfp == NULL) { | ||
1455 | if (fp != stdin && fp != stdout) fclose(fp); | ||
1456 | return NULL; | ||
1457 | } | ||
1458 | return bzfp; | ||
1459 | } | ||
1460 | |||
1461 | |||
1462 | /*---------------------------------------------------*/ | ||
1463 | /*-- | ||
1464 | open file for read or write. | ||
1465 | ex) bzopen("file","w9") | ||
1466 | case path="" or NULL => use stdin or stdout. | ||
1467 | --*/ | ||
1468 | BZFILE * BZ_API(BZ2_bzopen) | ||
1469 | ( const char *path, | ||
1470 | const char *mode ) | ||
1471 | { | ||
1472 | return bzopen_or_bzdopen(path,-1,mode,/*bzopen*/0); | ||
1473 | } | ||
1474 | |||
1475 | |||
1476 | /*---------------------------------------------------*/ | ||
1477 | BZFILE * BZ_API(BZ2_bzdopen) | ||
1478 | ( int fd, | ||
1479 | const char *mode ) | ||
1480 | { | ||
1481 | return bzopen_or_bzdopen(NULL,fd,mode,/*bzdopen*/1); | ||
1482 | } | ||
1483 | |||
1484 | |||
1485 | /*---------------------------------------------------*/ | ||
1486 | int BZ_API(BZ2_bzread) (BZFILE* b, void* buf, int len ) | ||
1487 | { | ||
1488 | int bzerr, nread; | ||
1489 | if (((bzFile*)b)->lastErr == BZ_STREAM_END) return 0; | ||
1490 | nread = BZ2_bzRead(&bzerr,b,buf,len); | ||
1491 | if (bzerr == BZ_OK || bzerr == BZ_STREAM_END) { | ||
1492 | return nread; | ||
1493 | } else { | ||
1494 | return -1; | ||
1495 | } | ||
1496 | } | ||
1497 | |||
1498 | |||
1499 | /*---------------------------------------------------*/ | ||
1500 | int BZ_API(BZ2_bzwrite) (BZFILE* b, void* buf, int len ) | ||
1501 | { | ||
1502 | int bzerr; | ||
1503 | |||
1504 | BZ2_bzWrite(&bzerr,b,buf,len); | ||
1505 | if(bzerr == BZ_OK){ | ||
1506 | return len; | ||
1507 | }else{ | ||
1508 | return -1; | ||
1509 | } | ||
1510 | } | ||
1511 | |||
1512 | |||
1513 | /*---------------------------------------------------*/ | ||
1514 | int BZ_API(BZ2_bzflush) (BZFILE *b) | ||
1515 | { | ||
1516 | /* do nothing now... */ | ||
1517 | return 0; | ||
1518 | } | ||
1519 | |||
1520 | |||
1521 | /*---------------------------------------------------*/ | ||
1522 | void BZ_API(BZ2_bzclose) (BZFILE* b) | ||
1523 | { | ||
1524 | int bzerr; | ||
1525 | FILE *fp; | ||
1526 | |||
1527 | if (b==NULL) {return;} | ||
1528 | fp = ((bzFile *)b)->handle; | ||
1529 | if(((bzFile*)b)->writing){ | ||
1530 | BZ2_bzWriteClose(&bzerr,b,0,NULL,NULL); | ||
1531 | if(bzerr != BZ_OK){ | ||
1532 | BZ2_bzWriteClose(NULL,b,1,NULL,NULL); | ||
1533 | } | ||
1534 | }else{ | ||
1535 | BZ2_bzReadClose(&bzerr,b); | ||
1536 | } | ||
1537 | if(fp!=stdin && fp!=stdout){ | ||
1538 | fclose(fp); | ||
1539 | } | ||
1540 | } | ||
1541 | |||
1542 | |||
1543 | /*---------------------------------------------------*/ | ||
1544 | /*-- | ||
1545 | return last error code | ||
1546 | --*/ | ||
1547 | static const char *bzerrorstrings[] = { | ||
1548 | "OK" | ||
1549 | ,"SEQUENCE_ERROR" | ||
1550 | ,"PARAM_ERROR" | ||
1551 | ,"MEM_ERROR" | ||
1552 | ,"DATA_ERROR" | ||
1553 | ,"DATA_ERROR_MAGIC" | ||
1554 | ,"IO_ERROR" | ||
1555 | ,"UNEXPECTED_EOF" | ||
1556 | ,"OUTBUFF_FULL" | ||
1557 | ,"CONFIG_ERROR" | ||
1558 | ,"???" /* for future */ | ||
1559 | ,"???" /* for future */ | ||
1560 | ,"???" /* for future */ | ||
1561 | ,"???" /* for future */ | ||
1562 | ,"???" /* for future */ | ||
1563 | ,"???" /* for future */ | ||
1564 | }; | ||
1565 | |||
1566 | |||
1567 | const char * BZ_API(BZ2_bzerror) (BZFILE *b, int *errnum) | ||
1568 | { | ||
1569 | int err = ((bzFile *)b)->lastErr; | ||
1570 | |||
1571 | if(err>0) err = 0; | ||
1572 | *errnum = err; | ||
1573 | return bzerrorstrings[err*-1]; | ||
1574 | } | ||
1575 | #endif | ||
1576 | |||
1577 | |||
1578 | /*-------------------------------------------------------------*/ | ||
1579 | /*--- end bzlib.c ---*/ | ||
1580 | /*-------------------------------------------------------------*/ | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzlib.h b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzlib.h new file mode 100644 index 0000000..acb1935 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzlib.h | |||
@@ -0,0 +1,285 @@ | |||
1 | |||
2 | /*-------------------------------------------------------------*/ | ||
3 | /*--- Public header file for the library. ---*/ | ||
4 | /*--- bzlib.h ---*/ | ||
5 | /*-------------------------------------------------------------*/ | ||
6 | |||
7 | /* ------------------------------------------------------------------ | ||
8 | This file is part of bzip2/libbzip2, a program and library for | ||
9 | lossless, block-sorting data compression. | ||
10 | |||
11 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | ||
12 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | ||
13 | |||
14 | Please read the WARNING, DISCLAIMER and PATENTS sections in the | ||
15 | README file. | ||
16 | |||
17 | This program is released under the terms of the license contained | ||
18 | in the file LICENSE. | ||
19 | ------------------------------------------------------------------ */ | ||
20 | |||
21 | |||
22 | #ifndef _BZLIB_H | ||
23 | #define _BZLIB_H | ||
24 | |||
25 | #ifdef __cplusplus | ||
26 | extern "C" { | ||
27 | #endif | ||
28 | |||
29 | // we don't need the FILE* interface | ||
30 | #define BZ_NO_STDIO | ||
31 | |||
32 | #define BZ_RUN 0 | ||
33 | #define BZ_FLUSH 1 | ||
34 | #define BZ_FINISH 2 | ||
35 | |||
36 | #define BZ_OK 0 | ||
37 | #define BZ_RUN_OK 1 | ||
38 | #define BZ_FLUSH_OK 2 | ||
39 | #define BZ_FINISH_OK 3 | ||
40 | #define BZ_STREAM_END 4 | ||
41 | #define BZ_SEQUENCE_ERROR (-1) | ||
42 | #define BZ_PARAM_ERROR (-2) | ||
43 | #define BZ_MEM_ERROR (-3) | ||
44 | #define BZ_DATA_ERROR (-4) | ||
45 | #define BZ_DATA_ERROR_MAGIC (-5) | ||
46 | #define BZ_IO_ERROR (-6) | ||
47 | #define BZ_UNEXPECTED_EOF (-7) | ||
48 | #define BZ_OUTBUFF_FULL (-8) | ||
49 | #define BZ_CONFIG_ERROR (-9) | ||
50 | |||
51 | typedef | ||
52 | struct { | ||
53 | char *next_in; | ||
54 | unsigned int avail_in; | ||
55 | unsigned int total_in_lo32; | ||
56 | unsigned int total_in_hi32; | ||
57 | |||
58 | char *next_out; | ||
59 | unsigned int avail_out; | ||
60 | unsigned int total_out_lo32; | ||
61 | unsigned int total_out_hi32; | ||
62 | |||
63 | void *state; | ||
64 | |||
65 | void *(*bzalloc)(void *,int,int); | ||
66 | void (*bzfree)(void *,void *); | ||
67 | void *opaque; | ||
68 | } | ||
69 | bz_stream; | ||
70 | |||
71 | |||
72 | #ifndef BZ_IMPORT | ||
73 | #define BZ_EXPORT | ||
74 | #endif | ||
75 | |||
76 | #ifndef BZ_NO_STDIO | ||
77 | /* Need a definitition for FILE */ | ||
78 | #include <stdio.h> | ||
79 | #endif | ||
80 | |||
81 | #ifdef _WIN32 | ||
82 | # include <windows.h> | ||
83 | # ifdef small | ||
84 | /* windows.h define small to char */ | ||
85 | # undef small | ||
86 | # endif | ||
87 | # ifdef BZ_EXPORT | ||
88 | # define BZ_API(func) WINAPI func | ||
89 | # define BZ_EXTERN extern | ||
90 | # else | ||
91 | /* import windows dll dynamically */ | ||
92 | # define BZ_API(func) (WINAPI * func) | ||
93 | # define BZ_EXTERN | ||
94 | # endif | ||
95 | #else | ||
96 | # define BZ_API(func) func | ||
97 | # define BZ_EXTERN extern | ||
98 | #endif | ||
99 | |||
100 | |||
101 | /*-- Core (low-level) library functions --*/ | ||
102 | |||
103 | BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( | ||
104 | bz_stream* strm, | ||
105 | int blockSize100k, | ||
106 | int verbosity, | ||
107 | int workFactor | ||
108 | ); | ||
109 | |||
110 | BZ_EXTERN int BZ_API(BZ2_bzCompress) ( | ||
111 | bz_stream* strm, | ||
112 | int action | ||
113 | ); | ||
114 | |||
115 | BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( | ||
116 | bz_stream* strm | ||
117 | ); | ||
118 | |||
119 | BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( | ||
120 | bz_stream *strm, | ||
121 | int verbosity, | ||
122 | int small | ||
123 | ); | ||
124 | |||
125 | BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( | ||
126 | bz_stream* strm | ||
127 | ); | ||
128 | |||
129 | BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( | ||
130 | bz_stream *strm | ||
131 | ); | ||
132 | |||
133 | |||
134 | |||
135 | /*-- High(er) level library functions --*/ | ||
136 | |||
137 | #ifndef BZ_NO_STDIO | ||
138 | #define BZ_MAX_UNUSED 5000 | ||
139 | |||
140 | typedef void BZFILE; | ||
141 | |||
142 | BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( | ||
143 | int* bzerror, | ||
144 | FILE* f, | ||
145 | int verbosity, | ||
146 | int small, | ||
147 | void* unused, | ||
148 | int nUnused | ||
149 | ); | ||
150 | |||
151 | BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( | ||
152 | int* bzerror, | ||
153 | BZFILE* b | ||
154 | ); | ||
155 | |||
156 | BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( | ||
157 | int* bzerror, | ||
158 | BZFILE* b, | ||
159 | void** unused, | ||
160 | int* nUnused | ||
161 | ); | ||
162 | |||
163 | BZ_EXTERN int BZ_API(BZ2_bzRead) ( | ||
164 | int* bzerror, | ||
165 | BZFILE* b, | ||
166 | void* buf, | ||
167 | int len | ||
168 | ); | ||
169 | |||
170 | BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( | ||
171 | int* bzerror, | ||
172 | FILE* f, | ||
173 | int blockSize100k, | ||
174 | int verbosity, | ||
175 | int workFactor | ||
176 | ); | ||
177 | |||
178 | BZ_EXTERN void BZ_API(BZ2_bzWrite) ( | ||
179 | int* bzerror, | ||
180 | BZFILE* b, | ||
181 | void* buf, | ||
182 | int len | ||
183 | ); | ||
184 | |||
185 | BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( | ||
186 | int* bzerror, | ||
187 | BZFILE* b, | ||
188 | int abandon, | ||
189 | unsigned int* nbytes_in, | ||
190 | unsigned int* nbytes_out | ||
191 | ); | ||
192 | |||
193 | BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( | ||
194 | int* bzerror, | ||
195 | BZFILE* b, | ||
196 | int abandon, | ||
197 | unsigned int* nbytes_in_lo32, | ||
198 | unsigned int* nbytes_in_hi32, | ||
199 | unsigned int* nbytes_out_lo32, | ||
200 | unsigned int* nbytes_out_hi32 | ||
201 | ); | ||
202 | #endif | ||
203 | |||
204 | |||
205 | /*-- Utility functions --*/ | ||
206 | |||
207 | BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( | ||
208 | char* dest, | ||
209 | unsigned int* destLen, | ||
210 | char* source, | ||
211 | unsigned int sourceLen, | ||
212 | int blockSize100k, | ||
213 | int verbosity, | ||
214 | int workFactor | ||
215 | ); | ||
216 | |||
217 | BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( | ||
218 | char* dest, | ||
219 | unsigned int* destLen, | ||
220 | char* source, | ||
221 | unsigned int sourceLen, | ||
222 | int small, | ||
223 | int verbosity | ||
224 | ); | ||
225 | |||
226 | |||
227 | /*-- | ||
228 | Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp) | ||
229 | to support better zlib compatibility. | ||
230 | This code is not _officially_ part of libbzip2 (yet); | ||
231 | I haven't tested it, documented it, or considered the | ||
232 | threading-safeness of it. | ||
233 | If this code breaks, please contact both Yoshioka and me. | ||
234 | --*/ | ||
235 | |||
236 | BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) ( | ||
237 | void | ||
238 | ); | ||
239 | |||
240 | #ifndef BZ_NO_STDIO | ||
241 | BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) ( | ||
242 | const char *path, | ||
243 | const char *mode | ||
244 | ); | ||
245 | |||
246 | BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) ( | ||
247 | int fd, | ||
248 | const char *mode | ||
249 | ); | ||
250 | |||
251 | BZ_EXTERN int BZ_API(BZ2_bzread) ( | ||
252 | BZFILE* b, | ||
253 | void* buf, | ||
254 | int len | ||
255 | ); | ||
256 | |||
257 | BZ_EXTERN int BZ_API(BZ2_bzwrite) ( | ||
258 | BZFILE* b, | ||
259 | void* buf, | ||
260 | int len | ||
261 | ); | ||
262 | |||
263 | BZ_EXTERN int BZ_API(BZ2_bzflush) ( | ||
264 | BZFILE* b | ||
265 | ); | ||
266 | |||
267 | BZ_EXTERN void BZ_API(BZ2_bzclose) ( | ||
268 | BZFILE* b | ||
269 | ); | ||
270 | |||
271 | BZ_EXTERN const char * BZ_API(BZ2_bzerror) ( | ||
272 | BZFILE *b, | ||
273 | int *errnum | ||
274 | ); | ||
275 | #endif | ||
276 | |||
277 | #ifdef __cplusplus | ||
278 | } | ||
279 | #endif | ||
280 | |||
281 | #endif | ||
282 | |||
283 | /*-------------------------------------------------------------*/ | ||
284 | /*--- end bzlib.h ---*/ | ||
285 | /*-------------------------------------------------------------*/ | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzlib_private.h b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzlib_private.h new file mode 100644 index 0000000..5d0217f --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzlib_private.h | |||
@@ -0,0 +1,509 @@ | |||
1 | |||
2 | /*-------------------------------------------------------------*/ | ||
3 | /*--- Private header file for the library. ---*/ | ||
4 | /*--- bzlib_private.h ---*/ | ||
5 | /*-------------------------------------------------------------*/ | ||
6 | |||
7 | /* ------------------------------------------------------------------ | ||
8 | This file is part of bzip2/libbzip2, a program and library for | ||
9 | lossless, block-sorting data compression. | ||
10 | |||
11 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | ||
12 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | ||
13 | |||
14 | Please read the WARNING, DISCLAIMER and PATENTS sections in the | ||
15 | README file. | ||
16 | |||
17 | This program is released under the terms of the license contained | ||
18 | in the file LICENSE. | ||
19 | ------------------------------------------------------------------ */ | ||
20 | |||
21 | |||
22 | #ifndef _BZLIB_PRIVATE_H | ||
23 | #define _BZLIB_PRIVATE_H | ||
24 | |||
25 | #include <stdlib.h> | ||
26 | |||
27 | #ifndef BZ_NO_STDIO | ||
28 | #include <stdio.h> | ||
29 | #include <ctype.h> | ||
30 | #include <string.h> | ||
31 | #endif | ||
32 | |||
33 | #include "bzlib.h" | ||
34 | |||
35 | |||
36 | |||
37 | /*-- General stuff. --*/ | ||
38 | |||
39 | #define BZ_VERSION "1.0.6, 6-Sept-2010" | ||
40 | |||
41 | typedef char Char; | ||
42 | typedef unsigned char Bool; | ||
43 | typedef unsigned char UChar; | ||
44 | typedef int Int32; | ||
45 | typedef unsigned int UInt32; | ||
46 | typedef short Int16; | ||
47 | typedef unsigned short UInt16; | ||
48 | |||
49 | #define True ((Bool)1) | ||
50 | #define False ((Bool)0) | ||
51 | |||
52 | #ifndef __GNUC__ | ||
53 | #define __inline__ /* */ | ||
54 | #endif | ||
55 | |||
56 | #ifndef BZ_NO_STDIO | ||
57 | |||
58 | extern void BZ2_bz__AssertH__fail ( int errcode ); | ||
59 | #define AssertH(cond,errcode) \ | ||
60 | { if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); } | ||
61 | |||
62 | #if BZ_DEBUG | ||
63 | #define AssertD(cond,msg) \ | ||
64 | { if (!(cond)) { \ | ||
65 | fprintf ( stderr, \ | ||
66 | "\n\nlibbzip2(debug build): internal error\n\t%s\n", msg );\ | ||
67 | exit(1); \ | ||
68 | }} | ||
69 | #else | ||
70 | #define AssertD(cond,msg) /* */ | ||
71 | #endif | ||
72 | |||
73 | #define VPrintf0(zf) \ | ||
74 | fprintf(stderr,zf) | ||
75 | #define VPrintf1(zf,za1) \ | ||
76 | fprintf(stderr,zf,za1) | ||
77 | #define VPrintf2(zf,za1,za2) \ | ||
78 | fprintf(stderr,zf,za1,za2) | ||
79 | #define VPrintf3(zf,za1,za2,za3) \ | ||
80 | fprintf(stderr,zf,za1,za2,za3) | ||
81 | #define VPrintf4(zf,za1,za2,za3,za4) \ | ||
82 | fprintf(stderr,zf,za1,za2,za3,za4) | ||
83 | #define VPrintf5(zf,za1,za2,za3,za4,za5) \ | ||
84 | fprintf(stderr,zf,za1,za2,za3,za4,za5) | ||
85 | |||
86 | #else | ||
87 | |||
88 | extern void bz_internal_error ( int errcode ); | ||
89 | #define AssertH(cond,errcode) \ | ||
90 | { if (!(cond)) bz_internal_error ( errcode ); } | ||
91 | #define AssertD(cond,msg) do { } while (0) | ||
92 | #define VPrintf0(zf) do { } while (0) | ||
93 | #define VPrintf1(zf,za1) do { } while (0) | ||
94 | #define VPrintf2(zf,za1,za2) do { } while (0) | ||
95 | #define VPrintf3(zf,za1,za2,za3) do { } while (0) | ||
96 | #define VPrintf4(zf,za1,za2,za3,za4) do { } while (0) | ||
97 | #define VPrintf5(zf,za1,za2,za3,za4,za5) do { } while (0) | ||
98 | |||
99 | #endif | ||
100 | |||
101 | |||
102 | #define BZALLOC(nnn) (strm->bzalloc)(strm->opaque,(nnn),1) | ||
103 | #define BZFREE(ppp) (strm->bzfree)(strm->opaque,(ppp)) | ||
104 | |||
105 | |||
106 | /*-- Header bytes. --*/ | ||
107 | |||
108 | #define BZ_HDR_B 0x42 /* 'B' */ | ||
109 | #define BZ_HDR_Z 0x5a /* 'Z' */ | ||
110 | #define BZ_HDR_h 0x68 /* 'h' */ | ||
111 | #define BZ_HDR_0 0x30 /* '0' */ | ||
112 | |||
113 | /*-- Constants for the back end. --*/ | ||
114 | |||
115 | #define BZ_MAX_ALPHA_SIZE 258 | ||
116 | #define BZ_MAX_CODE_LEN 23 | ||
117 | |||
118 | #define BZ_RUNA 0 | ||
119 | #define BZ_RUNB 1 | ||
120 | |||
121 | #define BZ_N_GROUPS 6 | ||
122 | #define BZ_G_SIZE 50 | ||
123 | #define BZ_N_ITERS 4 | ||
124 | |||
125 | #define BZ_MAX_SELECTORS (2 + (900000 / BZ_G_SIZE)) | ||
126 | |||
127 | |||
128 | |||
129 | /*-- Stuff for randomising repetitive blocks. --*/ | ||
130 | |||
131 | extern Int32 BZ2_rNums[512]; | ||
132 | |||
133 | #define BZ_RAND_DECLS \ | ||
134 | Int32 rNToGo; \ | ||
135 | Int32 rTPos \ | ||
136 | |||
137 | #define BZ_RAND_INIT_MASK \ | ||
138 | s->rNToGo = 0; \ | ||
139 | s->rTPos = 0 \ | ||
140 | |||
141 | #define BZ_RAND_MASK ((s->rNToGo == 1) ? 1 : 0) | ||
142 | |||
143 | #define BZ_RAND_UPD_MASK \ | ||
144 | if (s->rNToGo == 0) { \ | ||
145 | s->rNToGo = BZ2_rNums[s->rTPos]; \ | ||
146 | s->rTPos++; \ | ||
147 | if (s->rTPos == 512) s->rTPos = 0; \ | ||
148 | } \ | ||
149 | s->rNToGo--; | ||
150 | |||
151 | |||
152 | |||
153 | /*-- Stuff for doing CRCs. --*/ | ||
154 | |||
155 | extern UInt32 BZ2_crc32Table[256]; | ||
156 | |||
157 | #define BZ_INITIALISE_CRC(crcVar) \ | ||
158 | { \ | ||
159 | crcVar = 0xffffffffL; \ | ||
160 | } | ||
161 | |||
162 | #define BZ_FINALISE_CRC(crcVar) \ | ||
163 | { \ | ||
164 | crcVar = ~(crcVar); \ | ||
165 | } | ||
166 | |||
167 | #define BZ_UPDATE_CRC(crcVar,cha) \ | ||
168 | { \ | ||
169 | crcVar = (crcVar << 8) ^ \ | ||
170 | BZ2_crc32Table[(crcVar >> 24) ^ \ | ||
171 | ((UChar)cha)]; \ | ||
172 | } | ||
173 | |||
174 | |||
175 | |||
176 | /*-- States and modes for compression. --*/ | ||
177 | |||
178 | #define BZ_M_IDLE 1 | ||
179 | #define BZ_M_RUNNING 2 | ||
180 | #define BZ_M_FLUSHING 3 | ||
181 | #define BZ_M_FINISHING 4 | ||
182 | |||
183 | #define BZ_S_OUTPUT 1 | ||
184 | #define BZ_S_INPUT 2 | ||
185 | |||
186 | #define BZ_N_RADIX 2 | ||
187 | #define BZ_N_QSORT 12 | ||
188 | #define BZ_N_SHELL 18 | ||
189 | #define BZ_N_OVERSHOOT (BZ_N_RADIX + BZ_N_QSORT + BZ_N_SHELL + 2) | ||
190 | |||
191 | |||
192 | |||
193 | |||
194 | /*-- Structure holding all the compression-side stuff. --*/ | ||
195 | |||
196 | typedef | ||
197 | struct { | ||
198 | /* pointer back to the struct bz_stream */ | ||
199 | bz_stream* strm; | ||
200 | |||
201 | /* mode this stream is in, and whether inputting */ | ||
202 | /* or outputting data */ | ||
203 | Int32 mode; | ||
204 | Int32 state; | ||
205 | |||
206 | /* remembers avail_in when flush/finish requested */ | ||
207 | UInt32 avail_in_expect; | ||
208 | |||
209 | /* for doing the block sorting */ | ||
210 | UInt32* arr1; | ||
211 | UInt32* arr2; | ||
212 | UInt32* ftab; | ||
213 | Int32 origPtr; | ||
214 | |||
215 | /* aliases for arr1 and arr2 */ | ||
216 | UInt32* ptr; | ||
217 | UChar* block; | ||
218 | UInt16* mtfv; | ||
219 | UChar* zbits; | ||
220 | |||
221 | /* for deciding when to use the fallback sorting algorithm */ | ||
222 | Int32 workFactor; | ||
223 | |||
224 | /* run-length-encoding of the input */ | ||
225 | UInt32 state_in_ch; | ||
226 | Int32 state_in_len; | ||
227 | BZ_RAND_DECLS; | ||
228 | |||
229 | /* input and output limits and current posns */ | ||
230 | Int32 nblock; | ||
231 | Int32 nblockMAX; | ||
232 | Int32 numZ; | ||
233 | Int32 state_out_pos; | ||
234 | |||
235 | /* map of bytes used in block */ | ||
236 | Int32 nInUse; | ||
237 | Bool inUse[256]; | ||
238 | UChar unseqToSeq[256]; | ||
239 | |||
240 | /* the buffer for bit stream creation */ | ||
241 | UInt32 bsBuff; | ||
242 | Int32 bsLive; | ||
243 | |||
244 | /* block and combined CRCs */ | ||
245 | UInt32 blockCRC; | ||
246 | UInt32 combinedCRC; | ||
247 | |||
248 | /* misc administratium */ | ||
249 | Int32 verbosity; | ||
250 | Int32 blockNo; | ||
251 | Int32 blockSize100k; | ||
252 | |||
253 | /* stuff for coding the MTF values */ | ||
254 | Int32 nMTF; | ||
255 | Int32 mtfFreq [BZ_MAX_ALPHA_SIZE]; | ||
256 | UChar selector [BZ_MAX_SELECTORS]; | ||
257 | UChar selectorMtf[BZ_MAX_SELECTORS]; | ||
258 | |||
259 | UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; | ||
260 | Int32 code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; | ||
261 | Int32 rfreq [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; | ||
262 | /* second dimension: only 3 needed; 4 makes index calculations faster */ | ||
263 | UInt32 len_pack[BZ_MAX_ALPHA_SIZE][4]; | ||
264 | |||
265 | } | ||
266 | EState; | ||
267 | |||
268 | |||
269 | |||
270 | /*-- externs for compression. --*/ | ||
271 | |||
272 | extern void | ||
273 | BZ2_blockSort ( EState* ); | ||
274 | |||
275 | extern void | ||
276 | BZ2_compressBlock ( EState*, Bool ); | ||
277 | |||
278 | extern void | ||
279 | BZ2_bsInitWrite ( EState* ); | ||
280 | |||
281 | extern void | ||
282 | BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 ); | ||
283 | |||
284 | extern void | ||
285 | BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 ); | ||
286 | |||
287 | |||
288 | |||
289 | /*-- states for decompression. --*/ | ||
290 | |||
291 | #define BZ_X_IDLE 1 | ||
292 | #define BZ_X_OUTPUT 2 | ||
293 | |||
294 | #define BZ_X_MAGIC_1 10 | ||
295 | #define BZ_X_MAGIC_2 11 | ||
296 | #define BZ_X_MAGIC_3 12 | ||
297 | #define BZ_X_MAGIC_4 13 | ||
298 | #define BZ_X_BLKHDR_1 14 | ||
299 | #define BZ_X_BLKHDR_2 15 | ||
300 | #define BZ_X_BLKHDR_3 16 | ||
301 | #define BZ_X_BLKHDR_4 17 | ||
302 | #define BZ_X_BLKHDR_5 18 | ||
303 | #define BZ_X_BLKHDR_6 19 | ||
304 | #define BZ_X_BCRC_1 20 | ||
305 | #define BZ_X_BCRC_2 21 | ||
306 | #define BZ_X_BCRC_3 22 | ||
307 | #define BZ_X_BCRC_4 23 | ||
308 | #define BZ_X_RANDBIT 24 | ||
309 | #define BZ_X_ORIGPTR_1 25 | ||
310 | #define BZ_X_ORIGPTR_2 26 | ||
311 | #define BZ_X_ORIGPTR_3 27 | ||
312 | #define BZ_X_MAPPING_1 28 | ||
313 | #define BZ_X_MAPPING_2 29 | ||
314 | #define BZ_X_SELECTOR_1 30 | ||
315 | #define BZ_X_SELECTOR_2 31 | ||
316 | #define BZ_X_SELECTOR_3 32 | ||
317 | #define BZ_X_CODING_1 33 | ||
318 | #define BZ_X_CODING_2 34 | ||
319 | #define BZ_X_CODING_3 35 | ||
320 | #define BZ_X_MTF_1 36 | ||
321 | #define BZ_X_MTF_2 37 | ||
322 | #define BZ_X_MTF_3 38 | ||
323 | #define BZ_X_MTF_4 39 | ||
324 | #define BZ_X_MTF_5 40 | ||
325 | #define BZ_X_MTF_6 41 | ||
326 | #define BZ_X_ENDHDR_2 42 | ||
327 | #define BZ_X_ENDHDR_3 43 | ||
328 | #define BZ_X_ENDHDR_4 44 | ||
329 | #define BZ_X_ENDHDR_5 45 | ||
330 | #define BZ_X_ENDHDR_6 46 | ||
331 | #define BZ_X_CCRC_1 47 | ||
332 | #define BZ_X_CCRC_2 48 | ||
333 | #define BZ_X_CCRC_3 49 | ||
334 | #define BZ_X_CCRC_4 50 | ||
335 | |||
336 | |||
337 | |||
338 | /*-- Constants for the fast MTF decoder. --*/ | ||
339 | |||
340 | #define MTFA_SIZE 4096 | ||
341 | #define MTFL_SIZE 16 | ||
342 | |||
343 | |||
344 | |||
345 | /*-- Structure holding all the decompression-side stuff. --*/ | ||
346 | |||
347 | typedef | ||
348 | struct { | ||
349 | /* pointer back to the struct bz_stream */ | ||
350 | bz_stream* strm; | ||
351 | |||
352 | /* state indicator for this stream */ | ||
353 | Int32 state; | ||
354 | |||
355 | /* for doing the final run-length decoding */ | ||
356 | UChar state_out_ch; | ||
357 | Int32 state_out_len; | ||
358 | Bool blockRandomised; | ||
359 | BZ_RAND_DECLS; | ||
360 | |||
361 | /* the buffer for bit stream reading */ | ||
362 | UInt32 bsBuff; | ||
363 | Int32 bsLive; | ||
364 | |||
365 | /* misc administratium */ | ||
366 | Int32 blockSize100k; | ||
367 | Bool smallDecompress; | ||
368 | Int32 currBlockNo; | ||
369 | Int32 verbosity; | ||
370 | |||
371 | /* for undoing the Burrows-Wheeler transform */ | ||
372 | Int32 origPtr; | ||
373 | UInt32 tPos; | ||
374 | Int32 k0; | ||
375 | Int32 unzftab[256]; | ||
376 | Int32 nblock_used; | ||
377 | Int32 cftab[257]; | ||
378 | Int32 cftabCopy[257]; | ||
379 | |||
380 | /* for undoing the Burrows-Wheeler transform (FAST) */ | ||
381 | UInt32 *tt; | ||
382 | |||
383 | /* for undoing the Burrows-Wheeler transform (SMALL) */ | ||
384 | UInt16 *ll16; | ||
385 | UChar *ll4; | ||
386 | |||
387 | /* stored and calculated CRCs */ | ||
388 | UInt32 storedBlockCRC; | ||
389 | UInt32 storedCombinedCRC; | ||
390 | UInt32 calculatedBlockCRC; | ||
391 | UInt32 calculatedCombinedCRC; | ||
392 | |||
393 | /* map of bytes used in block */ | ||
394 | Int32 nInUse; | ||
395 | Bool inUse[256]; | ||
396 | Bool inUse16[16]; | ||
397 | UChar seqToUnseq[256]; | ||
398 | |||
399 | /* for decoding the MTF values */ | ||
400 | UChar mtfa [MTFA_SIZE]; | ||
401 | Int32 mtfbase[256 / MTFL_SIZE]; | ||
402 | UChar selector [BZ_MAX_SELECTORS]; | ||
403 | UChar selectorMtf[BZ_MAX_SELECTORS]; | ||
404 | UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; | ||
405 | |||
406 | Int32 limit [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; | ||
407 | Int32 base [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; | ||
408 | Int32 perm [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; | ||
409 | Int32 minLens[BZ_N_GROUPS]; | ||
410 | |||
411 | /* save area for scalars in the main decompress code */ | ||
412 | Int32 save_i; | ||
413 | Int32 save_j; | ||
414 | Int32 save_t; | ||
415 | Int32 save_alphaSize; | ||
416 | Int32 save_nGroups; | ||
417 | Int32 save_nSelectors; | ||
418 | Int32 save_EOB; | ||
419 | Int32 save_groupNo; | ||
420 | Int32 save_groupPos; | ||
421 | Int32 save_nextSym; | ||
422 | Int32 save_nblockMAX; | ||
423 | Int32 save_nblock; | ||
424 | Int32 save_es; | ||
425 | Int32 save_N; | ||
426 | Int32 save_curr; | ||
427 | Int32 save_zt; | ||
428 | Int32 save_zn; | ||
429 | Int32 save_zvec; | ||
430 | Int32 save_zj; | ||
431 | Int32 save_gSel; | ||
432 | Int32 save_gMinlen; | ||
433 | Int32* save_gLimit; | ||
434 | Int32* save_gBase; | ||
435 | Int32* save_gPerm; | ||
436 | |||
437 | } | ||
438 | DState; | ||
439 | |||
440 | |||
441 | |||
442 | /*-- Macros for decompression. --*/ | ||
443 | |||
444 | #define BZ_GET_FAST(cccc) \ | ||
445 | /* c_tPos is unsigned, hence test < 0 is pointless. */ \ | ||
446 | if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k) return True; \ | ||
447 | s->tPos = s->tt[s->tPos]; \ | ||
448 | cccc = (UChar)(s->tPos & 0xff); \ | ||
449 | s->tPos >>= 8; | ||
450 | |||
451 | #define BZ_GET_FAST_C(cccc) \ | ||
452 | /* c_tPos is unsigned, hence test < 0 is pointless. */ \ | ||
453 | if (c_tPos >= (UInt32)100000 * (UInt32)ro_blockSize100k) return True; \ | ||
454 | c_tPos = c_tt[c_tPos]; \ | ||
455 | cccc = (UChar)(c_tPos & 0xff); \ | ||
456 | c_tPos >>= 8; | ||
457 | |||
458 | #define SET_LL4(i,n) \ | ||
459 | { if (((i) & 0x1) == 0) \ | ||
460 | s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0xf0) | (n); else \ | ||
461 | s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0x0f) | ((n) << 4); \ | ||
462 | } | ||
463 | |||
464 | #define GET_LL4(i) \ | ||
465 | ((((UInt32)(s->ll4[(i) >> 1])) >> (((i) << 2) & 0x4)) & 0xF) | ||
466 | |||
467 | #define SET_LL(i,n) \ | ||
468 | { s->ll16[i] = (UInt16)(n & 0x0000ffff); \ | ||
469 | SET_LL4(i, n >> 16); \ | ||
470 | } | ||
471 | |||
472 | #define GET_LL(i) \ | ||
473 | (((UInt32)s->ll16[i]) | (GET_LL4(i) << 16)) | ||
474 | |||
475 | #define BZ_GET_SMALL(cccc) \ | ||
476 | /* c_tPos is unsigned, hence test < 0 is pointless. */ \ | ||
477 | if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k) return True; \ | ||
478 | cccc = BZ2_indexIntoF ( s->tPos, s->cftab ); \ | ||
479 | s->tPos = GET_LL(s->tPos); | ||
480 | |||
481 | |||
482 | /*-- externs for decompression. --*/ | ||
483 | |||
484 | extern Int32 | ||
485 | BZ2_indexIntoF ( Int32, Int32* ); | ||
486 | |||
487 | extern Int32 | ||
488 | BZ2_decompress ( DState* ); | ||
489 | |||
490 | extern void | ||
491 | BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*, | ||
492 | Int32, Int32, Int32 ); | ||
493 | |||
494 | |||
495 | #endif | ||
496 | |||
497 | |||
498 | /*-- BZ_NO_STDIO seems to make NULL disappear on some platforms. --*/ | ||
499 | |||
500 | #ifdef BZ_NO_STDIO | ||
501 | #ifndef NULL | ||
502 | #define NULL 0 | ||
503 | #endif | ||
504 | #endif | ||
505 | |||
506 | |||
507 | /*-------------------------------------------------------------*/ | ||
508 | /*--- end bzlib_private.h ---*/ | ||
509 | /*-------------------------------------------------------------*/ | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzmore b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzmore new file mode 100644 index 0000000..d314043 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzmore | |||
@@ -0,0 +1,61 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # Bzmore wrapped for bzip2, | ||
4 | # adapted from zmore by Philippe Troin <phil@fifi.org> for Debian GNU/Linux. | ||
5 | |||
6 | PATH="/usr/bin:$PATH"; export PATH | ||
7 | |||
8 | prog=`echo $0 | sed 's|.*/||'` | ||
9 | case "$prog" in | ||
10 | *less) more=less ;; | ||
11 | *) more=more ;; | ||
12 | esac | ||
13 | |||
14 | if test "`echo -n a`" = "-n a"; then | ||
15 | # looks like a SysV system: | ||
16 | n1=''; n2='\c' | ||
17 | else | ||
18 | n1='-n'; n2='' | ||
19 | fi | ||
20 | oldtty=`stty -g 2>/dev/null` | ||
21 | if stty -cbreak 2>/dev/null; then | ||
22 | cb='cbreak'; ncb='-cbreak' | ||
23 | else | ||
24 | # 'stty min 1' resets eof to ^a on both SunOS and SysV! | ||
25 | cb='min 1 -icanon'; ncb='icanon eof ^d' | ||
26 | fi | ||
27 | if test $? -eq 0 -a -n "$oldtty"; then | ||
28 | trap 'stty $oldtty 2>/dev/null; exit' 0 2 3 5 10 13 15 | ||
29 | else | ||
30 | trap 'stty $ncb echo 2>/dev/null; exit' 0 2 3 5 10 13 15 | ||
31 | fi | ||
32 | |||
33 | if test $# = 0; then | ||
34 | if test -t 0; then | ||
35 | echo usage: $prog files... | ||
36 | else | ||
37 | bzip2 -cdfq | eval $more | ||
38 | fi | ||
39 | else | ||
40 | FIRST=1 | ||
41 | for FILE | ||
42 | do | ||
43 | if test $FIRST -eq 0; then | ||
44 | echo $n1 "--More--(Next file: $FILE)$n2" | ||
45 | stty $cb -echo 2>/dev/null | ||
46 | ANS=`dd bs=1 count=1 2>/dev/null` | ||
47 | stty $ncb echo 2>/dev/null | ||
48 | echo " " | ||
49 | if test "$ANS" = 'e' -o "$ANS" = 'q'; then | ||
50 | exit | ||
51 | fi | ||
52 | fi | ||
53 | if test "$ANS" != 's'; then | ||
54 | echo "------> $FILE <------" | ||
55 | bzip2 -cdfq "$FILE" | eval $more | ||
56 | fi | ||
57 | if test -t; then | ||
58 | FIRST=0 | ||
59 | fi | ||
60 | done | ||
61 | fi | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzmore.1 b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzmore.1 new file mode 100644 index 0000000..b437d3b --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/bzmore.1 | |||
@@ -0,0 +1,152 @@ | |||
1 | .\"Shamelessly copied from zmore.1 by Philippe Troin <phil@fifi.org> | ||
2 | .\"for Debian GNU/Linux | ||
3 | .TH BZMORE 1 | ||
4 | .SH NAME | ||
5 | bzmore, bzless \- file perusal filter for crt viewing of bzip2 compressed text | ||
6 | .SH SYNOPSIS | ||
7 | .B bzmore | ||
8 | [ name ... ] | ||
9 | .br | ||
10 | .B bzless | ||
11 | [ name ... ] | ||
12 | .SH NOTE | ||
13 | In the following description, | ||
14 | .I bzless | ||
15 | and | ||
16 | .I less | ||
17 | can be used interchangeably with | ||
18 | .I bzmore | ||
19 | and | ||
20 | .I more. | ||
21 | .SH DESCRIPTION | ||
22 | .I Bzmore | ||
23 | is a filter which allows examination of compressed or plain text files | ||
24 | one screenful at a time on a soft-copy terminal. | ||
25 | .I bzmore | ||
26 | works on files compressed with | ||
27 | .I bzip2 | ||
28 | and also on uncompressed files. | ||
29 | If a file does not exist, | ||
30 | .I bzmore | ||
31 | looks for a file of the same name with the addition of a .bz2 suffix. | ||
32 | .PP | ||
33 | .I Bzmore | ||
34 | normally pauses after each screenful, printing --More-- | ||
35 | at the bottom of the screen. | ||
36 | If the user then types a carriage return, one more line is displayed. | ||
37 | If the user hits a space, | ||
38 | another screenful is displayed. Other possibilities are enumerated later. | ||
39 | .PP | ||
40 | .I Bzmore | ||
41 | looks in the file | ||
42 | .I /etc/termcap | ||
43 | to determine terminal characteristics, | ||
44 | and to determine the default window size. | ||
45 | On a terminal capable of displaying 24 lines, | ||
46 | the default window size is 22 lines. | ||
47 | Other sequences which may be typed when | ||
48 | .I bzmore | ||
49 | pauses, and their effects, are as follows (\fIi\fP is an optional integer | ||
50 | argument, defaulting to 1) : | ||
51 | .PP | ||
52 | .IP \fIi\|\fP<space> | ||
53 | display | ||
54 | .I i | ||
55 | more lines, (or another screenful if no argument is given) | ||
56 | .PP | ||
57 | .IP ^D | ||
58 | display 11 more lines (a ``scroll''). | ||
59 | If | ||
60 | .I i | ||
61 | is given, then the scroll size is set to \fIi\|\fP. | ||
62 | .PP | ||
63 | .IP d | ||
64 | same as ^D (control-D) | ||
65 | .PP | ||
66 | .IP \fIi\|\fPz | ||
67 | same as typing a space except that \fIi\|\fP, if present, becomes the new | ||
68 | window size. Note that the window size reverts back to the default at the | ||
69 | end of the current file. | ||
70 | .PP | ||
71 | .IP \fIi\|\fPs | ||
72 | skip \fIi\|\fP lines and print a screenful of lines | ||
73 | .PP | ||
74 | .IP \fIi\|\fPf | ||
75 | skip \fIi\fP screenfuls and print a screenful of lines | ||
76 | .PP | ||
77 | .IP "q or Q" | ||
78 | quit reading the current file; go on to the next (if any) | ||
79 | .PP | ||
80 | .IP "e or q" | ||
81 | When the prompt --More--(Next file: | ||
82 | .IR file ) | ||
83 | is printed, this command causes bzmore to exit. | ||
84 | .PP | ||
85 | .IP s | ||
86 | When the prompt --More--(Next file: | ||
87 | .IR file ) | ||
88 | is printed, this command causes bzmore to skip the next file and continue. | ||
89 | .PP | ||
90 | .IP = | ||
91 | Display the current line number. | ||
92 | .PP | ||
93 | .IP \fIi\|\fP/expr | ||
94 | search for the \fIi\|\fP-th occurrence of the regular expression \fIexpr.\fP | ||
95 | If the pattern is not found, | ||
96 | .I bzmore | ||
97 | goes on to the next file (if any). | ||
98 | Otherwise, a screenful is displayed, starting two lines before the place | ||
99 | where the expression was found. | ||
100 | The user's erase and kill characters may be used to edit the regular | ||
101 | expression. | ||
102 | Erasing back past the first column cancels the search command. | ||
103 | .PP | ||
104 | .IP \fIi\|\fPn | ||
105 | search for the \fIi\|\fP-th occurrence of the last regular expression entered. | ||
106 | .PP | ||
107 | .IP !command | ||
108 | invoke a shell with \fIcommand\|\fP. | ||
109 | The character `!' in "command" are replaced with the | ||
110 | previous shell command. The sequence "\\!" is replaced by "!". | ||
111 | .PP | ||
112 | .IP ":q or :Q" | ||
113 | quit reading the current file; go on to the next (if any) | ||
114 | (same as q or Q). | ||
115 | .PP | ||
116 | .IP . | ||
117 | (dot) repeat the previous command. | ||
118 | .PP | ||
119 | The commands take effect immediately, i.e., it is not necessary to | ||
120 | type a carriage return. | ||
121 | Up to the time when the command character itself is given, | ||
122 | the user may hit the line kill character to cancel the numerical | ||
123 | argument being formed. | ||
124 | In addition, the user may hit the erase character to redisplay the | ||
125 | --More-- message. | ||
126 | .PP | ||
127 | At any time when output is being sent to the terminal, the user can | ||
128 | hit the quit key (normally control\-\\). | ||
129 | .I Bzmore | ||
130 | will stop sending output, and will display the usual --More-- | ||
131 | prompt. | ||
132 | The user may then enter one of the above commands in the normal manner. | ||
133 | Unfortunately, some output is lost when this is done, due to the | ||
134 | fact that any characters waiting in the terminal's output queue | ||
135 | are flushed when the quit signal occurs. | ||
136 | .PP | ||
137 | The terminal is set to | ||
138 | .I noecho | ||
139 | mode by this program so that the output can be continuous. | ||
140 | What you type will thus not show on your terminal, except for the / and ! | ||
141 | commands. | ||
142 | .PP | ||
143 | If the standard output is not a teletype, then | ||
144 | .I bzmore | ||
145 | acts just like | ||
146 | .I bzcat, | ||
147 | except that a header is printed before each file. | ||
148 | .SH FILES | ||
149 | .DT | ||
150 | /etc/termcap Terminal data base | ||
151 | .SH "SEE ALSO" | ||
152 | more(1), less(1), bzip2(1), bzdiff(1), bzgrep(1) | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/crctable.c b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/crctable.c new file mode 100644 index 0000000..1fea7e9 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/crctable.c | |||
@@ -0,0 +1,104 @@ | |||
1 | |||
2 | /*-------------------------------------------------------------*/ | ||
3 | /*--- Table for doing CRCs ---*/ | ||
4 | /*--- crctable.c ---*/ | ||
5 | /*-------------------------------------------------------------*/ | ||
6 | |||
7 | /* ------------------------------------------------------------------ | ||
8 | This file is part of bzip2/libbzip2, a program and library for | ||
9 | lossless, block-sorting data compression. | ||
10 | |||
11 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | ||
12 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | ||
13 | |||
14 | Please read the WARNING, DISCLAIMER and PATENTS sections in the | ||
15 | README file. | ||
16 | |||
17 | This program is released under the terms of the license contained | ||
18 | in the file LICENSE. | ||
19 | ------------------------------------------------------------------ */ | ||
20 | |||
21 | |||
22 | #include "bzlib_private.h" | ||
23 | |||
24 | /*-- | ||
25 | I think this is an implementation of the AUTODIN-II, | ||
26 | Ethernet & FDDI 32-bit CRC standard. Vaguely derived | ||
27 | from code by Rob Warnock, in Section 51 of the | ||
28 | comp.compression FAQ. | ||
29 | --*/ | ||
30 | |||
31 | UInt32 BZ2_crc32Table[256] = { | ||
32 | |||
33 | /*-- Ugly, innit? --*/ | ||
34 | |||
35 | 0x00000000L, 0x04c11db7L, 0x09823b6eL, 0x0d4326d9L, | ||
36 | 0x130476dcL, 0x17c56b6bL, 0x1a864db2L, 0x1e475005L, | ||
37 | 0x2608edb8L, 0x22c9f00fL, 0x2f8ad6d6L, 0x2b4bcb61L, | ||
38 | 0x350c9b64L, 0x31cd86d3L, 0x3c8ea00aL, 0x384fbdbdL, | ||
39 | 0x4c11db70L, 0x48d0c6c7L, 0x4593e01eL, 0x4152fda9L, | ||
40 | 0x5f15adacL, 0x5bd4b01bL, 0x569796c2L, 0x52568b75L, | ||
41 | 0x6a1936c8L, 0x6ed82b7fL, 0x639b0da6L, 0x675a1011L, | ||
42 | 0x791d4014L, 0x7ddc5da3L, 0x709f7b7aL, 0x745e66cdL, | ||
43 | 0x9823b6e0L, 0x9ce2ab57L, 0x91a18d8eL, 0x95609039L, | ||
44 | 0x8b27c03cL, 0x8fe6dd8bL, 0x82a5fb52L, 0x8664e6e5L, | ||
45 | 0xbe2b5b58L, 0xbaea46efL, 0xb7a96036L, 0xb3687d81L, | ||
46 | 0xad2f2d84L, 0xa9ee3033L, 0xa4ad16eaL, 0xa06c0b5dL, | ||
47 | 0xd4326d90L, 0xd0f37027L, 0xddb056feL, 0xd9714b49L, | ||
48 | 0xc7361b4cL, 0xc3f706fbL, 0xceb42022L, 0xca753d95L, | ||
49 | 0xf23a8028L, 0xf6fb9d9fL, 0xfbb8bb46L, 0xff79a6f1L, | ||
50 | 0xe13ef6f4L, 0xe5ffeb43L, 0xe8bccd9aL, 0xec7dd02dL, | ||
51 | 0x34867077L, 0x30476dc0L, 0x3d044b19L, 0x39c556aeL, | ||
52 | 0x278206abL, 0x23431b1cL, 0x2e003dc5L, 0x2ac12072L, | ||
53 | 0x128e9dcfL, 0x164f8078L, 0x1b0ca6a1L, 0x1fcdbb16L, | ||
54 | 0x018aeb13L, 0x054bf6a4L, 0x0808d07dL, 0x0cc9cdcaL, | ||
55 | 0x7897ab07L, 0x7c56b6b0L, 0x71159069L, 0x75d48ddeL, | ||
56 | 0x6b93dddbL, 0x6f52c06cL, 0x6211e6b5L, 0x66d0fb02L, | ||
57 | 0x5e9f46bfL, 0x5a5e5b08L, 0x571d7dd1L, 0x53dc6066L, | ||
58 | 0x4d9b3063L, 0x495a2dd4L, 0x44190b0dL, 0x40d816baL, | ||
59 | 0xaca5c697L, 0xa864db20L, 0xa527fdf9L, 0xa1e6e04eL, | ||
60 | 0xbfa1b04bL, 0xbb60adfcL, 0xb6238b25L, 0xb2e29692L, | ||
61 | 0x8aad2b2fL, 0x8e6c3698L, 0x832f1041L, 0x87ee0df6L, | ||
62 | 0x99a95df3L, 0x9d684044L, 0x902b669dL, 0x94ea7b2aL, | ||
63 | 0xe0b41de7L, 0xe4750050L, 0xe9362689L, 0xedf73b3eL, | ||
64 | 0xf3b06b3bL, 0xf771768cL, 0xfa325055L, 0xfef34de2L, | ||
65 | 0xc6bcf05fL, 0xc27dede8L, 0xcf3ecb31L, 0xcbffd686L, | ||
66 | 0xd5b88683L, 0xd1799b34L, 0xdc3abdedL, 0xd8fba05aL, | ||
67 | 0x690ce0eeL, 0x6dcdfd59L, 0x608edb80L, 0x644fc637L, | ||
68 | 0x7a089632L, 0x7ec98b85L, 0x738aad5cL, 0x774bb0ebL, | ||
69 | 0x4f040d56L, 0x4bc510e1L, 0x46863638L, 0x42472b8fL, | ||
70 | 0x5c007b8aL, 0x58c1663dL, 0x558240e4L, 0x51435d53L, | ||
71 | 0x251d3b9eL, 0x21dc2629L, 0x2c9f00f0L, 0x285e1d47L, | ||
72 | 0x36194d42L, 0x32d850f5L, 0x3f9b762cL, 0x3b5a6b9bL, | ||
73 | 0x0315d626L, 0x07d4cb91L, 0x0a97ed48L, 0x0e56f0ffL, | ||
74 | 0x1011a0faL, 0x14d0bd4dL, 0x19939b94L, 0x1d528623L, | ||
75 | 0xf12f560eL, 0xf5ee4bb9L, 0xf8ad6d60L, 0xfc6c70d7L, | ||
76 | 0xe22b20d2L, 0xe6ea3d65L, 0xeba91bbcL, 0xef68060bL, | ||
77 | 0xd727bbb6L, 0xd3e6a601L, 0xdea580d8L, 0xda649d6fL, | ||
78 | 0xc423cd6aL, 0xc0e2d0ddL, 0xcda1f604L, 0xc960ebb3L, | ||
79 | 0xbd3e8d7eL, 0xb9ff90c9L, 0xb4bcb610L, 0xb07daba7L, | ||
80 | 0xae3afba2L, 0xaafbe615L, 0xa7b8c0ccL, 0xa379dd7bL, | ||
81 | 0x9b3660c6L, 0x9ff77d71L, 0x92b45ba8L, 0x9675461fL, | ||
82 | 0x8832161aL, 0x8cf30badL, 0x81b02d74L, 0x857130c3L, | ||
83 | 0x5d8a9099L, 0x594b8d2eL, 0x5408abf7L, 0x50c9b640L, | ||
84 | 0x4e8ee645L, 0x4a4ffbf2L, 0x470cdd2bL, 0x43cdc09cL, | ||
85 | 0x7b827d21L, 0x7f436096L, 0x7200464fL, 0x76c15bf8L, | ||
86 | 0x68860bfdL, 0x6c47164aL, 0x61043093L, 0x65c52d24L, | ||
87 | 0x119b4be9L, 0x155a565eL, 0x18197087L, 0x1cd86d30L, | ||
88 | 0x029f3d35L, 0x065e2082L, 0x0b1d065bL, 0x0fdc1becL, | ||
89 | 0x3793a651L, 0x3352bbe6L, 0x3e119d3fL, 0x3ad08088L, | ||
90 | 0x2497d08dL, 0x2056cd3aL, 0x2d15ebe3L, 0x29d4f654L, | ||
91 | 0xc5a92679L, 0xc1683bceL, 0xcc2b1d17L, 0xc8ea00a0L, | ||
92 | 0xd6ad50a5L, 0xd26c4d12L, 0xdf2f6bcbL, 0xdbee767cL, | ||
93 | 0xe3a1cbc1L, 0xe760d676L, 0xea23f0afL, 0xeee2ed18L, | ||
94 | 0xf0a5bd1dL, 0xf464a0aaL, 0xf9278673L, 0xfde69bc4L, | ||
95 | 0x89b8fd09L, 0x8d79e0beL, 0x803ac667L, 0x84fbdbd0L, | ||
96 | 0x9abc8bd5L, 0x9e7d9662L, 0x933eb0bbL, 0x97ffad0cL, | ||
97 | 0xafb010b1L, 0xab710d06L, 0xa6322bdfL, 0xa2f33668L, | ||
98 | 0xbcb4666dL, 0xb8757bdaL, 0xb5365d03L, 0xb1f740b4L | ||
99 | }; | ||
100 | |||
101 | |||
102 | /*-------------------------------------------------------------*/ | ||
103 | /*--- end crctable.c ---*/ | ||
104 | /*-------------------------------------------------------------*/ | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/decompress.c b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/decompress.c new file mode 100644 index 0000000..311f566 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/decompress.c | |||
@@ -0,0 +1,646 @@ | |||
1 | |||
2 | /*-------------------------------------------------------------*/ | ||
3 | /*--- Decompression machinery ---*/ | ||
4 | /*--- decompress.c ---*/ | ||
5 | /*-------------------------------------------------------------*/ | ||
6 | |||
7 | /* ------------------------------------------------------------------ | ||
8 | This file is part of bzip2/libbzip2, a program and library for | ||
9 | lossless, block-sorting data compression. | ||
10 | |||
11 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | ||
12 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | ||
13 | |||
14 | Please read the WARNING, DISCLAIMER and PATENTS sections in the | ||
15 | README file. | ||
16 | |||
17 | This program is released under the terms of the license contained | ||
18 | in the file LICENSE. | ||
19 | ------------------------------------------------------------------ */ | ||
20 | |||
21 | |||
22 | #include "bzlib_private.h" | ||
23 | |||
24 | |||
25 | /*---------------------------------------------------*/ | ||
26 | static | ||
27 | void makeMaps_d ( DState* s ) | ||
28 | { | ||
29 | Int32 i; | ||
30 | s->nInUse = 0; | ||
31 | for (i = 0; i < 256; i++) | ||
32 | if (s->inUse[i]) { | ||
33 | s->seqToUnseq[s->nInUse] = i; | ||
34 | s->nInUse++; | ||
35 | } | ||
36 | } | ||
37 | |||
38 | |||
39 | /*---------------------------------------------------*/ | ||
40 | #define RETURN(rrr) \ | ||
41 | { retVal = rrr; goto save_state_and_return; }; | ||
42 | |||
43 | #define GET_BITS(lll,vvv,nnn) \ | ||
44 | case lll: s->state = lll; \ | ||
45 | while (True) { \ | ||
46 | if (s->bsLive >= nnn) { \ | ||
47 | UInt32 v; \ | ||
48 | v = (s->bsBuff >> \ | ||
49 | (s->bsLive-nnn)) & ((1 << nnn)-1); \ | ||
50 | s->bsLive -= nnn; \ | ||
51 | vvv = v; \ | ||
52 | break; \ | ||
53 | } \ | ||
54 | if (s->strm->avail_in == 0) RETURN(BZ_OK); \ | ||
55 | s->bsBuff \ | ||
56 | = (s->bsBuff << 8) | \ | ||
57 | ((UInt32) \ | ||
58 | (*((UChar*)(s->strm->next_in)))); \ | ||
59 | s->bsLive += 8; \ | ||
60 | s->strm->next_in++; \ | ||
61 | s->strm->avail_in--; \ | ||
62 | s->strm->total_in_lo32++; \ | ||
63 | if (s->strm->total_in_lo32 == 0) \ | ||
64 | s->strm->total_in_hi32++; \ | ||
65 | } | ||
66 | |||
67 | #define GET_UCHAR(lll,uuu) \ | ||
68 | GET_BITS(lll,uuu,8) | ||
69 | |||
70 | #define GET_BIT(lll,uuu) \ | ||
71 | GET_BITS(lll,uuu,1) | ||
72 | |||
73 | /*---------------------------------------------------*/ | ||
74 | #define GET_MTF_VAL(label1,label2,lval) \ | ||
75 | { \ | ||
76 | if (groupPos == 0) { \ | ||
77 | groupNo++; \ | ||
78 | if (groupNo >= nSelectors) \ | ||
79 | RETURN(BZ_DATA_ERROR); \ | ||
80 | groupPos = BZ_G_SIZE; \ | ||
81 | gSel = s->selector[groupNo]; \ | ||
82 | gMinlen = s->minLens[gSel]; \ | ||
83 | gLimit = &(s->limit[gSel][0]); \ | ||
84 | gPerm = &(s->perm[gSel][0]); \ | ||
85 | gBase = &(s->base[gSel][0]); \ | ||
86 | } \ | ||
87 | groupPos--; \ | ||
88 | zn = gMinlen; \ | ||
89 | GET_BITS(label1, zvec, zn); \ | ||
90 | while (1) { \ | ||
91 | if (zn > 20 /* the longest code */) \ | ||
92 | RETURN(BZ_DATA_ERROR); \ | ||
93 | if (zvec <= gLimit[zn]) break; \ | ||
94 | zn++; \ | ||
95 | GET_BIT(label2, zj); \ | ||
96 | zvec = (zvec << 1) | zj; \ | ||
97 | }; \ | ||
98 | if (zvec - gBase[zn] < 0 \ | ||
99 | || zvec - gBase[zn] >= BZ_MAX_ALPHA_SIZE) \ | ||
100 | RETURN(BZ_DATA_ERROR); \ | ||
101 | lval = gPerm[zvec - gBase[zn]]; \ | ||
102 | } | ||
103 | |||
104 | |||
105 | /*---------------------------------------------------*/ | ||
106 | Int32 BZ2_decompress ( DState* s ) | ||
107 | { | ||
108 | UChar uc; | ||
109 | Int32 retVal; | ||
110 | Int32 minLen, maxLen; | ||
111 | bz_stream* strm = s->strm; | ||
112 | |||
113 | /* stuff that needs to be saved/restored */ | ||
114 | Int32 i; | ||
115 | Int32 j; | ||
116 | Int32 t; | ||
117 | Int32 alphaSize; | ||
118 | Int32 nGroups; | ||
119 | Int32 nSelectors; | ||
120 | Int32 EOB; | ||
121 | Int32 groupNo; | ||
122 | Int32 groupPos; | ||
123 | Int32 nextSym; | ||
124 | Int32 nblockMAX; | ||
125 | Int32 nblock; | ||
126 | Int32 es; | ||
127 | Int32 N; | ||
128 | Int32 curr; | ||
129 | Int32 zt; | ||
130 | Int32 zn; | ||
131 | Int32 zvec; | ||
132 | Int32 zj; | ||
133 | Int32 gSel; | ||
134 | Int32 gMinlen; | ||
135 | Int32* gLimit; | ||
136 | Int32* gBase; | ||
137 | Int32* gPerm; | ||
138 | |||
139 | if (s->state == BZ_X_MAGIC_1) { | ||
140 | /*initialise the save area*/ | ||
141 | s->save_i = 0; | ||
142 | s->save_j = 0; | ||
143 | s->save_t = 0; | ||
144 | s->save_alphaSize = 0; | ||
145 | s->save_nGroups = 0; | ||
146 | s->save_nSelectors = 0; | ||
147 | s->save_EOB = 0; | ||
148 | s->save_groupNo = 0; | ||
149 | s->save_groupPos = 0; | ||
150 | s->save_nextSym = 0; | ||
151 | s->save_nblockMAX = 0; | ||
152 | s->save_nblock = 0; | ||
153 | s->save_es = 0; | ||
154 | s->save_N = 0; | ||
155 | s->save_curr = 0; | ||
156 | s->save_zt = 0; | ||
157 | s->save_zn = 0; | ||
158 | s->save_zvec = 0; | ||
159 | s->save_zj = 0; | ||
160 | s->save_gSel = 0; | ||
161 | s->save_gMinlen = 0; | ||
162 | s->save_gLimit = NULL; | ||
163 | s->save_gBase = NULL; | ||
164 | s->save_gPerm = NULL; | ||
165 | } | ||
166 | |||
167 | /*restore from the save area*/ | ||
168 | i = s->save_i; | ||
169 | j = s->save_j; | ||
170 | t = s->save_t; | ||
171 | alphaSize = s->save_alphaSize; | ||
172 | nGroups = s->save_nGroups; | ||
173 | nSelectors = s->save_nSelectors; | ||
174 | EOB = s->save_EOB; | ||
175 | groupNo = s->save_groupNo; | ||
176 | groupPos = s->save_groupPos; | ||
177 | nextSym = s->save_nextSym; | ||
178 | nblockMAX = s->save_nblockMAX; | ||
179 | nblock = s->save_nblock; | ||
180 | es = s->save_es; | ||
181 | N = s->save_N; | ||
182 | curr = s->save_curr; | ||
183 | zt = s->save_zt; | ||
184 | zn = s->save_zn; | ||
185 | zvec = s->save_zvec; | ||
186 | zj = s->save_zj; | ||
187 | gSel = s->save_gSel; | ||
188 | gMinlen = s->save_gMinlen; | ||
189 | gLimit = s->save_gLimit; | ||
190 | gBase = s->save_gBase; | ||
191 | gPerm = s->save_gPerm; | ||
192 | |||
193 | retVal = BZ_OK; | ||
194 | |||
195 | switch (s->state) { | ||
196 | |||
197 | GET_UCHAR(BZ_X_MAGIC_1, uc); | ||
198 | if (uc != BZ_HDR_B) RETURN(BZ_DATA_ERROR_MAGIC); | ||
199 | |||
200 | GET_UCHAR(BZ_X_MAGIC_2, uc); | ||
201 | if (uc != BZ_HDR_Z) RETURN(BZ_DATA_ERROR_MAGIC); | ||
202 | |||
203 | GET_UCHAR(BZ_X_MAGIC_3, uc) | ||
204 | if (uc != BZ_HDR_h) RETURN(BZ_DATA_ERROR_MAGIC); | ||
205 | |||
206 | GET_BITS(BZ_X_MAGIC_4, s->blockSize100k, 8) | ||
207 | if (s->blockSize100k < (BZ_HDR_0 + 1) || | ||
208 | s->blockSize100k > (BZ_HDR_0 + 9)) RETURN(BZ_DATA_ERROR_MAGIC); | ||
209 | s->blockSize100k -= BZ_HDR_0; | ||
210 | |||
211 | if (s->smallDecompress) { | ||
212 | s->ll16 = BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) ); | ||
213 | s->ll4 = BZALLOC( | ||
214 | ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar) | ||
215 | ); | ||
216 | if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR); | ||
217 | } else { | ||
218 | s->tt = BZALLOC( s->blockSize100k * 100000 * sizeof(Int32) ); | ||
219 | if (s->tt == NULL) RETURN(BZ_MEM_ERROR); | ||
220 | } | ||
221 | |||
222 | GET_UCHAR(BZ_X_BLKHDR_1, uc); | ||
223 | |||
224 | if (uc == 0x17) goto endhdr_2; | ||
225 | if (uc != 0x31) RETURN(BZ_DATA_ERROR); | ||
226 | GET_UCHAR(BZ_X_BLKHDR_2, uc); | ||
227 | if (uc != 0x41) RETURN(BZ_DATA_ERROR); | ||
228 | GET_UCHAR(BZ_X_BLKHDR_3, uc); | ||
229 | if (uc != 0x59) RETURN(BZ_DATA_ERROR); | ||
230 | GET_UCHAR(BZ_X_BLKHDR_4, uc); | ||
231 | if (uc != 0x26) RETURN(BZ_DATA_ERROR); | ||
232 | GET_UCHAR(BZ_X_BLKHDR_5, uc); | ||
233 | if (uc != 0x53) RETURN(BZ_DATA_ERROR); | ||
234 | GET_UCHAR(BZ_X_BLKHDR_6, uc); | ||
235 | if (uc != 0x59) RETURN(BZ_DATA_ERROR); | ||
236 | |||
237 | s->currBlockNo++; | ||
238 | if (s->verbosity >= 2) | ||
239 | VPrintf1 ( "\n [%d: huff+mtf ", s->currBlockNo ); | ||
240 | |||
241 | s->storedBlockCRC = 0; | ||
242 | GET_UCHAR(BZ_X_BCRC_1, uc); | ||
243 | s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc); | ||
244 | GET_UCHAR(BZ_X_BCRC_2, uc); | ||
245 | s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc); | ||
246 | GET_UCHAR(BZ_X_BCRC_3, uc); | ||
247 | s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc); | ||
248 | GET_UCHAR(BZ_X_BCRC_4, uc); | ||
249 | s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc); | ||
250 | |||
251 | GET_BITS(BZ_X_RANDBIT, s->blockRandomised, 1); | ||
252 | |||
253 | s->origPtr = 0; | ||
254 | GET_UCHAR(BZ_X_ORIGPTR_1, uc); | ||
255 | s->origPtr = (s->origPtr << 8) | ((Int32)uc); | ||
256 | GET_UCHAR(BZ_X_ORIGPTR_2, uc); | ||
257 | s->origPtr = (s->origPtr << 8) | ((Int32)uc); | ||
258 | GET_UCHAR(BZ_X_ORIGPTR_3, uc); | ||
259 | s->origPtr = (s->origPtr << 8) | ((Int32)uc); | ||
260 | |||
261 | if (s->origPtr < 0) | ||
262 | RETURN(BZ_DATA_ERROR); | ||
263 | if (s->origPtr > 10 + 100000*s->blockSize100k) | ||
264 | RETURN(BZ_DATA_ERROR); | ||
265 | |||
266 | /*--- Receive the mapping table ---*/ | ||
267 | for (i = 0; i < 16; i++) { | ||
268 | GET_BIT(BZ_X_MAPPING_1, uc); | ||
269 | if (uc == 1) | ||
270 | s->inUse16[i] = True; else | ||
271 | s->inUse16[i] = False; | ||
272 | } | ||
273 | |||
274 | for (i = 0; i < 256; i++) s->inUse[i] = False; | ||
275 | |||
276 | for (i = 0; i < 16; i++) | ||
277 | if (s->inUse16[i]) | ||
278 | for (j = 0; j < 16; j++) { | ||
279 | GET_BIT(BZ_X_MAPPING_2, uc); | ||
280 | if (uc == 1) s->inUse[i * 16 + j] = True; | ||
281 | } | ||
282 | makeMaps_d ( s ); | ||
283 | if (s->nInUse == 0) RETURN(BZ_DATA_ERROR); | ||
284 | alphaSize = s->nInUse+2; | ||
285 | |||
286 | /*--- Now the selectors ---*/ | ||
287 | GET_BITS(BZ_X_SELECTOR_1, nGroups, 3); | ||
288 | if (nGroups < 2 || nGroups > 6) RETURN(BZ_DATA_ERROR); | ||
289 | GET_BITS(BZ_X_SELECTOR_2, nSelectors, 15); | ||
290 | if (nSelectors < 1) RETURN(BZ_DATA_ERROR); | ||
291 | for (i = 0; i < nSelectors; i++) { | ||
292 | j = 0; | ||
293 | while (True) { | ||
294 | GET_BIT(BZ_X_SELECTOR_3, uc); | ||
295 | if (uc == 0) break; | ||
296 | j++; | ||
297 | if (j >= nGroups) RETURN(BZ_DATA_ERROR); | ||
298 | } | ||
299 | s->selectorMtf[i] = j; | ||
300 | } | ||
301 | |||
302 | /*--- Undo the MTF values for the selectors. ---*/ | ||
303 | { | ||
304 | UChar pos[BZ_N_GROUPS], tmp, v; | ||
305 | for (v = 0; v < nGroups; v++) pos[v] = v; | ||
306 | |||
307 | for (i = 0; i < nSelectors; i++) { | ||
308 | v = s->selectorMtf[i]; | ||
309 | tmp = pos[v]; | ||
310 | while (v > 0) { pos[v] = pos[v-1]; v--; } | ||
311 | pos[0] = tmp; | ||
312 | s->selector[i] = tmp; | ||
313 | } | ||
314 | } | ||
315 | |||
316 | /*--- Now the coding tables ---*/ | ||
317 | for (t = 0; t < nGroups; t++) { | ||
318 | GET_BITS(BZ_X_CODING_1, curr, 5); | ||
319 | for (i = 0; i < alphaSize; i++) { | ||
320 | while (True) { | ||
321 | if (curr < 1 || curr > 20) RETURN(BZ_DATA_ERROR); | ||
322 | GET_BIT(BZ_X_CODING_2, uc); | ||
323 | if (uc == 0) break; | ||
324 | GET_BIT(BZ_X_CODING_3, uc); | ||
325 | if (uc == 0) curr++; else curr--; | ||
326 | } | ||
327 | s->len[t][i] = curr; | ||
328 | } | ||
329 | } | ||
330 | |||
331 | /*--- Create the Huffman decoding tables ---*/ | ||
332 | for (t = 0; t < nGroups; t++) { | ||
333 | minLen = 32; | ||
334 | maxLen = 0; | ||
335 | for (i = 0; i < alphaSize; i++) { | ||
336 | if (s->len[t][i] > maxLen) maxLen = s->len[t][i]; | ||
337 | if (s->len[t][i] < minLen) minLen = s->len[t][i]; | ||
338 | } | ||
339 | BZ2_hbCreateDecodeTables ( | ||
340 | &(s->limit[t][0]), | ||
341 | &(s->base[t][0]), | ||
342 | &(s->perm[t][0]), | ||
343 | &(s->len[t][0]), | ||
344 | minLen, maxLen, alphaSize | ||
345 | ); | ||
346 | s->minLens[t] = minLen; | ||
347 | } | ||
348 | |||
349 | /*--- Now the MTF values ---*/ | ||
350 | |||
351 | EOB = s->nInUse+1; | ||
352 | nblockMAX = 100000 * s->blockSize100k; | ||
353 | groupNo = -1; | ||
354 | groupPos = 0; | ||
355 | |||
356 | for (i = 0; i <= 255; i++) s->unzftab[i] = 0; | ||
357 | |||
358 | /*-- MTF init --*/ | ||
359 | { | ||
360 | Int32 ii, jj, kk; | ||
361 | kk = MTFA_SIZE-1; | ||
362 | for (ii = 256 / MTFL_SIZE - 1; ii >= 0; ii--) { | ||
363 | for (jj = MTFL_SIZE-1; jj >= 0; jj--) { | ||
364 | s->mtfa[kk] = (UChar)(ii * MTFL_SIZE + jj); | ||
365 | kk--; | ||
366 | } | ||
367 | s->mtfbase[ii] = kk + 1; | ||
368 | } | ||
369 | } | ||
370 | /*-- end MTF init --*/ | ||
371 | |||
372 | nblock = 0; | ||
373 | GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym); | ||
374 | |||
375 | while (True) { | ||
376 | |||
377 | if (nextSym == EOB) break; | ||
378 | |||
379 | if (nextSym == BZ_RUNA || nextSym == BZ_RUNB) { | ||
380 | |||
381 | es = -1; | ||
382 | N = 1; | ||
383 | do { | ||
384 | /* Check that N doesn't get too big, so that es doesn't | ||
385 | go negative. The maximum value that can be | ||
386 | RUNA/RUNB encoded is equal to the block size (post | ||
387 | the initial RLE), viz, 900k, so bounding N at 2 | ||
388 | million should guard against overflow without | ||
389 | rejecting any legitimate inputs. */ | ||
390 | if (N >= 2*1024*1024) RETURN(BZ_DATA_ERROR); | ||
391 | if (nextSym == BZ_RUNA) es = es + (0+1) * N; else | ||
392 | if (nextSym == BZ_RUNB) es = es + (1+1) * N; | ||
393 | N = N * 2; | ||
394 | GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym); | ||
395 | } | ||
396 | while (nextSym == BZ_RUNA || nextSym == BZ_RUNB); | ||
397 | |||
398 | es++; | ||
399 | uc = s->seqToUnseq[ s->mtfa[s->mtfbase[0]] ]; | ||
400 | s->unzftab[uc] += es; | ||
401 | |||
402 | if (s->smallDecompress) | ||
403 | while (es > 0) { | ||
404 | if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR); | ||
405 | s->ll16[nblock] = (UInt16)uc; | ||
406 | nblock++; | ||
407 | es--; | ||
408 | } | ||
409 | else | ||
410 | while (es > 0) { | ||
411 | if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR); | ||
412 | s->tt[nblock] = (UInt32)uc; | ||
413 | nblock++; | ||
414 | es--; | ||
415 | }; | ||
416 | |||
417 | continue; | ||
418 | |||
419 | } else { | ||
420 | |||
421 | if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR); | ||
422 | |||
423 | /*-- uc = MTF ( nextSym-1 ) --*/ | ||
424 | { | ||
425 | Int32 ii, jj, kk, pp, lno, off; | ||
426 | UInt32 nn; | ||
427 | nn = (UInt32)(nextSym - 1); | ||
428 | |||
429 | if (nn < MTFL_SIZE) { | ||
430 | /* avoid general-case expense */ | ||
431 | pp = s->mtfbase[0]; | ||
432 | uc = s->mtfa[pp+nn]; | ||
433 | while (nn > 3) { | ||
434 | Int32 z = pp+nn; | ||
435 | s->mtfa[(z) ] = s->mtfa[(z)-1]; | ||
436 | s->mtfa[(z)-1] = s->mtfa[(z)-2]; | ||
437 | s->mtfa[(z)-2] = s->mtfa[(z)-3]; | ||
438 | s->mtfa[(z)-3] = s->mtfa[(z)-4]; | ||
439 | nn -= 4; | ||
440 | } | ||
441 | while (nn > 0) { | ||
442 | s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--; | ||
443 | }; | ||
444 | s->mtfa[pp] = uc; | ||
445 | } else { | ||
446 | /* general case */ | ||
447 | lno = nn / MTFL_SIZE; | ||
448 | off = nn % MTFL_SIZE; | ||
449 | pp = s->mtfbase[lno] + off; | ||
450 | uc = s->mtfa[pp]; | ||
451 | while (pp > s->mtfbase[lno]) { | ||
452 | s->mtfa[pp] = s->mtfa[pp-1]; pp--; | ||
453 | }; | ||
454 | s->mtfbase[lno]++; | ||
455 | while (lno > 0) { | ||
456 | s->mtfbase[lno]--; | ||
457 | s->mtfa[s->mtfbase[lno]] | ||
458 | = s->mtfa[s->mtfbase[lno-1] + MTFL_SIZE - 1]; | ||
459 | lno--; | ||
460 | } | ||
461 | s->mtfbase[0]--; | ||
462 | s->mtfa[s->mtfbase[0]] = uc; | ||
463 | if (s->mtfbase[0] == 0) { | ||
464 | kk = MTFA_SIZE-1; | ||
465 | for (ii = 256 / MTFL_SIZE-1; ii >= 0; ii--) { | ||
466 | for (jj = MTFL_SIZE-1; jj >= 0; jj--) { | ||
467 | s->mtfa[kk] = s->mtfa[s->mtfbase[ii] + jj]; | ||
468 | kk--; | ||
469 | } | ||
470 | s->mtfbase[ii] = kk + 1; | ||
471 | } | ||
472 | } | ||
473 | } | ||
474 | } | ||
475 | /*-- end uc = MTF ( nextSym-1 ) --*/ | ||
476 | |||
477 | s->unzftab[s->seqToUnseq[uc]]++; | ||
478 | if (s->smallDecompress) | ||
479 | s->ll16[nblock] = (UInt16)(s->seqToUnseq[uc]); else | ||
480 | s->tt[nblock] = (UInt32)(s->seqToUnseq[uc]); | ||
481 | nblock++; | ||
482 | |||
483 | GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym); | ||
484 | continue; | ||
485 | } | ||
486 | } | ||
487 | |||
488 | /* Now we know what nblock is, we can do a better sanity | ||
489 | check on s->origPtr. | ||
490 | */ | ||
491 | if (s->origPtr < 0 || s->origPtr >= nblock) | ||
492 | RETURN(BZ_DATA_ERROR); | ||
493 | |||
494 | /*-- Set up cftab to facilitate generation of T^(-1) --*/ | ||
495 | /* Check: unzftab entries in range. */ | ||
496 | for (i = 0; i <= 255; i++) { | ||
497 | if (s->unzftab[i] < 0 || s->unzftab[i] > nblock) | ||
498 | RETURN(BZ_DATA_ERROR); | ||
499 | } | ||
500 | /* Actually generate cftab. */ | ||
501 | s->cftab[0] = 0; | ||
502 | for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1]; | ||
503 | for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1]; | ||
504 | /* Check: cftab entries in range. */ | ||
505 | for (i = 0; i <= 256; i++) { | ||
506 | if (s->cftab[i] < 0 || s->cftab[i] > nblock) { | ||
507 | /* s->cftab[i] can legitimately be == nblock */ | ||
508 | RETURN(BZ_DATA_ERROR); | ||
509 | } | ||
510 | } | ||
511 | /* Check: cftab entries non-descending. */ | ||
512 | for (i = 1; i <= 256; i++) { | ||
513 | if (s->cftab[i-1] > s->cftab[i]) { | ||
514 | RETURN(BZ_DATA_ERROR); | ||
515 | } | ||
516 | } | ||
517 | |||
518 | s->state_out_len = 0; | ||
519 | s->state_out_ch = 0; | ||
520 | BZ_INITIALISE_CRC ( s->calculatedBlockCRC ); | ||
521 | s->state = BZ_X_OUTPUT; | ||
522 | if (s->verbosity >= 2) VPrintf0 ( "rt+rld" ); | ||
523 | |||
524 | if (s->smallDecompress) { | ||
525 | |||
526 | /*-- Make a copy of cftab, used in generation of T --*/ | ||
527 | for (i = 0; i <= 256; i++) s->cftabCopy[i] = s->cftab[i]; | ||
528 | |||
529 | /*-- compute the T vector --*/ | ||
530 | for (i = 0; i < nblock; i++) { | ||
531 | uc = (UChar)(s->ll16[i]); | ||
532 | SET_LL(i, s->cftabCopy[uc]); | ||
533 | s->cftabCopy[uc]++; | ||
534 | } | ||
535 | |||
536 | /*-- Compute T^(-1) by pointer reversal on T --*/ | ||
537 | i = s->origPtr; | ||
538 | j = GET_LL(i); | ||
539 | do { | ||
540 | Int32 tmp = GET_LL(j); | ||
541 | SET_LL(j, i); | ||
542 | i = j; | ||
543 | j = tmp; | ||
544 | } | ||
545 | while (i != s->origPtr); | ||
546 | |||
547 | s->tPos = s->origPtr; | ||
548 | s->nblock_used = 0; | ||
549 | if (s->blockRandomised) { | ||
550 | BZ_RAND_INIT_MASK; | ||
551 | BZ_GET_SMALL(s->k0); s->nblock_used++; | ||
552 | BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; | ||
553 | } else { | ||
554 | BZ_GET_SMALL(s->k0); s->nblock_used++; | ||
555 | } | ||
556 | |||
557 | } else { | ||
558 | |||
559 | /*-- compute the T^(-1) vector --*/ | ||
560 | for (i = 0; i < nblock; i++) { | ||
561 | uc = (UChar)(s->tt[i] & 0xff); | ||
562 | s->tt[s->cftab[uc]] |= (i << 8); | ||
563 | s->cftab[uc]++; | ||
564 | } | ||
565 | |||
566 | s->tPos = s->tt[s->origPtr] >> 8; | ||
567 | s->nblock_used = 0; | ||
568 | if (s->blockRandomised) { | ||
569 | BZ_RAND_INIT_MASK; | ||
570 | BZ_GET_FAST(s->k0); s->nblock_used++; | ||
571 | BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; | ||
572 | } else { | ||
573 | BZ_GET_FAST(s->k0); s->nblock_used++; | ||
574 | } | ||
575 | |||
576 | } | ||
577 | |||
578 | RETURN(BZ_OK); | ||
579 | |||
580 | |||
581 | |||
582 | endhdr_2: | ||
583 | |||
584 | GET_UCHAR(BZ_X_ENDHDR_2, uc); | ||
585 | if (uc != 0x72) RETURN(BZ_DATA_ERROR); | ||
586 | GET_UCHAR(BZ_X_ENDHDR_3, uc); | ||
587 | if (uc != 0x45) RETURN(BZ_DATA_ERROR); | ||
588 | GET_UCHAR(BZ_X_ENDHDR_4, uc); | ||
589 | if (uc != 0x38) RETURN(BZ_DATA_ERROR); | ||
590 | GET_UCHAR(BZ_X_ENDHDR_5, uc); | ||
591 | if (uc != 0x50) RETURN(BZ_DATA_ERROR); | ||
592 | GET_UCHAR(BZ_X_ENDHDR_6, uc); | ||
593 | if (uc != 0x90) RETURN(BZ_DATA_ERROR); | ||
594 | |||
595 | s->storedCombinedCRC = 0; | ||
596 | GET_UCHAR(BZ_X_CCRC_1, uc); | ||
597 | s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc); | ||
598 | GET_UCHAR(BZ_X_CCRC_2, uc); | ||
599 | s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc); | ||
600 | GET_UCHAR(BZ_X_CCRC_3, uc); | ||
601 | s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc); | ||
602 | GET_UCHAR(BZ_X_CCRC_4, uc); | ||
603 | s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc); | ||
604 | |||
605 | s->state = BZ_X_IDLE; | ||
606 | RETURN(BZ_STREAM_END); | ||
607 | |||
608 | default: AssertH ( False, 4001 ); | ||
609 | } | ||
610 | |||
611 | AssertH ( False, 4002 ); | ||
612 | |||
613 | save_state_and_return: | ||
614 | |||
615 | s->save_i = i; | ||
616 | s->save_j = j; | ||
617 | s->save_t = t; | ||
618 | s->save_alphaSize = alphaSize; | ||
619 | s->save_nGroups = nGroups; | ||
620 | s->save_nSelectors = nSelectors; | ||
621 | s->save_EOB = EOB; | ||
622 | s->save_groupNo = groupNo; | ||
623 | s->save_groupPos = groupPos; | ||
624 | s->save_nextSym = nextSym; | ||
625 | s->save_nblockMAX = nblockMAX; | ||
626 | s->save_nblock = nblock; | ||
627 | s->save_es = es; | ||
628 | s->save_N = N; | ||
629 | s->save_curr = curr; | ||
630 | s->save_zt = zt; | ||
631 | s->save_zn = zn; | ||
632 | s->save_zvec = zvec; | ||
633 | s->save_zj = zj; | ||
634 | s->save_gSel = gSel; | ||
635 | s->save_gMinlen = gMinlen; | ||
636 | s->save_gLimit = gLimit; | ||
637 | s->save_gBase = gBase; | ||
638 | s->save_gPerm = gPerm; | ||
639 | |||
640 | return retVal; | ||
641 | } | ||
642 | |||
643 | |||
644 | /*-------------------------------------------------------------*/ | ||
645 | /*--- end decompress.c ---*/ | ||
646 | /*-------------------------------------------------------------*/ | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/dlltest.c b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/dlltest.c new file mode 100644 index 0000000..03fa146 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/dlltest.c | |||
@@ -0,0 +1,175 @@ | |||
1 | /* | ||
2 | minibz2 | ||
3 | libbz2.dll test program. | ||
4 | by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp) | ||
5 | This file is Public Domain. Welcome any email to me. | ||
6 | |||
7 | usage: minibz2 [-d] [-{1,2,..9}] [[srcfilename] destfilename] | ||
8 | */ | ||
9 | |||
10 | #define BZ_IMPORT | ||
11 | #include <stdio.h> | ||
12 | #include <stdlib.h> | ||
13 | #include "bzlib.h" | ||
14 | #ifdef _WIN32 | ||
15 | #include <io.h> | ||
16 | #endif | ||
17 | |||
18 | |||
19 | #ifdef _WIN32 | ||
20 | |||
21 | #define BZ2_LIBNAME "libbz2-1.0.2.DLL" | ||
22 | |||
23 | #include <windows.h> | ||
24 | static int BZ2DLLLoaded = 0; | ||
25 | static HINSTANCE BZ2DLLhLib; | ||
26 | int BZ2DLLLoadLibrary(void) | ||
27 | { | ||
28 | HINSTANCE hLib; | ||
29 | |||
30 | if(BZ2DLLLoaded==1){return 0;} | ||
31 | hLib=LoadLibrary(BZ2_LIBNAME); | ||
32 | if(hLib == NULL){ | ||
33 | fprintf(stderr,"Can't load %s\n",BZ2_LIBNAME); | ||
34 | return -1; | ||
35 | } | ||
36 | BZ2_bzlibVersion=GetProcAddress(hLib,"BZ2_bzlibVersion"); | ||
37 | BZ2_bzopen=GetProcAddress(hLib,"BZ2_bzopen"); | ||
38 | BZ2_bzdopen=GetProcAddress(hLib,"BZ2_bzdopen"); | ||
39 | BZ2_bzread=GetProcAddress(hLib,"BZ2_bzread"); | ||
40 | BZ2_bzwrite=GetProcAddress(hLib,"BZ2_bzwrite"); | ||
41 | BZ2_bzflush=GetProcAddress(hLib,"BZ2_bzflush"); | ||
42 | BZ2_bzclose=GetProcAddress(hLib,"BZ2_bzclose"); | ||
43 | BZ2_bzerror=GetProcAddress(hLib,"BZ2_bzerror"); | ||
44 | |||
45 | if (!BZ2_bzlibVersion || !BZ2_bzopen || !BZ2_bzdopen | ||
46 | || !BZ2_bzread || !BZ2_bzwrite || !BZ2_bzflush | ||
47 | || !BZ2_bzclose || !BZ2_bzerror) { | ||
48 | fprintf(stderr,"GetProcAddress failed.\n"); | ||
49 | return -1; | ||
50 | } | ||
51 | BZ2DLLLoaded=1; | ||
52 | BZ2DLLhLib=hLib; | ||
53 | return 0; | ||
54 | |||
55 | } | ||
56 | int BZ2DLLFreeLibrary(void) | ||
57 | { | ||
58 | if(BZ2DLLLoaded==0){return 0;} | ||
59 | FreeLibrary(BZ2DLLhLib); | ||
60 | BZ2DLLLoaded=0; | ||
61 | } | ||
62 | #endif /* WIN32 */ | ||
63 | |||
64 | void usage(void) | ||
65 | { | ||
66 | puts("usage: minibz2 [-d] [-{1,2,..9}] [[srcfilename] destfilename]"); | ||
67 | } | ||
68 | |||
69 | int main(int argc,char *argv[]) | ||
70 | { | ||
71 | int decompress = 0; | ||
72 | int level = 9; | ||
73 | char *fn_r = NULL; | ||
74 | char *fn_w = NULL; | ||
75 | |||
76 | #ifdef _WIN32 | ||
77 | if(BZ2DLLLoadLibrary()<0){ | ||
78 | fprintf(stderr,"Loading of %s failed. Giving up.\n", BZ2_LIBNAME); | ||
79 | exit(1); | ||
80 | } | ||
81 | printf("Loading of %s succeeded. Library version is %s.\n", | ||
82 | BZ2_LIBNAME, BZ2_bzlibVersion() ); | ||
83 | #endif | ||
84 | while(++argv,--argc){ | ||
85 | if(**argv =='-' || **argv=='/'){ | ||
86 | char *p; | ||
87 | |||
88 | for(p=*argv+1;*p;p++){ | ||
89 | if(*p=='d'){ | ||
90 | decompress = 1; | ||
91 | }else if('1'<=*p && *p<='9'){ | ||
92 | level = *p - '0'; | ||
93 | }else{ | ||
94 | usage(); | ||
95 | exit(1); | ||
96 | } | ||
97 | } | ||
98 | }else{ | ||
99 | break; | ||
100 | } | ||
101 | } | ||
102 | if(argc>=1){ | ||
103 | fn_r = *argv; | ||
104 | argc--;argv++; | ||
105 | }else{ | ||
106 | fn_r = NULL; | ||
107 | } | ||
108 | if(argc>=1){ | ||
109 | fn_w = *argv; | ||
110 | argc--;argv++; | ||
111 | }else{ | ||
112 | fn_w = NULL; | ||
113 | } | ||
114 | { | ||
115 | int len; | ||
116 | char buff[0x1000]; | ||
117 | char mode[10]; | ||
118 | |||
119 | if(decompress){ | ||
120 | BZFILE *BZ2fp_r = NULL; | ||
121 | FILE *fp_w = NULL; | ||
122 | |||
123 | if(fn_w){ | ||
124 | if((fp_w = fopen(fn_w,"wb"))==NULL){ | ||
125 | printf("can't open [%s]\n",fn_w); | ||
126 | perror("reason:"); | ||
127 | exit(1); | ||
128 | } | ||
129 | }else{ | ||
130 | fp_w = stdout; | ||
131 | } | ||
132 | if((fn_r == NULL && (BZ2fp_r = BZ2_bzdopen(fileno(stdin),"rb"))==NULL) | ||
133 | || (fn_r != NULL && (BZ2fp_r = BZ2_bzopen(fn_r,"rb"))==NULL)){ | ||
134 | printf("can't bz2openstream\n"); | ||
135 | exit(1); | ||
136 | } | ||
137 | while((len=BZ2_bzread(BZ2fp_r,buff,0x1000))>0){ | ||
138 | fwrite(buff,1,len,fp_w); | ||
139 | } | ||
140 | BZ2_bzclose(BZ2fp_r); | ||
141 | if(fp_w != stdout) fclose(fp_w); | ||
142 | }else{ | ||
143 | BZFILE *BZ2fp_w = NULL; | ||
144 | FILE *fp_r = NULL; | ||
145 | |||
146 | if(fn_r){ | ||
147 | if((fp_r = fopen(fn_r,"rb"))==NULL){ | ||
148 | printf("can't open [%s]\n",fn_r); | ||
149 | perror("reason:"); | ||
150 | exit(1); | ||
151 | } | ||
152 | }else{ | ||
153 | fp_r = stdin; | ||
154 | } | ||
155 | mode[0]='w'; | ||
156 | mode[1] = '0' + level; | ||
157 | mode[2] = '\0'; | ||
158 | |||
159 | if((fn_w == NULL && (BZ2fp_w = BZ2_bzdopen(fileno(stdout),mode))==NULL) | ||
160 | || (fn_w !=NULL && (BZ2fp_w = BZ2_bzopen(fn_w,mode))==NULL)){ | ||
161 | printf("can't bz2openstream\n"); | ||
162 | exit(1); | ||
163 | } | ||
164 | while((len=fread(buff,1,0x1000,fp_r))>0){ | ||
165 | BZ2_bzwrite(BZ2fp_w,buff,len); | ||
166 | } | ||
167 | BZ2_bzclose(BZ2fp_w); | ||
168 | if(fp_r!=stdin)fclose(fp_r); | ||
169 | } | ||
170 | } | ||
171 | #ifdef _WIN32 | ||
172 | BZ2DLLFreeLibrary(); | ||
173 | #endif | ||
174 | return 0; | ||
175 | } | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/dlltest.dsp b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/dlltest.dsp new file mode 100644 index 0000000..4b1615e --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/dlltest.dsp | |||
@@ -0,0 +1,93 @@ | |||
1 | # Microsoft Developer Studio Project File - Name="dlltest" - Package Owner=<4> | ||
2 | # Microsoft Developer Studio Generated Build File, Format Version 5.00 | ||
3 | # ** •ÒW‚µ‚È‚¢‚Å‚‚¾‚³‚¢ ** | ||
4 | |||
5 | # TARGTYPE "Win32 (x86) Console Application" 0x0103 | ||
6 | |||
7 | CFG=dlltest - Win32 Debug | ||
8 | !MESSAGE ‚±‚ê‚Í—LŒø‚ÈÒ²¸Ì§²Ù‚Å‚Í‚ ‚è‚Ü‚¹‚ñB ‚±‚ÌÌßÛ¼Þª¸Ä‚ðËÞÙÄÞ‚·‚邽‚ß‚É‚Í NMAKE ‚ðŽg—p‚µ‚Ä‚‚¾‚³‚¢B | ||
9 | !MESSAGE [Ò²¸Ì§²Ù‚Ì´¸½Îß°Ä] ºÏÝÄÞ‚ðŽg—p‚µ‚ÄŽÀs‚µ‚Ä‚‚¾‚³‚¢ | ||
10 | !MESSAGE | ||
11 | !MESSAGE NMAKE /f "dlltest.mak". | ||
12 | !MESSAGE | ||
13 | !MESSAGE NMAKE ‚ÌŽÀsŽž‚É\¬‚ðŽw’è‚Å‚«‚Ü‚· | ||
14 | !MESSAGE ºÏÝÄÞ ×²Ýã‚ÅϸۂÌÝ’è‚ð’è‹`‚µ‚Ü‚·B—á: | ||
15 | !MESSAGE | ||
16 | !MESSAGE NMAKE /f "dlltest.mak" CFG="dlltest - Win32 Debug" | ||
17 | !MESSAGE | ||
18 | !MESSAGE ‘I‘ð‰Â”\‚ÈËÞÙÄÞ Ó°ÄÞ: | ||
19 | !MESSAGE | ||
20 | !MESSAGE "dlltest - Win32 Release" ("Win32 (x86) Console Application" —p) | ||
21 | !MESSAGE "dlltest - Win32 Debug" ("Win32 (x86) Console Application" —p) | ||
22 | !MESSAGE | ||
23 | |||
24 | # Begin Project | ||
25 | # PROP Scc_ProjName "" | ||
26 | # PROP Scc_LocalPath "" | ||
27 | CPP=cl.exe | ||
28 | RSC=rc.exe | ||
29 | |||
30 | !IF "$(CFG)" == "dlltest - Win32 Release" | ||
31 | |||
32 | # PROP BASE Use_MFC 0 | ||
33 | # PROP BASE Use_Debug_Libraries 0 | ||
34 | # PROP BASE Output_Dir "Release" | ||
35 | # PROP BASE Intermediate_Dir "Release" | ||
36 | # PROP BASE Target_Dir "" | ||
37 | # PROP Use_MFC 0 | ||
38 | # PROP Use_Debug_Libraries 0 | ||
39 | # PROP Output_Dir "Release" | ||
40 | # PROP Intermediate_Dir "Release" | ||
41 | # PROP Ignore_Export_Lib 0 | ||
42 | # PROP Target_Dir "" | ||
43 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c | ||
44 | # ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c | ||
45 | # ADD BASE RSC /l 0x411 /d "NDEBUG" | ||
46 | # ADD RSC /l 0x411 /d "NDEBUG" | ||
47 | BSC32=bscmake.exe | ||
48 | # ADD BASE BSC32 /nologo | ||
49 | # ADD BSC32 /nologo | ||
50 | LINK32=link.exe | ||
51 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 | ||
52 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"minibz2.exe" | ||
53 | |||
54 | !ELSEIF "$(CFG)" == "dlltest - Win32 Debug" | ||
55 | |||
56 | # PROP BASE Use_MFC 0 | ||
57 | # PROP BASE Use_Debug_Libraries 1 | ||
58 | # PROP BASE Output_Dir "dlltest_" | ||
59 | # PROP BASE Intermediate_Dir "dlltest_" | ||
60 | # PROP BASE Target_Dir "" | ||
61 | # PROP Use_MFC 0 | ||
62 | # PROP Use_Debug_Libraries 1 | ||
63 | # PROP Output_Dir "dlltest_" | ||
64 | # PROP Intermediate_Dir "dlltest_" | ||
65 | # PROP Ignore_Export_Lib 0 | ||
66 | # PROP Target_Dir "" | ||
67 | # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c | ||
68 | # ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c | ||
69 | # ADD BASE RSC /l 0x411 /d "_DEBUG" | ||
70 | # ADD RSC /l 0x411 /d "_DEBUG" | ||
71 | BSC32=bscmake.exe | ||
72 | # ADD BASE BSC32 /nologo | ||
73 | # ADD BSC32 /nologo | ||
74 | LINK32=link.exe | ||
75 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept | ||
76 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"minibz2.exe" /pdbtype:sept | ||
77 | |||
78 | !ENDIF | ||
79 | |||
80 | # Begin Target | ||
81 | |||
82 | # Name "dlltest - Win32 Release" | ||
83 | # Name "dlltest - Win32 Debug" | ||
84 | # Begin Source File | ||
85 | |||
86 | SOURCE=.\bzlib.h | ||
87 | # End Source File | ||
88 | # Begin Source File | ||
89 | |||
90 | SOURCE=.\dlltest.c | ||
91 | # End Source File | ||
92 | # End Target | ||
93 | # End Project | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/entities.xml b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/entities.xml new file mode 100644 index 0000000..4b28f34 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/entities.xml | |||
@@ -0,0 +1,9 @@ | |||
1 | <!-- misc. strings --> | ||
2 | <!ENTITY bz-url "http://www.bzip.org"> | ||
3 | <!ENTITY bz-email "jseward@bzip.org"> | ||
4 | <!ENTITY bz-lifespan "1996-2010"> | ||
5 | |||
6 | <!ENTITY bz-version "1.0.6"> | ||
7 | <!ENTITY bz-date "6 September 2010"> | ||
8 | |||
9 | <!ENTITY manual-title "bzip2 Manual"> | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/format.pl b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/format.pl new file mode 100644 index 0000000..f169fd9 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/format.pl | |||
@@ -0,0 +1,68 @@ | |||
1 | #!/usr/bin/perl -w | ||
2 | # | ||
3 | # ------------------------------------------------------------------ | ||
4 | # This file is part of bzip2/libbzip2, a program and library for | ||
5 | # lossless, block-sorting data compression. | ||
6 | # | ||
7 | # bzip2/libbzip2 version 1.0.6 of 6 September 2010 | ||
8 | # Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | ||
9 | # | ||
10 | # Please read the WARNING, DISCLAIMER and PATENTS sections in the | ||
11 | # README file. | ||
12 | # | ||
13 | # This program is released under the terms of the license contained | ||
14 | # in the file LICENSE. | ||
15 | # ------------------------------------------------------------------ | ||
16 | # | ||
17 | use strict; | ||
18 | |||
19 | # get command line values: | ||
20 | if ( $#ARGV !=1 ) { | ||
21 | die "Usage: $0 xml_infile xml_outfile\n"; | ||
22 | } | ||
23 | |||
24 | my $infile = shift; | ||
25 | # check infile exists | ||
26 | die "Can't find file \"$infile\"" | ||
27 | unless -f $infile; | ||
28 | # check we can read infile | ||
29 | if (! -r $infile) { | ||
30 | die "Can't read input $infile\n"; | ||
31 | } | ||
32 | # check we can open infile | ||
33 | open( INFILE,"<$infile" ) or | ||
34 | die "Can't input $infile $!"; | ||
35 | |||
36 | #my $outfile = 'fmt-manual.xml'; | ||
37 | my $outfile = shift; | ||
38 | #print "Infile: $infile, Outfile: $outfile\n"; | ||
39 | # check we can write to outfile | ||
40 | open( OUTFILE,">$outfile" ) or | ||
41 | die "Can't output $outfile $! for writing"; | ||
42 | |||
43 | my ($prev, $curr, $str); | ||
44 | $prev = ''; $curr = ''; | ||
45 | while ( <INFILE> ) { | ||
46 | |||
47 | print OUTFILE $prev; | ||
48 | $prev = $curr; | ||
49 | $curr = $_; | ||
50 | $str = ''; | ||
51 | |||
52 | if ( $prev =~ /<programlisting>$|<screen>$/ ) { | ||
53 | chomp $prev; | ||
54 | $curr = join( '', $prev, "<![CDATA[", $curr ); | ||
55 | $prev = ''; | ||
56 | next; | ||
57 | } | ||
58 | elsif ( $curr =~ /<\/programlisting>|<\/screen>/ ) { | ||
59 | chomp $prev; | ||
60 | $curr = join( '', $prev, "]]>", $curr ); | ||
61 | $prev = ''; | ||
62 | next; | ||
63 | } | ||
64 | } | ||
65 | print OUTFILE $curr; | ||
66 | close INFILE; | ||
67 | close OUTFILE; | ||
68 | exit; | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/huffman.c b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/huffman.c new file mode 100644 index 0000000..2283fdb --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/huffman.c | |||
@@ -0,0 +1,205 @@ | |||
1 | |||
2 | /*-------------------------------------------------------------*/ | ||
3 | /*--- Huffman coding low-level stuff ---*/ | ||
4 | /*--- huffman.c ---*/ | ||
5 | /*-------------------------------------------------------------*/ | ||
6 | |||
7 | /* ------------------------------------------------------------------ | ||
8 | This file is part of bzip2/libbzip2, a program and library for | ||
9 | lossless, block-sorting data compression. | ||
10 | |||
11 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | ||
12 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | ||
13 | |||
14 | Please read the WARNING, DISCLAIMER and PATENTS sections in the | ||
15 | README file. | ||
16 | |||
17 | This program is released under the terms of the license contained | ||
18 | in the file LICENSE. | ||
19 | ------------------------------------------------------------------ */ | ||
20 | |||
21 | |||
22 | #include "bzlib_private.h" | ||
23 | |||
24 | /*---------------------------------------------------*/ | ||
25 | #define WEIGHTOF(zz0) ((zz0) & 0xffffff00) | ||
26 | #define DEPTHOF(zz1) ((zz1) & 0x000000ff) | ||
27 | #define MYMAX(zz2,zz3) ((zz2) > (zz3) ? (zz2) : (zz3)) | ||
28 | |||
29 | #define ADDWEIGHTS(zw1,zw2) \ | ||
30 | (WEIGHTOF(zw1)+WEIGHTOF(zw2)) | \ | ||
31 | (1 + MYMAX(DEPTHOF(zw1),DEPTHOF(zw2))) | ||
32 | |||
33 | #define UPHEAP(z) \ | ||
34 | { \ | ||
35 | Int32 zz, tmp; \ | ||
36 | zz = z; tmp = heap[zz]; \ | ||
37 | while (weight[tmp] < weight[heap[zz >> 1]]) { \ | ||
38 | heap[zz] = heap[zz >> 1]; \ | ||
39 | zz >>= 1; \ | ||
40 | } \ | ||
41 | heap[zz] = tmp; \ | ||
42 | } | ||
43 | |||
44 | #define DOWNHEAP(z) \ | ||
45 | { \ | ||
46 | Int32 zz, yy, tmp; \ | ||
47 | zz = z; tmp = heap[zz]; \ | ||
48 | while (True) { \ | ||
49 | yy = zz << 1; \ | ||
50 | if (yy > nHeap) break; \ | ||
51 | if (yy < nHeap && \ | ||
52 | weight[heap[yy+1]] < weight[heap[yy]]) \ | ||
53 | yy++; \ | ||
54 | if (weight[tmp] < weight[heap[yy]]) break; \ | ||
55 | heap[zz] = heap[yy]; \ | ||
56 | zz = yy; \ | ||
57 | } \ | ||
58 | heap[zz] = tmp; \ | ||
59 | } | ||
60 | |||
61 | |||
62 | /*---------------------------------------------------*/ | ||
63 | void BZ2_hbMakeCodeLengths ( UChar *len, | ||
64 | Int32 *freq, | ||
65 | Int32 alphaSize, | ||
66 | Int32 maxLen ) | ||
67 | { | ||
68 | /*-- | ||
69 | Nodes and heap entries run from 1. Entry 0 | ||
70 | for both the heap and nodes is a sentinel. | ||
71 | --*/ | ||
72 | Int32 nNodes, nHeap, n1, n2, i, j, k; | ||
73 | Bool tooLong; | ||
74 | |||
75 | Int32 heap [ BZ_MAX_ALPHA_SIZE + 2 ]; | ||
76 | Int32 weight [ BZ_MAX_ALPHA_SIZE * 2 ]; | ||
77 | Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ]; | ||
78 | |||
79 | for (i = 0; i < alphaSize; i++) | ||
80 | weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8; | ||
81 | |||
82 | while (True) { | ||
83 | |||
84 | nNodes = alphaSize; | ||
85 | nHeap = 0; | ||
86 | |||
87 | heap[0] = 0; | ||
88 | weight[0] = 0; | ||
89 | parent[0] = -2; | ||
90 | |||
91 | for (i = 1; i <= alphaSize; i++) { | ||
92 | parent[i] = -1; | ||
93 | nHeap++; | ||
94 | heap[nHeap] = i; | ||
95 | UPHEAP(nHeap); | ||
96 | } | ||
97 | |||
98 | AssertH( nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001 ); | ||
99 | |||
100 | while (nHeap > 1) { | ||
101 | n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1); | ||
102 | n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1); | ||
103 | nNodes++; | ||
104 | parent[n1] = parent[n2] = nNodes; | ||
105 | weight[nNodes] = ADDWEIGHTS(weight[n1], weight[n2]); | ||
106 | parent[nNodes] = -1; | ||
107 | nHeap++; | ||
108 | heap[nHeap] = nNodes; | ||
109 | UPHEAP(nHeap); | ||
110 | } | ||
111 | |||
112 | AssertH( nNodes < (BZ_MAX_ALPHA_SIZE * 2), 2002 ); | ||
113 | |||
114 | tooLong = False; | ||
115 | for (i = 1; i <= alphaSize; i++) { | ||
116 | j = 0; | ||
117 | k = i; | ||
118 | while (parent[k] >= 0) { k = parent[k]; j++; } | ||
119 | len[i-1] = j; | ||
120 | if (j > maxLen) tooLong = True; | ||
121 | } | ||
122 | |||
123 | if (! tooLong) break; | ||
124 | |||
125 | /* 17 Oct 04: keep-going condition for the following loop used | ||
126 | to be 'i < alphaSize', which missed the last element, | ||
127 | theoretically leading to the possibility of the compressor | ||
128 | looping. However, this count-scaling step is only needed if | ||
129 | one of the generated Huffman code words is longer than | ||
130 | maxLen, which up to and including version 1.0.2 was 20 bits, | ||
131 | which is extremely unlikely. In version 1.0.3 maxLen was | ||
132 | changed to 17 bits, which has minimal effect on compression | ||
133 | ratio, but does mean this scaling step is used from time to | ||
134 | time, enough to verify that it works. | ||
135 | |||
136 | This means that bzip2-1.0.3 and later will only produce | ||
137 | Huffman codes with a maximum length of 17 bits. However, in | ||
138 | order to preserve backwards compatibility with bitstreams | ||
139 | produced by versions pre-1.0.3, the decompressor must still | ||
140 | handle lengths of up to 20. */ | ||
141 | |||
142 | for (i = 1; i <= alphaSize; i++) { | ||
143 | j = weight[i] >> 8; | ||
144 | j = 1 + (j / 2); | ||
145 | weight[i] = j << 8; | ||
146 | } | ||
147 | } | ||
148 | } | ||
149 | |||
150 | |||
151 | /*---------------------------------------------------*/ | ||
152 | void BZ2_hbAssignCodes ( Int32 *code, | ||
153 | UChar *length, | ||
154 | Int32 minLen, | ||
155 | Int32 maxLen, | ||
156 | Int32 alphaSize ) | ||
157 | { | ||
158 | Int32 n, vec, i; | ||
159 | |||
160 | vec = 0; | ||
161 | for (n = minLen; n <= maxLen; n++) { | ||
162 | for (i = 0; i < alphaSize; i++) | ||
163 | if (length[i] == n) { code[i] = vec; vec++; }; | ||
164 | vec <<= 1; | ||
165 | } | ||
166 | } | ||
167 | |||
168 | |||
169 | /*---------------------------------------------------*/ | ||
170 | void BZ2_hbCreateDecodeTables ( Int32 *limit, | ||
171 | Int32 *base, | ||
172 | Int32 *perm, | ||
173 | UChar *length, | ||
174 | Int32 minLen, | ||
175 | Int32 maxLen, | ||
176 | Int32 alphaSize ) | ||
177 | { | ||
178 | Int32 pp, i, j, vec; | ||
179 | |||
180 | pp = 0; | ||
181 | for (i = minLen; i <= maxLen; i++) | ||
182 | for (j = 0; j < alphaSize; j++) | ||
183 | if (length[j] == i) { perm[pp] = j; pp++; }; | ||
184 | |||
185 | for (i = 0; i < BZ_MAX_CODE_LEN; i++) base[i] = 0; | ||
186 | for (i = 0; i < alphaSize; i++) base[length[i]+1]++; | ||
187 | |||
188 | for (i = 1; i < BZ_MAX_CODE_LEN; i++) base[i] += base[i-1]; | ||
189 | |||
190 | for (i = 0; i < BZ_MAX_CODE_LEN; i++) limit[i] = 0; | ||
191 | vec = 0; | ||
192 | |||
193 | for (i = minLen; i <= maxLen; i++) { | ||
194 | vec += (base[i+1] - base[i]); | ||
195 | limit[i] = vec-1; | ||
196 | vec <<= 1; | ||
197 | } | ||
198 | for (i = minLen + 1; i <= maxLen; i++) | ||
199 | base[i] = ((limit[i-1] + 1) << 1) - base[i]; | ||
200 | } | ||
201 | |||
202 | |||
203 | /*-------------------------------------------------------------*/ | ||
204 | /*--- end huffman.c ---*/ | ||
205 | /*-------------------------------------------------------------*/ | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/libbz2.def b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/libbz2.def new file mode 100644 index 0000000..2dc0dd8 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/libbz2.def | |||
@@ -0,0 +1,27 @@ | |||
1 | LIBRARY LIBBZ2 | ||
2 | DESCRIPTION "libbzip2: library for data compression" | ||
3 | EXPORTS | ||
4 | BZ2_bzCompressInit | ||
5 | BZ2_bzCompress | ||
6 | BZ2_bzCompressEnd | ||
7 | BZ2_bzDecompressInit | ||
8 | BZ2_bzDecompress | ||
9 | BZ2_bzDecompressEnd | ||
10 | BZ2_bzReadOpen | ||
11 | BZ2_bzReadClose | ||
12 | BZ2_bzReadGetUnused | ||
13 | BZ2_bzRead | ||
14 | BZ2_bzWriteOpen | ||
15 | BZ2_bzWrite | ||
16 | BZ2_bzWriteClose | ||
17 | BZ2_bzWriteClose64 | ||
18 | BZ2_bzBuffToBuffCompress | ||
19 | BZ2_bzBuffToBuffDecompress | ||
20 | BZ2_bzlibVersion | ||
21 | BZ2_bzopen | ||
22 | BZ2_bzdopen | ||
23 | BZ2_bzread | ||
24 | BZ2_bzwrite | ||
25 | BZ2_bzflush | ||
26 | BZ2_bzclose | ||
27 | BZ2_bzerror | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/libbz2.dsp b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/libbz2.dsp new file mode 100644 index 0000000..a21a20f --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/libbz2.dsp | |||
@@ -0,0 +1,130 @@ | |||
1 | # Microsoft Developer Studio Project File - Name="libbz2" - Package Owner=<4> | ||
2 | # Microsoft Developer Studio Generated Build File, Format Version 5.00 | ||
3 | # ** •ÒW‚µ‚È‚¢‚Å‚‚¾‚³‚¢ ** | ||
4 | |||
5 | # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 | ||
6 | |||
7 | CFG=libbz2 - Win32 Debug | ||
8 | !MESSAGE ‚±‚ê‚Í—LŒø‚ÈÒ²¸Ì§²Ù‚Å‚Í‚ ‚è‚Ü‚¹‚ñB ‚±‚ÌÌßÛ¼Þª¸Ä‚ðËÞÙÄÞ‚·‚邽‚ß‚É‚Í NMAKE ‚ðŽg—p‚µ‚Ä‚‚¾‚³‚¢B | ||
9 | !MESSAGE [Ò²¸Ì§²Ù‚Ì´¸½Îß°Ä] ºÏÝÄÞ‚ðŽg—p‚µ‚ÄŽÀs‚µ‚Ä‚‚¾‚³‚¢ | ||
10 | !MESSAGE | ||
11 | !MESSAGE NMAKE /f "libbz2.mak". | ||
12 | !MESSAGE | ||
13 | !MESSAGE NMAKE ‚ÌŽÀsŽž‚É\¬‚ðŽw’è‚Å‚«‚Ü‚· | ||
14 | !MESSAGE ºÏÝÄÞ ×²Ýã‚ÅϸۂÌÝ’è‚ð’è‹`‚µ‚Ü‚·B—á: | ||
15 | !MESSAGE | ||
16 | !MESSAGE NMAKE /f "libbz2.mak" CFG="libbz2 - Win32 Debug" | ||
17 | !MESSAGE | ||
18 | !MESSAGE ‘I‘ð‰Â”\‚ÈËÞÙÄÞ Ó°ÄÞ: | ||
19 | !MESSAGE | ||
20 | !MESSAGE "libbz2 - Win32 Release" ("Win32 (x86) Dynamic-Link Library" —p) | ||
21 | !MESSAGE "libbz2 - Win32 Debug" ("Win32 (x86) Dynamic-Link Library" —p) | ||
22 | !MESSAGE | ||
23 | |||
24 | # Begin Project | ||
25 | # PROP Scc_ProjName "" | ||
26 | # PROP Scc_LocalPath "" | ||
27 | CPP=cl.exe | ||
28 | MTL=midl.exe | ||
29 | RSC=rc.exe | ||
30 | |||
31 | !IF "$(CFG)" == "libbz2 - Win32 Release" | ||
32 | |||
33 | # PROP BASE Use_MFC 0 | ||
34 | # PROP BASE Use_Debug_Libraries 0 | ||
35 | # PROP BASE Output_Dir "Release" | ||
36 | # PROP BASE Intermediate_Dir "Release" | ||
37 | # PROP BASE Target_Dir "" | ||
38 | # PROP Use_MFC 0 | ||
39 | # PROP Use_Debug_Libraries 0 | ||
40 | # PROP Output_Dir "Release" | ||
41 | # PROP Intermediate_Dir "Release" | ||
42 | # PROP Ignore_Export_Lib 0 | ||
43 | # PROP Target_Dir "" | ||
44 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c | ||
45 | # ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c | ||
46 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 | ||
47 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 | ||
48 | # ADD BASE RSC /l 0x411 /d "NDEBUG" | ||
49 | # ADD RSC /l 0x411 /d "NDEBUG" | ||
50 | BSC32=bscmake.exe | ||
51 | # ADD BASE BSC32 /nologo | ||
52 | # ADD BSC32 /nologo | ||
53 | LINK32=link.exe | ||
54 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 | ||
55 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /out:"libbz2.dll" | ||
56 | |||
57 | !ELSEIF "$(CFG)" == "libbz2 - Win32 Debug" | ||
58 | |||
59 | # PROP BASE Use_MFC 0 | ||
60 | # PROP BASE Use_Debug_Libraries 1 | ||
61 | # PROP BASE Output_Dir "Debug" | ||
62 | # PROP BASE Intermediate_Dir "Debug" | ||
63 | # PROP BASE Target_Dir "" | ||
64 | # PROP Use_MFC 0 | ||
65 | # PROP Use_Debug_Libraries 1 | ||
66 | # PROP Output_Dir "Debug" | ||
67 | # PROP Intermediate_Dir "Debug" | ||
68 | # PROP Ignore_Export_Lib 0 | ||
69 | # PROP Target_Dir "" | ||
70 | # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c | ||
71 | # ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c | ||
72 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 | ||
73 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 | ||
74 | # ADD BASE RSC /l 0x411 /d "_DEBUG" | ||
75 | # ADD RSC /l 0x411 /d "_DEBUG" | ||
76 | BSC32=bscmake.exe | ||
77 | # ADD BASE BSC32 /nologo | ||
78 | # ADD BSC32 /nologo | ||
79 | LINK32=link.exe | ||
80 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept | ||
81 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"libbz2.dll" /pdbtype:sept | ||
82 | |||
83 | !ENDIF | ||
84 | |||
85 | # Begin Target | ||
86 | |||
87 | # Name "libbz2 - Win32 Release" | ||
88 | # Name "libbz2 - Win32 Debug" | ||
89 | # Begin Source File | ||
90 | |||
91 | SOURCE=.\blocksort.c | ||
92 | # End Source File | ||
93 | # Begin Source File | ||
94 | |||
95 | SOURCE=.\bzlib.c | ||
96 | # End Source File | ||
97 | # Begin Source File | ||
98 | |||
99 | SOURCE=.\bzlib.h | ||
100 | # End Source File | ||
101 | # Begin Source File | ||
102 | |||
103 | SOURCE=.\bzlib_private.h | ||
104 | # End Source File | ||
105 | # Begin Source File | ||
106 | |||
107 | SOURCE=.\compress.c | ||
108 | # End Source File | ||
109 | # Begin Source File | ||
110 | |||
111 | SOURCE=.\crctable.c | ||
112 | # End Source File | ||
113 | # Begin Source File | ||
114 | |||
115 | SOURCE=.\decompress.c | ||
116 | # End Source File | ||
117 | # Begin Source File | ||
118 | |||
119 | SOURCE=.\huffman.c | ||
120 | # End Source File | ||
121 | # Begin Source File | ||
122 | |||
123 | SOURCE=.\libbz2.def | ||
124 | # End Source File | ||
125 | # Begin Source File | ||
126 | |||
127 | SOURCE=.\randtable.c | ||
128 | # End Source File | ||
129 | # End Target | ||
130 | # End Project | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/makefile.msc b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/makefile.msc new file mode 100644 index 0000000..799a18a --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/makefile.msc | |||
@@ -0,0 +1,63 @@ | |||
1 | # Makefile for Microsoft Visual C++ 6.0 | ||
2 | # usage: nmake -f makefile.msc | ||
3 | # K.M. Syring (syring@gsf.de) | ||
4 | # Fixed up by JRS for bzip2-0.9.5d release. | ||
5 | |||
6 | CC=cl | ||
7 | CFLAGS= -DWIN32 -MD -Ox -D_FILE_OFFSET_BITS=64 -nologo | ||
8 | |||
9 | OBJS= blocksort.obj \ | ||
10 | huffman.obj \ | ||
11 | crctable.obj \ | ||
12 | randtable.obj \ | ||
13 | compress.obj \ | ||
14 | decompress.obj \ | ||
15 | bzlib.obj | ||
16 | |||
17 | all: lib bzip2 test | ||
18 | |||
19 | bzip2: lib | ||
20 | $(CC) $(CFLAGS) -o bzip2 bzip2.c libbz2.lib setargv.obj | ||
21 | $(CC) $(CFLAGS) -o bzip2recover bzip2recover.c | ||
22 | |||
23 | lib: $(OBJS) | ||
24 | lib /out:libbz2.lib $(OBJS) | ||
25 | |||
26 | test: bzip2 | ||
27 | type words1 | ||
28 | .\\bzip2 -1 < sample1.ref > sample1.rb2 | ||
29 | .\\bzip2 -2 < sample2.ref > sample2.rb2 | ||
30 | .\\bzip2 -3 < sample3.ref > sample3.rb2 | ||
31 | .\\bzip2 -d < sample1.bz2 > sample1.tst | ||
32 | .\\bzip2 -d < sample2.bz2 > sample2.tst | ||
33 | .\\bzip2 -ds < sample3.bz2 > sample3.tst | ||
34 | @echo All six of the fc's should find no differences. | ||
35 | @echo If fc finds an error on sample3.bz2, this could be | ||
36 | @echo because WinZip's 'TAR file smart CR/LF conversion' | ||
37 | @echo is too clever for its own good. Disable this option. | ||
38 | @echo The correct size for sample3.ref is 120,244. If it | ||
39 | @echo is 150,251, WinZip has messed it up. | ||
40 | fc sample1.bz2 sample1.rb2 | ||
41 | fc sample2.bz2 sample2.rb2 | ||
42 | fc sample3.bz2 sample3.rb2 | ||
43 | fc sample1.tst sample1.ref | ||
44 | fc sample2.tst sample2.ref | ||
45 | fc sample3.tst sample3.ref | ||
46 | |||
47 | |||
48 | |||
49 | clean: | ||
50 | del *.obj | ||
51 | del libbz2.lib | ||
52 | del bzip2.exe | ||
53 | del bzip2recover.exe | ||
54 | del sample1.rb2 | ||
55 | del sample2.rb2 | ||
56 | del sample3.rb2 | ||
57 | del sample1.tst | ||
58 | del sample2.tst | ||
59 | del sample3.tst | ||
60 | |||
61 | .c.obj: | ||
62 | $(CC) $(CFLAGS) -c $*.c -o $*.obj | ||
63 | |||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/mk251.c b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/mk251.c new file mode 100644 index 0000000..c9c36f6 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/mk251.c | |||
@@ -0,0 +1,31 @@ | |||
1 | |||
2 | /* Spew out a long sequence of the byte 251. When fed to bzip2 | ||
3 | versions 1.0.0 or 1.0.1, causes it to die with internal error | ||
4 | 1007 in blocksort.c. This assertion misses an extremely rare | ||
5 | case, which is fixed in this version (1.0.2) and above. | ||
6 | */ | ||
7 | |||
8 | /* ------------------------------------------------------------------ | ||
9 | This file is part of bzip2/libbzip2, a program and library for | ||
10 | lossless, block-sorting data compression. | ||
11 | |||
12 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | ||
13 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | ||
14 | |||
15 | Please read the WARNING, DISCLAIMER and PATENTS sections in the | ||
16 | README file. | ||
17 | |||
18 | This program is released under the terms of the license contained | ||
19 | in the file LICENSE. | ||
20 | ------------------------------------------------------------------ */ | ||
21 | |||
22 | |||
23 | #include <stdio.h> | ||
24 | |||
25 | int main () | ||
26 | { | ||
27 | int i; | ||
28 | for (i = 0; i < 48500000 ; i++) | ||
29 | putchar(251); | ||
30 | return 0; | ||
31 | } | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/randtable.c b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/randtable.c new file mode 100644 index 0000000..6d62459 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/randtable.c | |||
@@ -0,0 +1,84 @@ | |||
1 | |||
2 | /*-------------------------------------------------------------*/ | ||
3 | /*--- Table for randomising repetitive blocks ---*/ | ||
4 | /*--- randtable.c ---*/ | ||
5 | /*-------------------------------------------------------------*/ | ||
6 | |||
7 | /* ------------------------------------------------------------------ | ||
8 | This file is part of bzip2/libbzip2, a program and library for | ||
9 | lossless, block-sorting data compression. | ||
10 | |||
11 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | ||
12 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | ||
13 | |||
14 | Please read the WARNING, DISCLAIMER and PATENTS sections in the | ||
15 | README file. | ||
16 | |||
17 | This program is released under the terms of the license contained | ||
18 | in the file LICENSE. | ||
19 | ------------------------------------------------------------------ */ | ||
20 | |||
21 | |||
22 | #include "bzlib_private.h" | ||
23 | |||
24 | |||
25 | /*---------------------------------------------*/ | ||
26 | Int32 BZ2_rNums[512] = { | ||
27 | 619, 720, 127, 481, 931, 816, 813, 233, 566, 247, | ||
28 | 985, 724, 205, 454, 863, 491, 741, 242, 949, 214, | ||
29 | 733, 859, 335, 708, 621, 574, 73, 654, 730, 472, | ||
30 | 419, 436, 278, 496, 867, 210, 399, 680, 480, 51, | ||
31 | 878, 465, 811, 169, 869, 675, 611, 697, 867, 561, | ||
32 | 862, 687, 507, 283, 482, 129, 807, 591, 733, 623, | ||
33 | 150, 238, 59, 379, 684, 877, 625, 169, 643, 105, | ||
34 | 170, 607, 520, 932, 727, 476, 693, 425, 174, 647, | ||
35 | 73, 122, 335, 530, 442, 853, 695, 249, 445, 515, | ||
36 | 909, 545, 703, 919, 874, 474, 882, 500, 594, 612, | ||
37 | 641, 801, 220, 162, 819, 984, 589, 513, 495, 799, | ||
38 | 161, 604, 958, 533, 221, 400, 386, 867, 600, 782, | ||
39 | 382, 596, 414, 171, 516, 375, 682, 485, 911, 276, | ||
40 | 98, 553, 163, 354, 666, 933, 424, 341, 533, 870, | ||
41 | 227, 730, 475, 186, 263, 647, 537, 686, 600, 224, | ||
42 | 469, 68, 770, 919, 190, 373, 294, 822, 808, 206, | ||
43 | 184, 943, 795, 384, 383, 461, 404, 758, 839, 887, | ||
44 | 715, 67, 618, 276, 204, 918, 873, 777, 604, 560, | ||
45 | 951, 160, 578, 722, 79, 804, 96, 409, 713, 940, | ||
46 | 652, 934, 970, 447, 318, 353, 859, 672, 112, 785, | ||
47 | 645, 863, 803, 350, 139, 93, 354, 99, 820, 908, | ||
48 | 609, 772, 154, 274, 580, 184, 79, 626, 630, 742, | ||
49 | 653, 282, 762, 623, 680, 81, 927, 626, 789, 125, | ||
50 | 411, 521, 938, 300, 821, 78, 343, 175, 128, 250, | ||
51 | 170, 774, 972, 275, 999, 639, 495, 78, 352, 126, | ||
52 | 857, 956, 358, 619, 580, 124, 737, 594, 701, 612, | ||
53 | 669, 112, 134, 694, 363, 992, 809, 743, 168, 974, | ||
54 | 944, 375, 748, 52, 600, 747, 642, 182, 862, 81, | ||
55 | 344, 805, 988, 739, 511, 655, 814, 334, 249, 515, | ||
56 | 897, 955, 664, 981, 649, 113, 974, 459, 893, 228, | ||
57 | 433, 837, 553, 268, 926, 240, 102, 654, 459, 51, | ||
58 | 686, 754, 806, 760, 493, 403, 415, 394, 687, 700, | ||
59 | 946, 670, 656, 610, 738, 392, 760, 799, 887, 653, | ||
60 | 978, 321, 576, 617, 626, 502, 894, 679, 243, 440, | ||
61 | 680, 879, 194, 572, 640, 724, 926, 56, 204, 700, | ||
62 | 707, 151, 457, 449, 797, 195, 791, 558, 945, 679, | ||
63 | 297, 59, 87, 824, 713, 663, 412, 693, 342, 606, | ||
64 | 134, 108, 571, 364, 631, 212, 174, 643, 304, 329, | ||
65 | 343, 97, 430, 751, 497, 314, 983, 374, 822, 928, | ||
66 | 140, 206, 73, 263, 980, 736, 876, 478, 430, 305, | ||
67 | 170, 514, 364, 692, 829, 82, 855, 953, 676, 246, | ||
68 | 369, 970, 294, 750, 807, 827, 150, 790, 288, 923, | ||
69 | 804, 378, 215, 828, 592, 281, 565, 555, 710, 82, | ||
70 | 896, 831, 547, 261, 524, 462, 293, 465, 502, 56, | ||
71 | 661, 821, 976, 991, 658, 869, 905, 758, 745, 193, | ||
72 | 768, 550, 608, 933, 378, 286, 215, 979, 792, 961, | ||
73 | 61, 688, 793, 644, 986, 403, 106, 366, 905, 644, | ||
74 | 372, 567, 466, 434, 645, 210, 389, 550, 919, 135, | ||
75 | 780, 773, 635, 389, 707, 100, 626, 958, 165, 504, | ||
76 | 920, 176, 193, 713, 857, 265, 203, 50, 668, 108, | ||
77 | 645, 990, 626, 197, 510, 357, 358, 850, 858, 364, | ||
78 | 936, 638 | ||
79 | }; | ||
80 | |||
81 | |||
82 | /*-------------------------------------------------------------*/ | ||
83 | /*--- end randtable.c ---*/ | ||
84 | /*-------------------------------------------------------------*/ | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/spewG.c b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/spewG.c new file mode 100644 index 0000000..14a3649 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/spewG.c | |||
@@ -0,0 +1,54 @@ | |||
1 | |||
2 | /* spew out a thoroughly gigantic file designed so that bzip2 | ||
3 | can compress it reasonably rapidly. This is to help test | ||
4 | support for large files (> 2GB) in a reasonable amount of time. | ||
5 | I suggest you use the undocumented --exponential option to | ||
6 | bzip2 when compressing the resulting file; this saves a bit of | ||
7 | time. Note: *don't* bother with --exponential when compressing | ||
8 | Real Files; it'll just waste a lot of CPU time :-) | ||
9 | (but is otherwise harmless). | ||
10 | */ | ||
11 | |||
12 | /* ------------------------------------------------------------------ | ||
13 | This file is part of bzip2/libbzip2, a program and library for | ||
14 | lossless, block-sorting data compression. | ||
15 | |||
16 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | ||
17 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | ||
18 | |||
19 | Please read the WARNING, DISCLAIMER and PATENTS sections in the | ||
20 | README file. | ||
21 | |||
22 | This program is released under the terms of the license contained | ||
23 | in the file LICENSE. | ||
24 | ------------------------------------------------------------------ */ | ||
25 | |||
26 | |||
27 | #define _FILE_OFFSET_BITS 64 | ||
28 | |||
29 | #include <stdio.h> | ||
30 | #include <stdlib.h> | ||
31 | |||
32 | /* The number of megabytes of junk to spew out (roughly) */ | ||
33 | #define MEGABYTES 5000 | ||
34 | |||
35 | #define N_BUF 1000000 | ||
36 | char buf[N_BUF]; | ||
37 | |||
38 | int main ( int argc, char** argv ) | ||
39 | { | ||
40 | int ii, kk, p; | ||
41 | srandom(1); | ||
42 | setbuffer ( stdout, buf, N_BUF ); | ||
43 | for (kk = 0; kk < MEGABYTES * 515; kk+=3) { | ||
44 | p = 25+random()%50; | ||
45 | for (ii = 0; ii < p; ii++) | ||
46 | printf ( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ); | ||
47 | for (ii = 0; ii < p-1; ii++) | ||
48 | printf ( "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" ); | ||
49 | for (ii = 0; ii < p+1; ii++) | ||
50 | printf ( "ccccccccccccccccccccccccccccccccccccc" ); | ||
51 | } | ||
52 | fflush(stdout); | ||
53 | return 0; | ||
54 | } | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/unzcrash.c b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/unzcrash.c new file mode 100644 index 0000000..7041da5 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/unzcrash.c | |||
@@ -0,0 +1,141 @@ | |||
1 | |||
2 | /* A test program written to test robustness to decompression of | ||
3 | corrupted data. Usage is | ||
4 | unzcrash filename | ||
5 | and the program will read the specified file, compress it (in memory), | ||
6 | and then repeatedly decompress it, each time with a different bit of | ||
7 | the compressed data inverted, so as to test all possible one-bit errors. | ||
8 | This should not cause any invalid memory accesses. If it does, | ||
9 | I want to know about it! | ||
10 | |||
11 | PS. As you can see from the above description, the process is | ||
12 | incredibly slow. A file of size eg 5KB will cause it to run for | ||
13 | many hours. | ||
14 | */ | ||
15 | |||
16 | /* ------------------------------------------------------------------ | ||
17 | This file is part of bzip2/libbzip2, a program and library for | ||
18 | lossless, block-sorting data compression. | ||
19 | |||
20 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | ||
21 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | ||
22 | |||
23 | Please read the WARNING, DISCLAIMER and PATENTS sections in the | ||
24 | README file. | ||
25 | |||
26 | This program is released under the terms of the license contained | ||
27 | in the file LICENSE. | ||
28 | ------------------------------------------------------------------ */ | ||
29 | |||
30 | |||
31 | #include <stdio.h> | ||
32 | #include <assert.h> | ||
33 | #include "bzlib.h" | ||
34 | |||
35 | #define M_BLOCK 1000000 | ||
36 | |||
37 | typedef unsigned char uchar; | ||
38 | |||
39 | #define M_BLOCK_OUT (M_BLOCK + 1000000) | ||
40 | uchar inbuf[M_BLOCK]; | ||
41 | uchar outbuf[M_BLOCK_OUT]; | ||
42 | uchar zbuf[M_BLOCK + 600 + (M_BLOCK / 100)]; | ||
43 | |||
44 | int nIn, nOut, nZ; | ||
45 | |||
46 | static char *bzerrorstrings[] = { | ||
47 | "OK" | ||
48 | ,"SEQUENCE_ERROR" | ||
49 | ,"PARAM_ERROR" | ||
50 | ,"MEM_ERROR" | ||
51 | ,"DATA_ERROR" | ||
52 | ,"DATA_ERROR_MAGIC" | ||
53 | ,"IO_ERROR" | ||
54 | ,"UNEXPECTED_EOF" | ||
55 | ,"OUTBUFF_FULL" | ||
56 | ,"???" /* for future */ | ||
57 | ,"???" /* for future */ | ||
58 | ,"???" /* for future */ | ||
59 | ,"???" /* for future */ | ||
60 | ,"???" /* for future */ | ||
61 | ,"???" /* for future */ | ||
62 | }; | ||
63 | |||
64 | void flip_bit ( int bit ) | ||
65 | { | ||
66 | int byteno = bit / 8; | ||
67 | int bitno = bit % 8; | ||
68 | uchar mask = 1 << bitno; | ||
69 | //fprintf ( stderr, "(byte %d bit %d mask %d)", | ||
70 | // byteno, bitno, (int)mask ); | ||
71 | zbuf[byteno] ^= mask; | ||
72 | } | ||
73 | |||
74 | int main ( int argc, char** argv ) | ||
75 | { | ||
76 | FILE* f; | ||
77 | int r; | ||
78 | int bit; | ||
79 | int i; | ||
80 | |||
81 | if (argc != 2) { | ||
82 | fprintf ( stderr, "usage: unzcrash filename\n" ); | ||
83 | return 1; | ||
84 | } | ||
85 | |||
86 | f = fopen ( argv[1], "r" ); | ||
87 | if (!f) { | ||
88 | fprintf ( stderr, "unzcrash: can't open %s\n", argv[1] ); | ||
89 | return 1; | ||
90 | } | ||
91 | |||
92 | nIn = fread ( inbuf, 1, M_BLOCK, f ); | ||
93 | fprintf ( stderr, "%d bytes read\n", nIn ); | ||
94 | |||
95 | nZ = M_BLOCK; | ||
96 | r = BZ2_bzBuffToBuffCompress ( | ||
97 | zbuf, &nZ, inbuf, nIn, 9, 0, 30 ); | ||
98 | |||
99 | assert (r == BZ_OK); | ||
100 | fprintf ( stderr, "%d after compression\n", nZ ); | ||
101 | |||
102 | for (bit = 0; bit < nZ*8; bit++) { | ||
103 | fprintf ( stderr, "bit %d ", bit ); | ||
104 | flip_bit ( bit ); | ||
105 | nOut = M_BLOCK_OUT; | ||
106 | r = BZ2_bzBuffToBuffDecompress ( | ||
107 | outbuf, &nOut, zbuf, nZ, 0, 0 ); | ||
108 | fprintf ( stderr, " %d %s ", r, bzerrorstrings[-r] ); | ||
109 | |||
110 | if (r != BZ_OK) { | ||
111 | fprintf ( stderr, "\n" ); | ||
112 | } else { | ||
113 | if (nOut != nIn) { | ||
114 | fprintf(stderr, "nIn/nOut mismatch %d %d\n", nIn, nOut ); | ||
115 | return 1; | ||
116 | } else { | ||
117 | for (i = 0; i < nOut; i++) | ||
118 | if (inbuf[i] != outbuf[i]) { | ||
119 | fprintf(stderr, "mismatch at %d\n", i ); | ||
120 | return 1; | ||
121 | } | ||
122 | if (i == nOut) fprintf(stderr, "really ok!\n" ); | ||
123 | } | ||
124 | } | ||
125 | |||
126 | flip_bit ( bit ); | ||
127 | } | ||
128 | |||
129 | #if 0 | ||
130 | assert (nOut == nIn); | ||
131 | for (i = 0; i < nOut; i++) { | ||
132 | if (inbuf[i] != outbuf[i]) { | ||
133 | fprintf ( stderr, "difference at %d !\n", i ); | ||
134 | return 1; | ||
135 | } | ||
136 | } | ||
137 | #endif | ||
138 | |||
139 | fprintf ( stderr, "all ok\n" ); | ||
140 | return 0; | ||
141 | } | ||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/words0 b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/words0 new file mode 100644 index 0000000..fbf442a --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/words0 | |||
@@ -0,0 +1,9 @@ | |||
1 | |||
2 | If compilation produces errors, or a large number of warnings, | ||
3 | please read README.COMPILATION.PROBLEMS -- you might be able to | ||
4 | adjust the flags in this Makefile to improve matters. | ||
5 | |||
6 | Also in README.COMPILATION.PROBLEMS are some hints that may help | ||
7 | if your build produces an executable which is unable to correctly | ||
8 | handle so-called 'large files' -- files of size 2GB or more. | ||
9 | |||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/words1 b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/words1 new file mode 100644 index 0000000..2e83de9 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/words1 | |||
@@ -0,0 +1,4 @@ | |||
1 | |||
2 | Doing 6 tests (3 compress, 3 uncompress) ... | ||
3 | If there's a problem, things might stop at this point. | ||
4 | |||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/words2 b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/words2 new file mode 100644 index 0000000..caddcf4 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/words2 | |||
@@ -0,0 +1,5 @@ | |||
1 | |||
2 | Checking test results. If any of the four "cmp"s which follow | ||
3 | report any differences, something is wrong. If you can't easily | ||
4 | figure out what, please let me know (jseward@bzip.org). | ||
5 | |||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/words3 b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/words3 new file mode 100644 index 0000000..6972669 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/words3 | |||
@@ -0,0 +1,30 @@ | |||
1 | |||
2 | If you got this far and the 'cmp's didn't complain, it looks | ||
3 | like you're in business. | ||
4 | |||
5 | To install in /usr/local/bin, /usr/local/lib, /usr/local/man and | ||
6 | /usr/local/include, type | ||
7 | |||
8 | make install | ||
9 | |||
10 | To install somewhere else, eg, /xxx/yyy/{bin,lib,man,include}, type | ||
11 | |||
12 | make install PREFIX=/xxx/yyy | ||
13 | |||
14 | If you are (justifiably) paranoid and want to see what 'make install' | ||
15 | is going to do, you can first do | ||
16 | |||
17 | make -n install or | ||
18 | make -n install PREFIX=/xxx/yyy respectively. | ||
19 | |||
20 | The -n instructs make to show the commands it would execute, but | ||
21 | not actually execute them. | ||
22 | |||
23 | Instructions for use are in the preformatted manual page, in the file | ||
24 | bzip2.txt. For more detailed documentation, read the full manual. | ||
25 | It is available in Postscript form (manual.ps), PDF form (manual.pdf), | ||
26 | and HTML form (manual.html). | ||
27 | |||
28 | You can also do "bzip2 --help" to see some helpful information. | ||
29 | "bzip2 -L" displays the software license. | ||
30 | |||
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/xmlproc.sh b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/xmlproc.sh new file mode 100755 index 0000000..ca284ea --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/bzip2/xmlproc.sh | |||
@@ -0,0 +1,114 @@ | |||
1 | #!/bin/bash | ||
2 | # see the README file for usage etc. | ||
3 | # | ||
4 | # ------------------------------------------------------------------ | ||
5 | # This file is part of bzip2/libbzip2, a program and library for | ||
6 | # lossless, block-sorting data compression. | ||
7 | # | ||
8 | # bzip2/libbzip2 version 1.0.6 of 6 September 2010 | ||
9 | # Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | ||
10 | # | ||
11 | # Please read the WARNING, DISCLAIMER and PATENTS sections in the | ||
12 | # README file. | ||
13 | # | ||
14 | # This program is released under the terms of the license contained | ||
15 | # in the file LICENSE. | ||
16 | # ---------------------------------------------------------------- | ||
17 | |||
18 | |||
19 | usage() { | ||
20 | echo ''; | ||
21 | echo 'Usage: xmlproc.sh -[option] <filename.xml>'; | ||
22 | echo 'Specify a target from:'; | ||
23 | echo '-v verify xml file conforms to dtd'; | ||
24 | echo '-html output in html format (single file)'; | ||
25 | echo '-ps output in postscript format'; | ||
26 | echo '-pdf output in pdf format'; | ||
27 | exit; | ||
28 | } | ||
29 | |||
30 | if test $# -ne 2; then | ||
31 | usage | ||
32 | fi | ||
33 | # assign the variable for the output type | ||
34 | action=$1; shift | ||
35 | # assign the output filename | ||
36 | xmlfile=$1; shift | ||
37 | # and check user input it correct | ||
38 | if !(test -f $xmlfile); then | ||
39 | echo "No such file: $xmlfile"; | ||
40 | exit; | ||
41 | fi | ||
42 | # some other stuff we will use | ||
43 | OUT=output | ||
44 | xsl_fo=bz-fo.xsl | ||
45 | xsl_html=bz-html.xsl | ||
46 | |||
47 | basename=$xmlfile | ||
48 | basename=${basename//'.xml'/''} | ||
49 | |||
50 | fofile="${basename}.fo" | ||
51 | htmlfile="${basename}.html" | ||
52 | pdffile="${basename}.pdf" | ||
53 | psfile="${basename}.ps" | ||
54 | xmlfmtfile="${basename}.fmt" | ||
55 | |||
56 | # first process the xmlfile with CDATA tags | ||
57 | ./format.pl $xmlfile $xmlfmtfile | ||
58 | # so the shell knows where the catalogs live | ||
59 | export XML_CATALOG_FILES=/etc/xml/catalog | ||
60 | |||
61 | # post-processing tidy up | ||
62 | cleanup() { | ||
63 | echo "Cleaning up: $@" | ||
64 | while [ $# != 0 ] | ||
65 | do | ||
66 | arg=$1; shift; | ||
67 | echo " deleting $arg"; | ||
68 | rm $arg | ||
69 | done | ||
70 | } | ||
71 | |||
72 | case $action in | ||
73 | -v) | ||
74 | flags='--noout --xinclude --noblanks --postvalid' | ||
75 | dtd='--dtdvalid http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd' | ||
76 | xmllint $flags $dtd $xmlfmtfile 2> $OUT | ||
77 | egrep 'error' $OUT | ||
78 | rm $OUT | ||
79 | ;; | ||
80 | |||
81 | -html) | ||
82 | echo "Creating $htmlfile ..." | ||
83 | xsltproc --nonet --xinclude -o $htmlfile $xsl_html $xmlfmtfile | ||
84 | cleanup $xmlfmtfile | ||
85 | ;; | ||
86 | |||
87 | -pdf) | ||
88 | echo "Creating $pdffile ..." | ||
89 | xsltproc --nonet --xinclude -o $fofile $xsl_fo $xmlfmtfile | ||
90 | pdfxmltex $fofile >$OUT </dev/null | ||
91 | pdfxmltex $fofile >$OUT </dev/null | ||
92 | pdfxmltex $fofile >$OUT </dev/null | ||
93 | cleanup $OUT $xmlfmtfile *.aux *.fo *.log *.out | ||
94 | ;; | ||
95 | |||
96 | -ps) | ||
97 | echo "Creating $psfile ..." | ||
98 | xsltproc --nonet --xinclude -o $fofile $xsl_fo $xmlfmtfile | ||
99 | pdfxmltex $fofile >$OUT </dev/null | ||
100 | pdfxmltex $fofile >$OUT </dev/null | ||
101 | pdfxmltex $fofile >$OUT </dev/null | ||
102 | pdftops $pdffile $psfile | ||
103 | cleanup $OUT $xmlfmtfile $pdffile *.aux *.fo *.log *.out | ||
104 | # passivetex is broken, so we can't go this route yet. | ||
105 | # xmltex $fofile >$OUT </dev/null | ||
106 | # xmltex $fofile >$OUT </dev/null | ||
107 | # xmltex $fofile >$OUT </dev/null | ||
108 | # dvips -R -q -o bzip-manual.ps *.dvi | ||
109 | ;; | ||
110 | |||
111 | *) | ||
112 | usage | ||
113 | ;; | ||
114 | esac | ||