Debian Codegraph @

compat/zlib/contrib/ada/zlib-thin.adb

raw
1 ----------------------------------------------------------------
2 -- ZLib for Ada thick binding. --
3 -- --
4 -- Copyright (C) 2002-2003 Dmitriy Anisimkov --
5 -- --
6 -- Open source license information is in the zlib.ads file. --
7 ----------------------------------------------------------------
8
9 -- $Id: zlib-thin.adb,v 1.8 2003/12/14 18:27:31 vagul Exp $
10
11 package body ZLib.Thin is
12
13 ZLIB_VERSION : constant Chars_Ptr := zlibVersion;
14
15 Dummy : Z_Stream;
16 Z_Stream_Size : constant Int := Dummy'Size / System.Storage_Unit;
17
18 --------------
19 -- Avail_In --
20 --------------
21
22 function Avail_In (Strm : in Z_Stream) return UInt is
23 begin
24 return Strm.Avail_In;
25 end Avail_In;
26
27 ---------------
28 -- Avail_Out --
29 ---------------
30
31 function Avail_Out (Strm : in Z_Stream) return UInt is
32 begin
33 return Strm.Avail_Out;
34 end Avail_Out;
35
36 ------------------
37 -- Deflate_Init --
38 ------------------
39
40 function Deflate_Init
41 (strm : Z_Streamp;
42 level : Int;
43 method : Int;
44 windowBits : Int;
45 memLevel : Int;
46 strategy : Int)
47 return Int is
48 begin
49 return deflateInit2
50 (strm,
51 level,
52 method,
53 windowBits,
54 memLevel,
55 strategy,
56 ZLIB_VERSION,
57 Z_Stream_Size);
58 end Deflate_Init;
59
60 ------------------
61 -- Inflate_Init --
62 ------------------
63
64 function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int is
65 begin
66 return inflateInit2 (strm, windowBits, ZLIB_VERSION, Z_Stream_Size);
67 end Inflate_Init;
68
69 ------------------------
70 -- Last_Error_Message --
71 ------------------------
72
73 function Last_Error_Message (Strm : in Z_Stream) return String is
74 use Interfaces.C.Strings;
75 begin
76 if Strm.msg = Null_Ptr then
77 return "";
78 else
79 return Value (Strm.msg);
80 end if;
81 end Last_Error_Message;
82
83 ------------
84 -- Set_In --
85 ------------
86
87 procedure Set_In
88 (Strm : in out Z_Stream;
89 Buffer : in Voidp;
90 Size : in UInt) is
91 begin
92 Strm.Next_In := Buffer;
93 Strm.Avail_In := Size;
94 end Set_In;
95
96 ------------------
97 -- Set_Mem_Func --
98 ------------------
99
100 procedure Set_Mem_Func
101 (Strm : in out Z_Stream;
102 Opaque : in Voidp;
103 Alloc : in alloc_func;
104 Free : in free_func) is
105 begin
106 Strm.opaque := Opaque;
107 Strm.zalloc := Alloc;
108 Strm.zfree := Free;
109 end Set_Mem_Func;
110
111 -------------
112 -- Set_Out --
113 -------------
114
115 procedure Set_Out
116 (Strm : in out Z_Stream;
117 Buffer : in Voidp;
118 Size : in UInt) is
119 begin
120 Strm.Next_Out := Buffer;
121 Strm.Avail_Out := Size;
122 end Set_Out;
123
124 --------------
125 -- Total_In --
126 --------------
127
128 function Total_In (Strm : in Z_Stream) return ULong is
129 begin
130 return Strm.Total_In;
131 end Total_In;
132
133 ---------------
134 -- Total_Out --
135 ---------------
136
137 function Total_Out (Strm : in Z_Stream) return ULong is
138 begin
139 return Strm.Total_Out;
140 end Total_Out;
141
142 end ZLib.Thin;