annotate src/zlib-1.2.7/contrib/ada/zlib-streams.ads @ 83:ae30d91d2ffe

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