annotate src/zlib-1.2.8/contrib/ada/zlib-streams.ads @ 169:223a55898ab9 tip default

Add null config files
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 02 Mar 2020 14:03:47 +0000
parents 5b4145a0d408
children
rev   line source
cannam@128 1 ----------------------------------------------------------------
cannam@128 2 -- ZLib for Ada thick binding. --
cannam@128 3 -- --
cannam@128 4 -- Copyright (C) 2002-2003 Dmitriy Anisimkov --
cannam@128 5 -- --
cannam@128 6 -- Open source license information is in the zlib.ads file. --
cannam@128 7 ----------------------------------------------------------------
cannam@128 8
cannam@128 9 -- $Id: zlib-streams.ads,v 1.12 2004/05/31 10:53:40 vagul Exp $
cannam@128 10
cannam@128 11 package ZLib.Streams is
cannam@128 12
cannam@128 13 type Stream_Mode is (In_Stream, Out_Stream, Duplex);
cannam@128 14
cannam@128 15 type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class;
cannam@128 16
cannam@128 17 type Stream_Type is
cannam@128 18 new Ada.Streams.Root_Stream_Type with private;
cannam@128 19
cannam@128 20 procedure Read
cannam@128 21 (Stream : in out Stream_Type;
cannam@128 22 Item : out Ada.Streams.Stream_Element_Array;
cannam@128 23 Last : out Ada.Streams.Stream_Element_Offset);
cannam@128 24
cannam@128 25 procedure Write
cannam@128 26 (Stream : in out Stream_Type;
cannam@128 27 Item : in Ada.Streams.Stream_Element_Array);
cannam@128 28
cannam@128 29 procedure Flush
cannam@128 30 (Stream : in out Stream_Type;
cannam@128 31 Mode : in Flush_Mode := Sync_Flush);
cannam@128 32 -- Flush the written data to the back stream,
cannam@128 33 -- all data placed to the compressor is flushing to the Back stream.
cannam@128 34 -- Should not be used untill necessary, becouse it is decreasing
cannam@128 35 -- compression.
cannam@128 36
cannam@128 37 function Read_Total_In (Stream : in Stream_Type) return Count;
cannam@128 38 pragma Inline (Read_Total_In);
cannam@128 39 -- Return total number of bytes read from back stream so far.
cannam@128 40
cannam@128 41 function Read_Total_Out (Stream : in Stream_Type) return Count;
cannam@128 42 pragma Inline (Read_Total_Out);
cannam@128 43 -- Return total number of bytes read so far.
cannam@128 44
cannam@128 45 function Write_Total_In (Stream : in Stream_Type) return Count;
cannam@128 46 pragma Inline (Write_Total_In);
cannam@128 47 -- Return total number of bytes written so far.
cannam@128 48
cannam@128 49 function Write_Total_Out (Stream : in Stream_Type) return Count;
cannam@128 50 pragma Inline (Write_Total_Out);
cannam@128 51 -- Return total number of bytes written to the back stream.
cannam@128 52
cannam@128 53 procedure Create
cannam@128 54 (Stream : out Stream_Type;
cannam@128 55 Mode : in Stream_Mode;
cannam@128 56 Back : in Stream_Access;
cannam@128 57 Back_Compressed : in Boolean;
cannam@128 58 Level : in Compression_Level := Default_Compression;
cannam@128 59 Strategy : in Strategy_Type := Default_Strategy;
cannam@128 60 Header : in Header_Type := Default;
cannam@128 61 Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset
cannam@128 62 := Default_Buffer_Size;
cannam@128 63 Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset
cannam@128 64 := Default_Buffer_Size);
cannam@128 65 -- Create the Comression/Decompression stream.
cannam@128 66 -- If mode is In_Stream then Write operation is disabled.
cannam@128 67 -- If mode is Out_Stream then Read operation is disabled.
cannam@128 68
cannam@128 69 -- If Back_Compressed is true then
cannam@128 70 -- Data written to the Stream is compressing to the Back stream
cannam@128 71 -- and data read from the Stream is decompressed data from the Back stream.
cannam@128 72
cannam@128 73 -- If Back_Compressed is false then
cannam@128 74 -- Data written to the Stream is decompressing to the Back stream
cannam@128 75 -- and data read from the Stream is compressed data from the Back stream.
cannam@128 76
cannam@128 77 -- !!! When the Need_Header is False ZLib-Ada is using undocumented
cannam@128 78 -- ZLib 1.1.4 functionality to do not create/wait for ZLib headers.
cannam@128 79
cannam@128 80 function Is_Open (Stream : Stream_Type) return Boolean;
cannam@128 81
cannam@128 82 procedure Close (Stream : in out Stream_Type);
cannam@128 83
cannam@128 84 private
cannam@128 85
cannam@128 86 use Ada.Streams;
cannam@128 87
cannam@128 88 type Buffer_Access is access all Stream_Element_Array;
cannam@128 89
cannam@128 90 type Stream_Type
cannam@128 91 is new Root_Stream_Type with
cannam@128 92 record
cannam@128 93 Mode : Stream_Mode;
cannam@128 94
cannam@128 95 Buffer : Buffer_Access;
cannam@128 96 Rest_First : Stream_Element_Offset;
cannam@128 97 Rest_Last : Stream_Element_Offset;
cannam@128 98 -- Buffer for Read operation.
cannam@128 99 -- We need to have this buffer in the record
cannam@128 100 -- becouse not all read data from back stream
cannam@128 101 -- could be processed during the read operation.
cannam@128 102
cannam@128 103 Buffer_Size : Stream_Element_Offset;
cannam@128 104 -- Buffer size for write operation.
cannam@128 105 -- We do not need to have this buffer
cannam@128 106 -- in the record becouse all data could be
cannam@128 107 -- processed in the write operation.
cannam@128 108
cannam@128 109 Back : Stream_Access;
cannam@128 110 Reader : Filter_Type;
cannam@128 111 Writer : Filter_Type;
cannam@128 112 end record;
cannam@128 113
cannam@128 114 end ZLib.Streams;