Back to... Zip-Ada

Source file : unzip-decompress.ads



   1  --  UnZip.Decompress
   2  --------------------
   3  --  Private, internal to the UnZip package.
   4  --  See root package (UnZip) for details & credits.
   5  
   6  --  Legal licensing note:
   7  
   8  --  Copyright (c) 2007 .. 2024 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  ---------------------
  33  --
  34  --  Created 9-Mar-2007
  35  --
  36  --  This package includes the decompression algorithms for methods
  37  --  Store, Reduce, Shrink (LZW), Implode, Deflate, BZip2 and LZMA.
  38  --
  39  --  The package body contains the packages UnZ_IO, UnZ_Glob, UnZ_Infl,
  40  --  UnZ_Olds and UnZ_Misc that were separate in previous versions of Zip-Ada.
  41  --  They became local packages inside the Decompress_Data procedure.
  42  --  Previously global variables are since then local and task-safe
  43  --  with one copy per concurrent call.
  44  
  45  with Zip.Headers;
  46  with Zip_Streams;
  47  
  48  with Ada.Strings.Unbounded;
  49  
  50  private package UnZip.Decompress is
  51  
  52    procedure Decompress_Data
  53      (zip_file                   : in out Zip_Streams.Root_Zipstream_Type'Class;
  54       --  zip_file must be open and its index is meant
  55       --  to point to the beginning of compressed data
  56       format                     : in     Zip.PKZip_method;
  57       write_mode                 : in     Write_Mode_Type;
  58       output_file_name           : in     String;  --  relevant only if mode = write_to_file
  59       output_memory_access       :    out p_Stream_Element_Array;  -- \ = write_to_memory
  60       output_stream_access       : in     p_Stream;                -- \ = write_to_stream
  61       feedback                   : in     Zip.Feedback_Proc;
  62       explode_literal_tree       : in     Boolean;  --  relevant for the "explode" format
  63       explode_slide_8KB_LZMA_EOS : in     Boolean;  --  relevant for the "explode" and "LZMA" formats
  64       data_descriptor_after_data : in     Boolean;
  65       is_encrypted               : in     Boolean;
  66       password                   : in out Ada.Strings.Unbounded.Unbounded_String;
  67       get_new_password           : in     Get_Password_Proc;  --  if null, initial pwd must fit
  68       hint                       : in out Zip.Headers.Local_File_Header);
  69       --
  70       --  Values are known, or smart fakes, and are later corrected if a closing
  71       --  Data_descriptor is appended to the compressed data (1-pass written
  72       --  zip files, like JAR, OpenDocument, etc.)
  73  
  74  private
  75  
  76    --  When deflate_strict = True, stop if there is an incomplete Huffman
  77    --  code set for decoding LZ distances. This is the correct and safe behaviour.
  78    --  When dealing with Zip files from some old compression programs like PKZIP 1.93a,
  79    --  the check can be bypassed with deflate_strict = False, but this lessens the
  80    --  data error detection.
  81    --
  82    deflate_strict : constant Boolean := True;
  83  
  84    --  Primitive tracing using Ada.Text_IO, plus a few statistics
  85    --
  86    type Trace_type is (none, some_t, full);
  87  
  88    trace : constant Trace_type := none; --  <==  Choice is here
  89  
  90    no_trace   : constant Boolean := trace = none;
  91    some_trace : constant Boolean := trace >= some_t;
  92    full_trace : constant Boolean := trace = full;
  93  
  94  end UnZip.Decompress;

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.