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. private package UnZip.Decompress.Huffman is 
  7.  
  8.   type HufT_table; 
  9.   type p_HufT_table is access HufT_table; 
  10.  
  11.   type HufT is record 
  12.     extra_bits  : Natural; 
  13.     bits        : Natural; 
  14.     n           : Natural; 
  15.     next_table  : p_HufT_table; 
  16.   end record; 
  17.  
  18.   invalid : constant := 99; -- invalid value for extra bits 
  19.  
  20.   type HufT_table is array (Integer range <>) of aliased HufT; 
  21.  
  22.   type p_HufT is access all HufT; 
  23.  
  24.   -- Linked list just for destroying Huffman tables 
  25.  
  26.   type Table_list; 
  27.   type p_Table_list is access Table_list; 
  28.  
  29.   type Table_list is record 
  30.     table : p_HufT_table; 
  31.     next  : p_Table_list; 
  32.   end record; 
  33.  
  34.   type Length_array is array (Integer range <>) of Natural; 
  35.  
  36.   empty  : constant Length_array (1 .. 0) := (others => 0); 
  37.  
  38.   -- Free huffman tables starting with table where t points to 
  39.   procedure HufT_free (tl : in out p_Table_list); 
  40.  
  41.   -- Build huffman table from code lengths given by array b.all 
  42.   procedure HufT_build (b     : Length_array; 
  43.                          s     : Integer; 
  44.                          d, e  : Length_array; 
  45.                          tl    :    out p_Table_list; 
  46.                          m     : in out Integer; 
  47.               huft_incomplete  :    out Boolean); 
  48.  
  49.   -- Possible exceptions occuring in huft_build 
  50.   huft_error,                    -- bad tree constructed 
  51.   huft_out_of_memory : exception; -- not enough memory 
  52.  
  53. end UnZip.Decompress.Huffman;