~ubuntu-branches/ubuntu/feisty/clamav/feisty

« back to all changes in this revision

Viewing changes to win32/3rdparty/zlib/contrib/ada/zlib-streams.ads

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2007-02-20 10:33:44 UTC
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20070220103344-zgcu2psnx9d98fpa
Tags: upstream-0.90
ImportĀ upstreamĀ versionĀ 0.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
----------------------------------------------------------------
2
 
----------------------------------------------------------------
3
 
 
4
 
 
5
 
package ZLib.Streams is
6
 
 
7
 
   type Stream_Mode is (In_Stream, Out_Stream, Duplex);
8
 
 
9
 
   type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class;
10
 
 
11
 
   type Stream_Type is
12
 
      new Ada.Streams.Root_Stream_Type with private;
13
 
 
14
 
   procedure Read
15
 
     (Stream : in out Stream_Type;
16
 
      Item   :    out Ada.Streams.Stream_Element_Array;
17
 
      Last   :    out Ada.Streams.Stream_Element_Offset);
18
 
 
19
 
   procedure Write
20
 
     (Stream : in out Stream_Type;
21
 
      Item   : in     Ada.Streams.Stream_Element_Array);
22
 
 
23
 
   procedure Flush
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
29
 
   --  compression.
30
 
 
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.
34
 
 
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.
38
 
 
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.
42
 
 
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.
46
 
 
47
 
   procedure Create
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.
62
 
 
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.
66
 
 
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.
70
 
 
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.
73
 
 
74
 
   function Is_Open (Stream : Stream_Type) return Boolean;
75
 
 
76
 
   procedure Close (Stream : in out Stream_Type);
77
 
 
78
 
private
79
 
 
80
 
   use Ada.Streams;
81
 
 
82
 
   type Buffer_Access is access all Stream_Element_Array;
83
 
 
84
 
   type Stream_Type
85
 
     is new Root_Stream_Type with
86
 
   record
87
 
      Mode       : Stream_Mode;
88
 
 
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.
96
 
 
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.
102
 
 
103
 
      Back       : Stream_Access;
104
 
      Reader     : Filter_Type;
105
 
      Writer     : Filter_Type;
106
 
   end record;
107
 
 
108
 
end ZLib.Streams;