Source file : unzip-decompress-huffman.ads
1 -- UnZip.Decompress.Huffman
2 ----------------------------
3 -- Huffman tree generation and deletion.
4 -- Originally from info-zip's unzip, data structure rewritten by G. de Montmollin
5
6 -- Legal licensing note:
7
8 -- Copyright (c) 1999 .. 2019 Gautier de Montmollin
9 -- SWITZERLAND
10
11 -- Permission is hereby granted, free of charge, to any person obtaining a copy
12 -- of this software and associated documentation files (the "Software"), to deal
13 -- in the Software without restriction, including without limitation the rights
14 -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 -- copies of the Software, and to permit persons to whom the Software is
16 -- furnished to do so, subject to the following conditions:
17
18 -- The above copyright notice and this permission notice shall be included in
19 -- all copies or substantial portions of the Software.
20
21 -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 -- THE SOFTWARE.
28
29 -- NB: this is the MIT License, as found on the site
30 -- http://www.opensource.org/licenses/mit-license.php
31
32 private package UnZip.Decompress.Huffman is
33
34 type HufT_table;
35 type p_HufT_table is access HufT_table;
36
37 type HufT is record
38 extra_bits : Natural;
39 bits : Natural;
40 n : Natural;
41 next_table : p_HufT_table;
42 end record;
43
44 invalid : constant := 99; -- invalid value for extra bits
45
46 type HufT_table is array (Natural range <>) of HufT;
47
48 -- Linked list just for destroying Huffman tables
49
50 type Table_list;
51 type p_Table_list is access Table_list;
52
53 type Table_list is record
54 table : p_HufT_table;
55 next : p_Table_list;
56 end record;
57
58 type Length_array is array (Integer range <>) of Natural;
59
60 empty : constant Length_array (1 .. 0) := (others => 0);
61
62 -- Free huffman tables starting with table where t points to
63 procedure HufT_free (tl : in out p_Table_list);
64
65 -- Build huffman table from code lengths given by array b.all
66 procedure HufT_build (b : Length_array;
67 s : Integer;
68 d, e : Length_array;
69 tl : out p_Table_list;
70 m : in out Integer;
71 huft_incomplete : out Boolean);
72
73 -- Possible exceptions occuring in huft_build
74 huft_error, -- bad tree constructed
75 huft_out_of_memory : exception; -- not enough memory
76
77 end UnZip.Decompress.Huffman;
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.