text stringlengths 0 234 |
|---|
return b; |
end Intel_x86_buffer; |
function Intel_bf is new Intel_x86_buffer (Unsigned_16, 2); |
function Intel_bf is new Intel_x86_buffer (Unsigned_32, 4); |
------------------- |
-- PK signatures -- |
------------------- |
function PK_signature (buf : Byte_Buffer; code : Unsigned_8) return Boolean is |
(buf (1 .. 4) = (16#50#, 16#4B#, code, code + 1)); -- PK12, PK34, . .. |
procedure PK_signature (buf : in out Byte_Buffer; code : Unsigned_8) is |
begin |
buf (1 .. 4) := (16#50#, 16#4B#, code, code + 1); -- PK12, PK34, . .. |
end PK_signature; |
------------------------------------------------------- |
-- PKZIP file header, as in central directory - PK12 -- |
------------------------------------------------------- |
procedure Read_and_check (stream : Zipstream_Class; |
header : out Central_File_Header) is |
chb : Byte_Buffer (1 .. 46); |
begin |
BlockRead (stream, chb); |
if not PK_signature (chb, 1) then |
raise bad_central_header; |
end if; |
header := (made_by_version => Intel_nb (chb (5 .. 6)), |
short_info => |
(needed_extract_version => Intel_nb (chb (7 .. 8)), |
bit_flag => Intel_nb (chb (9 .. 10)), |
zip_type => Intel_nb (chb (11 .. 12)), |
file_timedate => Zip_Streams.Calendar.Convert (Unsigned_32'(Intel_nb (chb (13 .. 16)))), |
dd => |
(crc_32 => Intel_nb (chb (17 .. 20)), |
compressed_size => Intel_nb (chb (21 .. 24)), |
uncompressed_size => Intel_nb (chb (25 .. 28))), |
filename_length => Intel_nb (chb (29 .. 30)), |
extra_field_length => Intel_nb (chb (31 .. 32))), |
comment_length => Intel_nb (chb (33 .. 34)), |
disk_number_start => Intel_nb (chb (35 .. 36)), |
internal_attributes => Intel_nb (chb (37 .. 38)), |
external_attributes => Intel_nb (chb (39 .. 42)), |
local_header_offset => Intel_nb (chb (43 .. 46))); |
end Read_and_check; |
procedure Write (stream : Zipstream_Class; |
header : Central_File_Header) is |
chb : Byte_Buffer (1 .. 46); |
begin |
PK_signature (chb, 1); |
chb (5 .. 6) := Intel_bf (header.made_by_version); |
chb (7 .. 8) := Intel_bf (header.short_info.needed_extract_version); |
chb (9 .. 10) := Intel_bf (header.short_info.bit_flag); |
chb (11 .. 12) := Intel_bf (header.short_info.zip_type); |
chb (13 .. 16) := Intel_bf (Zip_Streams.Calendar.Convert (header.short_info.file_timedate)); |
chb (17 .. 20) := Intel_bf (header.short_info.dd.crc_32); |
chb (21 .. 24) := Intel_bf (header.short_info.dd.compressed_size); |
chb (25 .. 28) := Intel_bf (header.short_info.dd.uncompressed_size); |
chb (29 .. 30) := Intel_bf (header.short_info.filename_length); |
chb (31 .. 32) := Intel_bf (header.short_info.extra_field_length); |
chb (33 .. 34) := Intel_bf (header.comment_length); |
chb (35 .. 36) := Intel_bf (header.disk_number_start); |
chb (37 .. 38) := Intel_bf (header.internal_attributes); |
chb (39 .. 42) := Intel_bf (header.external_attributes); |
chb (43 .. 46) := Intel_bf (header.local_header_offset); |
BlockWrite (stream.all, chb); |
end Write; |
----------------------------------------------------------------------- |
-- PKZIP local file header, in front of every file in archive - PK34 -- |
----------------------------------------------------------------------- |
procedure Read_and_check (stream : Zipstream_Class; |
header : out Local_File_Header) is |
lhb : Byte_Buffer (1 .. 30); |
begin |
BlockRead (stream, lhb); |
if not PK_signature (lhb, 3) then |
raise bad_local_header; |
end if; |
header := |
(needed_extract_version => Intel_nb (lhb (5 .. 6)), |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.