1
----------------------------------------------------------------
2
----------------------------------------------------------------
5
package ZLib.Streams is
7
type Stream_Mode is (In_Stream, Out_Stream, Duplex);
9
type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class;
12
new Ada.Streams.Root_Stream_Type with private;
15
(Stream : in out Stream_Type;
16
Item : out Ada.Streams.Stream_Element_Array;
17
Last : out Ada.Streams.Stream_Element_Offset);
20
(Stream : in out Stream_Type;
21
Item : in Ada.Streams.Stream_Element_Array);
24
(Stream : in out Stream_Type;
25
Mode : in Flush_Mode := Sync_Flush);
26
-- Flush the written data to the back stream,
27
-- all data placed to the compressor is flushing to the Back stream.
28
-- Should not be used untill necessary, becouse it is decreasing
31
function Read_Total_In (Stream : in Stream_Type) return Count;
32
pragma Inline (Read_Total_In);
33
-- Return total number of bytes read from back stream so far.
35
function Read_Total_Out (Stream : in Stream_Type) return Count;
36
pragma Inline (Read_Total_Out);
37
-- Return total number of bytes read so far.
39
function Write_Total_In (Stream : in Stream_Type) return Count;
40
pragma Inline (Write_Total_In);
41
-- Return total number of bytes written so far.
43
function Write_Total_Out (Stream : in Stream_Type) return Count;
44
pragma Inline (Write_Total_Out);
45
-- Return total number of bytes written to the back stream.
48
(Stream : out Stream_Type;
49
Mode : in Stream_Mode;
50
Back : in Stream_Access;
51
Back_Compressed : in Boolean;
52
Level : in Compression_Level := Default_Compression;
53
Strategy : in Strategy_Type := Default_Strategy;
54
Header : in Header_Type := Default;
55
Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset
56
:= Default_Buffer_Size;
57
Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset
58
:= Default_Buffer_Size);
59
-- Create the Comression/Decompression stream.
60
-- If mode is In_Stream then Write operation is disabled.
61
-- If mode is Out_Stream then Read operation is disabled.
63
-- If Back_Compressed is true then
64
-- Data written to the Stream is compressing to the Back stream
65
-- and data read from the Stream is decompressed data from the Back stream.
67
-- If Back_Compressed is false then
68
-- Data written to the Stream is decompressing to the Back stream
69
-- and data read from the Stream is compressed data from the Back stream.
71
-- !!! When the Need_Header is False ZLib-Ada is using undocumented
72
-- ZLib 1.1.4 functionality to do not create/wait for ZLib headers.
74
function Is_Open (Stream : Stream_Type) return Boolean;
76
procedure Close (Stream : in out Stream_Type);
82
type Buffer_Access is access all Stream_Element_Array;
85
is new Root_Stream_Type with
89
Buffer : Buffer_Access;
90
Rest_First : Stream_Element_Offset;
91
Rest_Last : Stream_Element_Offset;
92
-- Buffer for Read operation.
93
-- We need to have this buffer in the record
94
-- becouse not all read data from back stream
95
-- could be processed during the read operation.
97
Buffer_Size : Stream_Element_Offset;
98
-- Buffer size for write operation.
99
-- We do not need to have this buffer
100
-- in the record becouse all data could be
101
-- processed in the write operation.
103
Back : Stream_Access;
104
Reader : Filter_Type;
105
Writer : Filter_Type;