Subversion Repositories autosfx

Rev

Blame | Last modification | View Log | RSS feed

  1. (******************************************************************)
  2. (* Structures for DelZip v1.7                                     *)
  3. (* Copyright (C)1997-2004 E. W. Engler, C. Vleghert, M. Stephany  *)
  4. (*                                                                *)
  5. (* written by Markus Stephany                                     *)
  6. (* mailto:delphizip@mirkes.de                                     *)
  7. (* http://delphizip.mirkes.de                                     *)
  8. (*                                                                *)
  9. (* last changed: 12/21/2003                                       *)
  10. (*                                                                *)
  11. (******************************************************************)
  12. (************************************************************************
  13.  Copyright (C) 2009, 2010  by Russell J. Peters, Roger Aelbrecht,
  14.       Eric W. Engler and Chris Vleghert.
  15.  
  16.    This file is part of TZipMaster Version 1.9.
  17.  
  18.     TZipMaster is free software: you can redistribute it and/or modify
  19.     it under the terms of the GNU Lesser General Public License as published by
  20.     the Free Software Foundation, either version 3 of the License, or
  21.     (at your option) any later version.
  22.  
  23.     TZipMaster is distributed in the hope that it will be useful,
  24.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  25.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  26.     GNU Lesser General Public License for more details.
  27.  
  28.     You should have received a copy of the GNU Lesser General Public License
  29.     along with TZipMaster.  If not, see <http://www.gnu.org/licenses/>.
  30.  
  31.     contact: problems@delphizip.org (include ZipMaster in the subject).
  32.     updates: http://www.delphizip.org
  33.     DelphiZip maillist subscribe at http://www.freelists.org/list/delphizip
  34. ************************************************************************)
  35. unit ZMSFXStructs19;
  36.  
  37. {
  38. this unit contains definitions of records and signatures used
  39. in zipfiles.
  40.  
  41. }
  42.  
  43. interface
  44.  
  45. uses
  46.   Windows;
  47. {$I '..\ZipVers19.inc'}
  48.  
  49. const
  50.   FS_FAT: Integer = 0;
  51.   FS_HPFS: Integer = 6;
  52.   FS_NTFS: Integer = 11;
  53.   FLAG_UTF8_BIT = $0800;
  54.                          
  55.   Zip64_data_tag = $0001;     // Zip64 extra field tag
  56.   NTFS_STAMP_TAG = $000A;     // NTFS time stamps
  57.   UPath_Data_Tag = $7075;     // Info-Zip UTF8 path field
  58.   UCmnt_Data_Tag = $6375;     // Info-Zip UTF8 comment field
  59. // Tag - 2 byte
  60. // total size - 2 byte
  61. // version - 1 byte = 1
  62. // crc -4 bytes = crc of orig field
  63. // utf8 string - total size - 9
  64.  
  65. type
  66.   XNTFSData = packed record
  67.     MTime: Int64;
  68.     ATime: Int64;
  69.     CTime: Int64;
  70.   end;
  71.   PXNTFData = ^XNTFSData;
  72.  
  73. type
  74.   PUString_Data_Header = ^UString_Data_Header;
  75.   UString_Data_Header = packed record
  76.     tag: word;
  77.     totsiz: word;
  78.     version: byte;
  79.     origcrc: DWORD;
  80.   end;
  81.  
  82. type
  83.   // local file header entry
  84.   PZipLocalHeader = ^TZipLocalHeader;
  85.   TZipLocalHeader = packed record
  86.     HeaderSig: LongWord;
  87.     VersionNeed: Word;
  88.     Flag: Word;
  89.     ComprMethod: Word;
  90.     ModifTime: Word;
  91.     ModifDate: Word;
  92.     CRC32: LongWord;
  93.     ComprSize: LongWord;
  94.     UnComprSize: LongWord;
  95.     FileNameLen: Word;
  96.     ExtraLen: Word;
  97.   end;
  98. //  ZipLocalHeader = TZipLocalHeader;
  99.  
  100.  
  101.   // central directory entry
  102.   PZipCentralHeader = ^TZipCentralHeader;
  103.   TZipCentralHeader = packed record //fixed part size : 42 bytes
  104.     HeaderSig: LongWord; // hex: 02014B50(4)
  105.     VersionMadeBy0: Byte; //version made by(1)
  106.     VersionMadeBy1: Byte; //host number(1)
  107.     VersionNeed: Word; // version needed to extract(2)
  108.     Flag: Word; //generalPurpose bitflag(2)
  109.     ComprMethod: Word; //compression method(2)
  110.     ModifTime: Word; // modification time(2)
  111.     ModifDate: Word; // modification date(2)
  112.     CRC32: LongWord; //Cycling redundancy check (4)
  113.     ComprSize: LongWord; //compressed file size  (4)
  114.     UnComprSize: LongWord; //uncompressed file size (4)
  115.     FileNameLen: Word; //(2)
  116.     ExtraLen: Word; //(2)
  117.     FileComLen: Word; //(2)
  118.     DiskStart: Word; //starts on disk number xx(2)
  119.     IntFileAtt: Word; //internal file attributes(2)
  120.     ExtFileAtt: LongWord; //external file attributes(4)
  121.     RelOffLocal: LongWord; //relative offset of local file header(4)
  122.     // not used as part of this record structure:
  123.     // filename, extra data, file comment
  124.   end;
  125. //  ZipCentralHeader = TZipCentralHeader;
  126.  
  127.   pZ64CentralEntry = ^TZ64CentralEntry;
  128.   TZ64CentralEntry = packed record // used internally  
  129.     HeaderSig: LongWord; // hex: 02014B50(4)
  130.     VersionMadeBy0: Byte; //version made by(1)
  131.     VersionMadeBy1: Byte; //host number(1)
  132.     VersionNeed: Word; // version needed to extract(2)
  133.     Flag: Word; //generalPurpose bitflag(2)
  134.     ComprMethod: Word; //compression method(2)
  135.     ModifTime: Word; // modification time(2)
  136.     ModifDate: Word; // modification date(2)
  137.     CRC32: LongWord; //Cycling redundancy check (4)
  138.     ComprSize: Int64; //compressed file size  (4)
  139.     UnComprSize: Int64; //uncompressed file size (4)
  140.     FileNameLen: Word; //(2)
  141.     ExtraLen: Word; //(2)
  142.     FileComLen: Word; //(2)
  143.     DiskStart: Word; //starts on disk number xx(2)
  144.     IntFileAtt: Word; //internal file attributes(2)
  145.     ExtFileAtt: LongWord; //external file attributes(4)
  146.     RelOffLocal: Int64; //relative offset of local file header(4)
  147.     MTime: Int64; // ntfs modified time - only if data available
  148.     ATime: Int64; // ntfs accessed time - only if data available
  149.     CTime: Int64; // ntfs created time - only if data available
  150.     // not used as part of this record structure:
  151.     // filename, extra data, file comment
  152.   end;
  153.  
  154.   // end of central directory record
  155.   PZipEndOfCentral = ^TZipEndOfCentral;
  156.   TZipEndOfCentral = packed record //Fixed part size : 22 bytes
  157.     HeaderSig: LongWord; //(4)  hex=06054B50
  158.     ThisDiskNo: Word; //(2)This disk's number
  159.     CentralDiskNo: Word; //(2)Disk number central directory start
  160.     CentralEntries: Word; //(2)Number of central directory entries on this disk
  161.     TotalEntries: Word; //(2)Number of entries in central dir
  162.     CentralSize: LongWord; //(4)Size of central directory
  163.     CentralOffSet: LongWord; //(4)offsett of central directory on 1st disk
  164.     ZipCommentLen: Word; //(2)
  165.     // not used as part of this record structure:
  166.     // ZipComment
  167.   end;
  168. //  ZipEndOfCentral = TZipEndOfCentral;
  169.  
  170.   // ext local header (for spanning ?)
  171.   PZipExtLocalHeader = ^TZipExtLocalHeader;
  172.   TZipExtLocalHeader = packed record
  173.     DataDescSig: LongWord; // Should be 0x08074B50
  174.     CRC32: LongWord;
  175.     ComprSize: LongWord;
  176.     UnComprSize: LongWord;
  177.   end;
  178. //  ZipExtLocalHeader = TZipExtLocalHeader;
  179. //  ZipDataDescriptor = TZipExtLocalHeader;
  180.  
  181. type
  182.   // must be same disk as EOC
  183.   pZip64EOCLocator = ^TZip64EOCLocator;
  184.   TZip64EOCLocator = packed record
  185.     LocSig: Longword;             // (4) Should be 0x07064B50
  186.     EOC64DiskStt: Longword;       // (4)
  187.     EOC64RelOfs: Int64;          // (8) relative to start of it's disk
  188.     NumberDisks: Longword;        // (4) total disks
  189.   end;
  190. //  pZip64EOCLocator = ^TZip64EOCLocator;
  191.  
  192. type
  193.   pZipEOC64 = ^TZipEOC64;
  194.   TZipEOC64 = packed record
  195.     EOC64Sig: LongWord;           // (4) should be 0x06064b50
  196.     vsize: Int64;                // (8)    size of variable part
  197.     // variable part   - fields as needed? (old field = 0XFFFF or 0XFF)
  198.     VersionMade: Word;            // (2)
  199.     VersionNeed: Word;            // (2)
  200.     ThisDiskNo: LongWord;         // (4)
  201.     CentralDiskNo: LongWord;      // (4)
  202.     CentralEntries: Int64;       // (8) Number of central dir entries on this disk
  203.     TotalEntries: Int64;         // (8) Number of entries in central dir
  204.     CentralSize: Int64;          // (8) Size of central directory
  205.     CentralOffSet: Int64;        // (8) offsett of central dir on 1st disk
  206. //  zip64 extensible data sector    (variable size)
  207.   end;
  208.  
  209. type
  210.   TZipCentralDigitSignature = packed record
  211.     CenDigSig: LongWord;          // (4) should be 0x05054b50
  212.     vsize: Word;                  // (2)
  213. //    data[vsize]
  214.   end;
  215.  
  216. var { these are stored in reverse order }
  217.   // xyz-1: avoid zip structure signatures in the sfx code
  218.   //        zipdll.dll doesn't like them...
  219.   ZipLocalHeaderSig: DWORD = $04034B50-1; { 'PK'34  (in file: 504b0304) }
  220.   ZipCentralHeaderSig: DWORD = $02014B50-1; { 'PK'12 }
  221.   ZipEndOfCentralSig: DWORD = $06054B50-1; { 'PK'56 }
  222.   ZipExtLocalHeaderSig: DWORD = $08074B50-1; { 'PK'78 }
  223.   ZipEndCentral64Sig: DWORD = $06064B50-1;       { 'PK'66 }
  224.   ZipEOC64LocatorSig: DWORD = $07064B50-1;       { 'PK'67 }
  225.  
  226.  
  227. // buffer stuff (not anymore public in zipmstr.pas)
  228. const
  229.   SFXBufSize = 8192;
  230.                  
  231. //  Zip64_data_tag = $0001;   // zip64 extra field tag
  232.  
  233.   MAX_UNSIGNED:DWORD   = $FFFFFFFF;
  234.   MAX_WORD:WORD = $FFFF;
  235.   MAX_BYTE:BYTE  = $FF;
  236.  
  237. type
  238.   PSFXBuffer = ^TSFXBuffer;
  239.   TSFXBuffer = array[0..SFXBufSize - 1] of Byte;
  240.  
  241. implementation
  242.  
  243. initialization
  244.   // adjust the signatures
  245.   Inc(ZipLocalHeaderSig);
  246.   Inc(ZipCentralHeaderSig);
  247.   Inc(ZipEndOfCentralSig);
  248.   Inc(ZipExtLocalHeaderSig);
  249.   Inc(ZipEndCentral64Sig);
  250.   Inc(ZipEOC64LocatorSig);
  251.  
  252. end.
  253.