Back to index

php5  5.3.10
pharzip.h
Go to the documentation of this file.
00001 /*
00002   +----------------------------------------------------------------------+
00003   | phar php single-file executable PHP extension                        |
00004   +----------------------------------------------------------------------+
00005   | Copyright (c) 2006-2012 The PHP Group                                |
00006   +----------------------------------------------------------------------+
00007   | This source file is subject to version 3.01 of the PHP license,      |
00008   | that is bundled with this package in the file LICENSE, and is        |
00009   | available through the world-wide-web at the following url:           |
00010   | http://www.php.net/license/3_01.txt.                                 |
00011   | If you did not receive a copy of the PHP license and are unable to   |
00012   | obtain it through the world-wide-web, please send a note to          |
00013   | license@php.net so we can mail you a copy immediately.               |
00014   +----------------------------------------------------------------------+
00015   | Authors: Gregory Beaver <cellog@php.net>                             |
00016   |          Marcus Boerger <helly@php.net>                              |
00017   +----------------------------------------------------------------------+
00018 */
00019 
00020 /* $Id: pharzip.h 321634 2012-01-01 13:15:04Z felipe $ */
00021 
00022 typedef struct _phar_zip_file_header {
00023        char signature[4];       /* local file header signature     4 bytes  (0x04034b50) */
00024        char zipversion[2];      /* version needed to extract       2 bytes */
00025        char flags[2];        /* general purpose bit flag        2 bytes */
00026        char compressed[2];   /* compression method              2 bytes */
00027        char timestamp[2];    /* last mod file time              2 bytes */
00028        char datestamp[2];    /* last mod file date              2 bytes */
00029        char crc32[4];        /* crc-32                          4 bytes */
00030        char compsize[4];     /* compressed size                 4 bytes */
00031        char uncompsize[4];   /* uncompressed size               4 bytes */
00032        char filename_len[2]; /* file name length                2 bytes */
00033        char extra_len[2];    /* extra field length              2 bytes */
00034 /* file name (variable size) */
00035 /* extra field (variable size) */
00036 } phar_zip_file_header;
00037 
00038 /* unused in this release */
00039 typedef struct _phar_zip_file_datadesc {
00040        char signature[4];  /* signature (optional)            4 bytes */
00041        char crc32[4];      /* crc-32                          4 bytes */
00042        char compsize[4];   /* compressed size                 4 bytes */
00043        char uncompsize[4]; /* uncompressed size               4 bytes */
00044 } phar_zip_data_desc;
00045 
00046 /* unused in this release */
00047 typedef struct _phar_zip_file_datadesc_zip64 {
00048        char crc32[4];       /* crc-32                          4 bytes */
00049        char compsize[4];    /* compressed size                 8 bytes */
00050        char compsize2[4];
00051        char uncompsize[4];  /* uncompressed size               8 bytes */
00052        char uncompsize2[4];
00053 } phar_zip_data_desc_zip64;
00054 
00055 typedef struct _phar_zip_archive_extra_data_record {
00056        char signature[4];   /* archive extra data signature    4 bytes  (0x08064b50) */
00057        char len[4];      /* extra field length              4 bytes */
00058 /* extra field data                (variable size) */
00059 } phar_zip_archive_extra_data_record;
00060 
00061 /* madeby/extractneeded value if bzip2 compression is used */
00062 #define PHAR_ZIP_BZIP2 "46"
00063 /* madeby/extractneeded value for other cases */
00064 #define PHAR_ZIP_NORM  "20"
00065 
00066 #define PHAR_ZIP_FLAG_ENCRYPTED 0x0001
00067 /* data descriptor present for this file */
00068 #define PHAR_ZIP_FLAG_DATADESC  0x0008
00069 #define PHAR_ZIP_FLAG_UTF8      0x0400
00070 
00071 /*
00072 0 - The file is stored (no compression)
00073 1 - The file is Shrunk
00074 2 - The file is Reduced with compression factor 1
00075 3 - The file is Reduced with compression factor 2
00076 4 - The file is Reduced with compression factor 3
00077 5 - The file is Reduced with compression factor 4
00078 6 - The file is Imploded
00079 7 - Reserved for Tokenizing compression algorithm
00080 8 - The file is Deflated
00081 9 - Enhanced Deflating using Deflate64(tm)
00082 10 - PKWARE Data Compression Library Imploding (old IBM TERSE)
00083 11 - Reserved by PKWARE
00084 12 - File is compressed using BZIP2 algorithm
00085 13 - Reserved by PKWARE
00086 14 - LZMA (EFS)
00087 15 - Reserved by PKWARE
00088 16 - Reserved by PKWARE
00089 17 - Reserved by PKWARE
00090 18 - File is compressed using IBM TERSE (new)
00091 19 - IBM LZ77 z Architecture (PFS)
00092 97 - WavPack compressed data
00093 98 - PPMd version I, Rev 1
00094 */
00095 #define PHAR_ZIP_COMP_NONE    0
00096 #define PHAR_ZIP_COMP_DEFLATE 8
00097 #define PHAR_ZIP_COMP_BZIP2   12
00098 
00099 /*
00100          -ASi Unix Extra Field:
00101           ====================
00102 
00103           The following is the layout of the ASi extra block for Unix.  The
00104           local-header and central-header versions are identical.
00105           (Last Revision 19960916)
00106 
00107           Value         Size        Description
00108           -----         ----        -----------
00109   (Unix3) 0x756e        Short       tag for this extra block type ("nu")
00110           TSize         Short       total data size for this block
00111           CRC           Long        CRC-32 of the remaining data
00112           Mode          Short       file permissions
00113           SizDev        Long        symlink'd size OR major/minor dev num
00114           UID           Short       user ID
00115           GID           Short       group ID
00116           (var.)        variable    symbolic link filename
00117 
00118           Mode is the standard Unix st_mode field from struct stat, containing
00119           user/group/other permissions, setuid/setgid and symlink info, etc.
00120 
00121           If Mode indicates that this file is a symbolic link, SizDev is the
00122           size of the file to which the link points.  Otherwise, if the file
00123           is a device, SizDev contains the standard Unix st_rdev field from
00124           struct stat (includes the major and minor numbers of the device).
00125           SizDev is undefined in other cases.
00126 
00127           If Mode indicates that the file is a symbolic link, the final field
00128           will be the name of the file to which the link points.  The file-
00129           name length can be inferred from TSize.
00130 
00131           [Note that TSize may incorrectly refer to the data size not counting
00132            the CRC; i.e., it may be four bytes too small.]
00133 */
00134 
00135 typedef struct _phar_zip_extra_field_header {
00136        char tag[2];
00137        char size[2];
00138 } phar_zip_extra_field_header;
00139 
00140 typedef struct _phar_zip_unix3 {
00141        char tag[2];            /* 0x756e        Short       tag for this extra block type ("nu") */
00142        char size[2];        /* TSize         Short       total data size for this block */
00143        char crc32[4];       /* CRC           Long        CRC-32 of the remaining data */
00144        char perms[2];       /* Mode          Short       file permissions */
00145        char symlinksize[4]; /* SizDev        Long        symlink'd size OR major/minor dev num */
00146        char uid[2];         /* UID           Short       user ID */
00147        char gid[2];         /* GID           Short       group ID */
00148 /* (var.)        variable    symbolic link filename */
00149 } phar_zip_unix3;
00150 
00151 typedef struct _phar_zip_central_dir_file {
00152        char signature[4];            /* central file header signature   4 bytes  (0x02014b50) */
00153        char madeby[2];               /* version made by                 2 bytes */
00154        char zipversion[2];           /* version needed to extract       2 bytes */
00155        char flags[2];             /* general purpose bit flag        2 bytes */
00156        char compressed[2];        /* compression method              2 bytes */
00157        char timestamp[2];         /* last mod file time              2 bytes */
00158        char datestamp[2];         /* last mod file date              2 bytes */
00159        char crc32[4];             /* crc-32                          4 bytes */
00160        char compsize[4];          /* compressed size                 4 bytes */
00161        char uncompsize[4];        /* uncompressed size               4 bytes */
00162        char filename_len[2];      /* file name length                2 bytes */
00163        char extra_len[2];         /* extra field length              2 bytes */
00164        char comment_len[2];       /* file comment length             2 bytes */
00165        char disknumber[2];        /* disk number start               2 bytes */
00166        char internal_atts[2];     /* internal file attributes        2 bytes */
00167        char external_atts[4];     /* external file attributes        4 bytes */
00168        char offset[4];            /* relative offset of local header 4 bytes */
00169 
00170 /* file name (variable size) */
00171 /* extra field (variable size) */
00172 /* file comment (variable size) */
00173 } phar_zip_central_dir_file;
00174 
00175 typedef struct _phar_zip_dir_signature {
00176        char signature[4];  /* header signature                4 bytes  (0x05054b50) */
00177        char size[2];    /* size of data                    2 bytes */
00178 } phar_zip_dir_signature;
00179 
00180 /* unused in this release */
00181 typedef struct _phar_zip64_dir_end {
00182        char signature[4];        /* zip64 end of central dir 
00183                                  signature                       4 bytes  (0x06064b50) */
00184        char size1[4];         /* size of zip64 end of central
00185                                  directory record                8 bytes */
00186        char size2[4];
00187        char madeby[2];           /* version made by                 2 bytes */
00188        char extractneeded[2]; /* version needed to extract       2 bytes */
00189        char disknum[4];       /* number of this disk             4 bytes */
00190        char cdir_num[4];      /* number of the disk with the 
00191                                  start of the central directory  4 bytes */
00192        char entries1[4];      /* total number of entries in the
00193                                  central directory on this disk  8 bytes */
00194        char entries2[4];
00195        char entriestotal1[4]; /* total number of entries in the
00196                                  central directory               8 bytes */
00197        char entriestotal2[4];
00198        char cdirsize1[4];     /* size of the central directory   8 bytes */
00199        char cdirsize2[4];
00200        char offset1[4];       /* offset of start of central
00201                                  directory with respect to
00202                                  the starting disk number        8 bytes */
00203        char offset2[4];
00204 /* zip64 extensible data sector    (variable size) */
00205 } phar_zip64_dir_end;
00206 
00207 /* unused in this release */
00208 typedef struct _phar_zip64_dir_locator {
00209        char signature[4];     /* zip64 end of central dir locator 
00210                               signature                       4 bytes  (0x07064b50) */
00211        char disknum[4];    /* number of the disk with the
00212                               start of the zip64 end of 
00213                               central directory               4 bytes */
00214        char diroffset1[4]; /* relative offset of the zip64
00215                               end of central directory record 8 bytes */
00216        char diroffset2[4];
00217        char totaldisks[4]; /* total number of disks           4 bytes */
00218 } phar_zip64_dir_locator;
00219 
00220 typedef struct _phar_zip_dir_end {
00221        char signature[4];           /* end of central dir signature    4 bytes  (0x06054b50) */
00222        char disknumber[2];       /* number of this disk             2 bytes */
00223        char centraldisk[2];      /* number of the disk with the
00224                                     start of the central directory  2 bytes */
00225        char counthere[2];        /* total number of entries in the
00226                                     central directory on this disk  2 bytes */
00227        char count[2];            /* total number of entries in
00228                                     the central directory           2 bytes */
00229        char cdir_size[4];        /* size of the central directory   4 bytes */
00230        char cdir_offset[4];      /* offset of start of central
00231                                     directory with respect to
00232                                     the starting disk number        4 bytes */
00233        char comment_len[2];      /* .ZIP file comment length        2 bytes */
00234 /* .ZIP file comment       (variable size) */
00235 } phar_zip_dir_end;
00236 /*
00237  * Local variables:
00238  * tab-width: 4
00239  * c-basic-offset: 4
00240  * End:
00241  * vim600: noet sw=4 ts=4 fdm=marker
00242  * vim<600: noet sw=4 ts=4
00243  */