php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
pharzip.h
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | phar php single-file executable PHP extension |
4 +----------------------------------------------------------------------+
5 | Copyright (c) The PHP Group |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | https://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
15 | Authors: Gregory Beaver <cellog@php.net> |
16 | Marcus Boerger <helly@php.net> |
17 +----------------------------------------------------------------------+
18*/
19
20typedef struct _phar_zip_file_header {
21 char signature[4]; /* local file header signature 4 bytes (0x04034b50) */
22 char zipversion[2]; /* version needed to extract 2 bytes */
23 char flags[2]; /* general purpose bit flag 2 bytes */
24 char compressed[2]; /* compression method 2 bytes */
25 char timestamp[2]; /* last mod file time 2 bytes */
26 char datestamp[2]; /* last mod file date 2 bytes */
27 char crc32[4]; /* crc-32 4 bytes */
28 char compsize[4]; /* compressed size 4 bytes */
29 char uncompsize[4]; /* uncompressed size 4 bytes */
30 char filename_len[2]; /* file name length 2 bytes */
31 char extra_len[2]; /* extra field length 2 bytes */
32/* file name (variable size) */
33/* extra field (variable size) */
35
36/* unused in this release */
38 char signature[4]; /* signature (optional) 4 bytes */
39 char crc32[4]; /* crc-32 4 bytes */
40 char compsize[4]; /* compressed size 4 bytes */
41 char uncompsize[4]; /* uncompressed size 4 bytes */
43
44/* unused in this release */
46 char crc32[4]; /* crc-32 4 bytes */
47 char compsize[4]; /* compressed size 8 bytes */
48 char compsize2[4];
49 char uncompsize[4]; /* uncompressed size 8 bytes */
50 char uncompsize2[4];
52
54 char signature[4]; /* archive extra data signature 4 bytes (0x08064b50) */
55 char len[4]; /* extra field length 4 bytes */
56/* extra field data (variable size) */
58
59/* madeby/extractneeded value if bzip2 compression is used */
60#define PHAR_ZIP_BZIP2 "46"
61/* madeby/extractneeded value for other cases */
62#define PHAR_ZIP_NORM "20"
63
64#define PHAR_ZIP_FLAG_ENCRYPTED 0x0001
65/* data descriptor present for this file */
66#define PHAR_ZIP_FLAG_DATADESC 0x0008
67#define PHAR_ZIP_FLAG_UTF8 0x0400
68
69/*
700 - The file is stored (no compression)
711 - The file is Shrunk
722 - The file is Reduced with compression factor 1
733 - The file is Reduced with compression factor 2
744 - The file is Reduced with compression factor 3
755 - The file is Reduced with compression factor 4
766 - The file is Imploded
777 - Reserved for Tokenizing compression algorithm
788 - The file is Deflated
799 - Enhanced Deflating using Deflate64(tm)
8010 - PKWARE Data Compression Library Imploding (old IBM TERSE)
8111 - Reserved by PKWARE
8212 - File is compressed using BZIP2 algorithm
8313 - Reserved by PKWARE
8414 - LZMA (EFS)
8515 - Reserved by PKWARE
8616 - Reserved by PKWARE
8717 - Reserved by PKWARE
8818 - File is compressed using IBM TERSE (new)
8919 - IBM LZ77 z Architecture (PFS)
9097 - WavPack compressed data
9198 - PPMd version I, Rev 1
92*/
93#define PHAR_ZIP_COMP_NONE 0
94#define PHAR_ZIP_COMP_DEFLATE 8
95#define PHAR_ZIP_COMP_BZIP2 12
96
97/*
98 -ASi Unix Extra Field:
99 ====================
100
101 The following is the layout of the ASi extra block for Unix. The
102 local-header and central-header versions are identical.
103 (Last Revision 19960916)
104
105 Value Size Description
106 ----- ---- -----------
107 (Unix3) 0x756e Short tag for this extra block type ("nu")
108 TSize Short total data size for this block
109 CRC Long CRC-32 of the remaining data
110 Mode Short file permissions
111 SizDev Long symlink'd size OR major/minor dev num
112 UID Short user ID
113 GID Short group ID
114 (var.) variable symbolic link filename
115
116 Mode is the standard Unix st_mode field from struct stat, containing
117 user/group/other permissions, setuid/setgid and symlink info, etc.
118
119 If Mode indicates that this file is a symbolic link, SizDev is the
120 size of the file to which the link points. Otherwise, if the file
121 is a device, SizDev contains the standard Unix st_rdev field from
122 struct stat (includes the major and minor numbers of the device).
123 SizDev is undefined in other cases.
124
125 If Mode indicates that the file is a symbolic link, the final field
126 will be the name of the file to which the link points. The file-
127 name length can be inferred from TSize.
128
129 [Note that TSize may incorrectly refer to the data size not counting
130 the CRC; i.e., it may be four bytes too small.]
131*/
132
137
138typedef struct _phar_zip_unix3 {
139 char tag[2]; /* 0x756e Short tag for this extra block type ("nu") */
140 char size[2]; /* TSize Short total data size for this block */
141 char crc32[4]; /* CRC Long CRC-32 of the remaining data */
142 char perms[2]; /* Mode Short file permissions */
143 char symlinksize[4]; /* SizDev Long symlink'd size OR major/minor dev num */
144 char uid[2]; /* UID Short user ID */
145 char gid[2]; /* GID Short group ID */
146/* (var.) variable symbolic link filename */
148
149/* See https://libzip.org/specifications/extrafld.txt */
150typedef struct _phar_zip_unix_time {
152 char flags; /* flags 1 byte */
153 char time[4]; /* time in standard Unix format 4 bytes */
155
157 char signature[4]; /* central file header signature 4 bytes (0x02014b50) */
158 char madeby[2]; /* version made by 2 bytes */
159 char zipversion[2]; /* version needed to extract 2 bytes */
160 char flags[2]; /* general purpose bit flag 2 bytes */
161 char compressed[2]; /* compression method 2 bytes */
162 char timestamp[2]; /* last mod file time 2 bytes */
163 char datestamp[2]; /* last mod file date 2 bytes */
164 char crc32[4]; /* crc-32 4 bytes */
165 char compsize[4]; /* compressed size 4 bytes */
166 char uncompsize[4]; /* uncompressed size 4 bytes */
167 char filename_len[2]; /* file name length 2 bytes */
168 char extra_len[2]; /* extra field length 2 bytes */
169 char comment_len[2]; /* file comment length 2 bytes */
170 char disknumber[2]; /* disk number start 2 bytes */
171 char internal_atts[2]; /* internal file attributes 2 bytes */
172 char external_atts[4]; /* external file attributes 4 bytes */
173 char offset[4]; /* relative offset of local header 4 bytes */
174
175/* file name (variable size) */
176/* extra field (variable size) */
177/* file comment (variable size) */
179
181 char signature[4]; /* header signature 4 bytes (0x05054b50) */
182 char size[2]; /* size of data 2 bytes */
184
185/* unused in this release */
186typedef struct _phar_zip64_dir_end {
187 char signature[4]; /* zip64 end of central dir
188 signature 4 bytes (0x06064b50) */
189 char size1[4]; /* size of zip64 end of central
190 directory record 8 bytes */
191 char size2[4];
192 char madeby[2]; /* version made by 2 bytes */
193 char extractneeded[2]; /* version needed to extract 2 bytes */
194 char disknum[4]; /* number of this disk 4 bytes */
195 char cdir_num[4]; /* number of the disk with the
196 start of the central directory 4 bytes */
197 char entries1[4]; /* total number of entries in the
198 central directory on this disk 8 bytes */
199 char entries2[4];
200 char entriestotal1[4]; /* total number of entries in the
201 central directory 8 bytes */
203 char cdirsize1[4]; /* size of the central directory 8 bytes */
204 char cdirsize2[4];
205 char offset1[4]; /* offset of start of central
206 directory with respect to
207 the starting disk number 8 bytes */
208 char offset2[4];
209/* zip64 extensible data sector (variable size) */
211
212/* unused in this release */
214 char signature[4]; /* zip64 end of central dir locator
215 signature 4 bytes (0x07064b50) */
216 char disknum[4]; /* number of the disk with the
217 start of the zip64 end of
218 central directory 4 bytes */
219 char diroffset1[4]; /* relative offset of the zip64
220 end of central directory record 8 bytes */
221 char diroffset2[4];
222 char totaldisks[4]; /* total number of disks 4 bytes */
224
225typedef struct _phar_zip_dir_end {
226 char signature[4]; /* end of central dir signature 4 bytes (0x06054b50) */
227 char disknumber[2]; /* number of this disk 2 bytes */
228 char centraldisk[2]; /* number of the disk with the
229 start of the central directory 2 bytes */
230 char counthere[2]; /* total number of entries in the
231 central directory on this disk 2 bytes */
232 char count[2]; /* total number of entries in
233 the central directory 2 bytes */
234 char cdir_size[4]; /* size of the central directory 4 bytes */
235 char cdir_offset[4]; /* offset of start of central
236 directory with respect to
237 the starting disk number 4 bytes */
238 char comment_len[2]; /* .ZIP file comment length 2 bytes */
239/* .ZIP file comment (variable size) */
struct _phar_zip_dir_end phar_zip_dir_end
struct _phar_zip_central_dir_file phar_zip_central_dir_file
struct _phar_zip_extra_field_header phar_zip_extra_field_header
struct _phar_zip_unix3 phar_zip_unix3
struct _phar_zip_file_header phar_zip_file_header
struct _phar_zip_unix_time phar_zip_unix_time
struct _phar_zip_file_datadesc_zip64 phar_zip_data_desc_zip64
struct _phar_zip_file_datadesc phar_zip_data_desc
struct _phar_zip64_dir_locator phar_zip64_dir_locator
struct _phar_zip64_dir_end phar_zip64_dir_end
struct _phar_zip_dir_signature phar_zip_dir_signature
struct _phar_zip_archive_extra_data_record phar_zip_archive_extra_data_record
char entriestotal1[4]
Definition pharzip.h:200
char entriestotal2[4]
Definition pharzip.h:202
char extractneeded[2]
Definition pharzip.h:193
char signature[4]
Definition pharzip.h:226
char disknumber[2]
Definition pharzip.h:227
char comment_len[2]
Definition pharzip.h:238
char counthere[2]
Definition pharzip.h:230
char centraldisk[2]
Definition pharzip.h:228
char cdir_offset[4]
Definition pharzip.h:235
char cdir_size[4]
Definition pharzip.h:234
char size[2]
Definition pharzip.h:140
char gid[2]
Definition pharzip.h:145
char perms[2]
Definition pharzip.h:142
char symlinksize[4]
Definition pharzip.h:143
char crc32[4]
Definition pharzip.h:141
char uid[2]
Definition pharzip.h:144
char tag[2]
Definition pharzip.h:139
phar_zip_extra_field_header header
Definition pharzip.h:151