text
stringlengths
0
234
begin
return Integer (Read_U32 (N));
end Read;
function Read_And_Dump (N : Natural) return Integer is
Res : Integer;
begin
Res := Read (N);
Dump (N);
return Res;
end Read_And_Dump;
function Read_And_Dump_U32 (N : Natural) return Unsigned_32 is
Res : Unsigned_32;
begin
Res := Read_U32 (N);
Dump (N);
return Res;
end Read_And_Dump_U32;
end Bit_Buffer;
procedure Flush (X : Natural) is
use Zip;
use Ada.Streams;
begin
begin
Blockwrite (Output_Stream_Access.all, Unz_Glob.Slide (0 .. X - 1));
exception
when others =>
raise Unzip.Write_Error;
Function Definition: procedure Inflate_Stored_Block is -- Actually, nothing to inflate
Function Body: N : Integer;
begin
Unz_Io.Bit_Buffer.Dump_To_Byte_Boundary;
-- Get the block length and its complement
N := Unz_Io.Bit_Buffer.Read_And_Dump (16);
if N /= Integer ((not Unz_Io.Bit_Buffer.Read_And_Dump_U32 (16)) and 16#ffff#) then
raise Zip.Archive_Corrupted;
end if;
while N > 0 and then not Zip_Eof loop
-- Read and output the non-compressed data
N := N - 1;
Unz_Glob.Slide (Unz_Glob.Slide_Index) :=
Zip.Byte (Unz_Io.Bit_Buffer.Read_And_Dump (8));
Unz_Glob.Slide_Index := Unz_Glob.Slide_Index + 1;
Unz_Io.Flush_If_Full (Unz_Glob.Slide_Index);
end loop;
end Inflate_Stored_Block;
-- Copy lengths for literal codes 257..285
Copy_Lengths_Literal : constant Length_Array (0 .. 30) :=
(3,
4,
5,
6,
7,
8,
9,
10,
11,
13,
15,
17,
19,
23,
27,
31,
35,
43,
51,
59,
67,
83,
99,
115,
131,
163,
195,
227,
258,
0,
0);
-- Extra bits for literal codes 257..285
Extra_Bits_Literal : constant Length_Array (0 .. 30) :=
(0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,