Source file : bzip2-decoding.ads
1 -- BZip2.Decoding - a standalone, generic BZip2 decoding package.
2 ------------------
3 --
4 -- Legal licensing note:
5 --
6 -- Copyright (c) 2009 .. 2024 Gautier de Montmollin (maintainer of the Ada version)
7 -- SWITZERLAND
8 --
9 -- Permission is hereby granted, free of charge, to any person obtaining a copy
10 -- of this software and associated documentation files (the "Software"), to deal
11 -- in the Software without restriction, including without limitation the rights
12 -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 -- copies of the Software, and to permit persons to whom the Software is
14 -- furnished to do so, subject to the following conditions:
15 --
16 -- The above copyright notice and this permission notice shall be included in
17 -- all copies or substantial portions of the Software.
18 --
19 -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 -- THE SOFTWARE.
26 --
27 -- NB: this is the MIT License, as found 21-Aug-2016 on the site
28 -- http://www.opensource.org/licenses/mit-license.php
29
30 --------------------------------------------------------------
31 -- | This Ada code is a reworked 2009 translation of a Pascal version,
32 -- | bzip2.pas, by Daniel Mantione, of the decompression code of libbzip2
33 -- | by Julian Seward. bzip2.pas is part of the FreePascal sources.
34 --
35 -- Translated on 20-Oct-2009 by (New) P2Ada v. 15-Nov-2006
36 -- Rework by G. de Montmollin
37 --
38 -- Main differences over the FreePascal version:
39 --
40 -- * There is no more pointer arithmetics.
41 -- The only pointer is tt, for dynamically allocating the biggest
42 -- decoding array.
43 --
44 -- * In 2024 the overcomplicated and buggy RLE_1 part was rewritten.
45 --
46 -- With the appropriate options, the performance is very close to
47 -- the bzip2 tool in C: it takes around 7%-11% more time depending on data
48 -- to be decompressed (tested in 2009). Add some 5% when CRC checking is enabled.
49 -- These timings are obtained with bunzip.adb compiled on GNAT 2008, Win32,
50 -- with the -O2 -gnatpn -fpeel-loops -funroll-loops -fweb -frename-registers
51 -- options, average on several runs (see bz_test.cmd).
52
53 generic
54 -- Input:
55 with function Read_Byte return Byte;
56 -- Output:
57 with procedure Write_Byte (b : Byte);
58
59 -- CRC checking is useless if the whole bzip stream is enclosed
60 -- in another CRC-checked stream, like a in Zip archive.
61 check_crc : Boolean;
62
63 package BZip2.Decoding is
64
65 bad_header_magic,
66 bad_block_magic,
67 data_error,
68 block_crc_check_failed,
69 randomized_not_yet_implemented : exception;
70
71 -- Decompress: decompression of bzip2 data streams.
72 procedure Decompress;
73
74 end BZip2.Decoding;
Web view of Ada source code generated by GNATHTML, project: ALI_Parse version 1.0.
Zip-Ada: Ada library for zip archive files (.zip).
Ada programming.
Some news about Zip-Ada and other Ada projects
on Gautier's blog.