text stringlengths 0 234 |
|---|
-- |
-- This is the *real* position of the end-of-central-directory block to begin with: |
X := I; |
-- We subtract the *theoretical* (stored) position of the end-of-central-directory. |
-- The theoretical position is equal to central_dir_offset + central_dir_size. |
-- The theoretical position should be smaller or equal than the real position - |
-- unless the archive is corrupted. |
-- We do it step by step, because ZS_Size_Type was modular until rev. 644. |
-- Now it's a signed 64 bits, but we don't want to change anything again... |
X := X - 1; |
-- i >= 1, so no dragons here. The "- 1" is for adapting |
-- from the 1-based Ada index. |
-- Fuzzy value, will trigger bad_end |
exit when Zs_Size_Type (The_End.Central_Dir_Offset) > X; |
-- Fuzzy value, will trigger bad_end |
X := X - Zs_Size_Type (The_End.Central_Dir_Offset); |
exit when Zs_Size_Type (The_End.Central_Dir_Size) > X; |
X := X - Zs_Size_Type (The_End.Central_Dir_Size); |
-- Now, x is the difference : real - theoretical. |
-- x > 0 if the archive was appended to another file (typically an executable |
-- for self-extraction purposes). |
-- x = 0 if this is a "pure" Zip archive. |
The_End.Offset_Shifting := X; |
Set_Index (Stream, I + 22); |
return; -- The_End found and filled -> exit |
end if; |
end loop; |
raise Bad_End; -- Definitely no "end-of-central-directory" in this stream |
Function Definition: procedure Dispose is new Ada.Unchecked_Deallocation (Huft_Table, P_Huft_Table); |
Function Body: procedure Dispose is new Ada.Unchecked_Deallocation (Table_List, P_Table_List); |
Current : P_Table_List; |
begin |
while Tl /= null loop |
Dispose (Tl.Table); -- Destroy the Huffman table |
Current := Tl; |
Tl := Tl.Next; |
Dispose (Current); -- Destroy the current node |
end loop; |
end Huft_Free; |
-- Build huffman table from code lengths given by array b |
procedure Huft_Build |
(B : Length_Array; |
S : Integer; |
D, E : Length_Array; |
Tl : out P_Table_List; |
M : in out Integer; |
Huft_Incomplete : out Boolean) |
is |
B_Max : constant := 16; |
B_Maxp1 : constant := B_Max + 1; |
-- Bit length count table |
Count : array (0 .. B_Maxp1) of Integer := (others => 0); |
F : Integer; -- I repeats in table every f entries |
G : Integer; -- Maximum code length |
I : Integer; -- Counter, current code |
J : Integer; -- Counter |
Kcc : Integer; -- Number of bits in current code |
C_Idx, V_Idx : Natural; -- Array indices |
Current_Table_Ptr : P_Huft_Table := null; |
Current_Node_Ptr : P_Table_List := null; -- Current node for the current table |
New_Node_Ptr : P_Table_List; -- New node for the new table |
New_Entry : Huft; -- Table entry for structure assignment |
U : array (0 .. B_Max) of P_Huft_Table; -- Table stack |
N_Max : constant := 288; |
-- Values in order of bit length |
V : array (0 .. N_Max) of Integer := (others => 0); |
El_V, El_V_M_S : Integer; |
W : Natural := 0; -- Bits before this table |
Offset, Code_Stack : array (0 .. B_Maxp1) of Integer; |
Table_Level : Integer := -1; |
Bits : array (Integer'(-1) .. B_Maxp1) of Integer; |
-- ^ bits(table_level) = # bits in table of level table_level |
Y : Integer; -- Number of dummy codes added |
Z : Natural := 0; -- Number of entries in current table |
El : Integer; -- Length of eob code=code 256 |
No_Copy_Length_Array : constant Boolean := D'Length = 0 or E'Length = 0; |
begin |
Tl := null; |
if B'Length > 256 then -- Set length of EOB code, if any |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.