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