xref: /PHP-5.6/ext/phar/tar.h (revision 49493a2d)
1 #ifndef __PHAR_TAR_H
2 #define __PHAR_TAR_H
3 /*
4   +----------------------------------------------------------------------+
5   | TAR archive support for Phar                                         |
6   +----------------------------------------------------------------------+
7   | Copyright (c) 2005-2016 The PHP Group                                |
8   +----------------------------------------------------------------------+
9   | This source file is subject to version 3.01 of the PHP license,      |
10   | that is bundled with this package in the file LICENSE, and is        |
11   | available through the world-wide-web at the following url:           |
12   | http://www.php.net/license/3_01.txt.                                 |
13   | If you did not receive a copy of the PHP license and are unable to   |
14   | obtain it through the world-wide-web, please send a note to          |
15   | license@php.net so we can mail you a copy immediately.               |
16   +----------------------------------------------------------------------+
17   | Authors: Dmitry Stogov <dmitry@zend.com>                             |
18   |          Gregory Beaver <cellog@php.net>                             |
19   +----------------------------------------------------------------------+
20 */
21 
22 #ifdef PHP_WIN32
23 #pragma pack(1)
24 # define PHAR_TAR_PACK
25 #elif defined(__sgi)
26 # define PHAR_TAR_PACK
27 #elif defined(__GNUC__)
28 # define PHAR_TAR_PACK __attribute__((__packed__))
29 #else
30 # define PHAR_TAR_PACK
31 #endif
32 
33 #if defined(__sgi)
34 # pragma pack 0
35 #endif
36 /**
37  * the format of the header block for a file, in the older UNIX-compatible
38  * TAR format
39  */
40 typedef struct _old_tar_header {  /* {{{ */
41 	char name[100];     /* name of file;
42 	                         directory is indicated by a trailing slash (/) */
43 	char mode[8];       /* file mode */
44 	char uid[8];        /* owner user ID */
45 	char gid[8];        /* owner group ID */
46 	char size[12];      /* length of file in bytes */
47 	char mtime[12];     /* modify time of file */
48 	char checksum[8];   /* checksum for header */
49 	char link;          /* indicator for links;
50 	                         1 for a linked file,
51 	                         2 for a symbolic link,
52 	                         0 otherwise */
53 	char linkname[100]; /* name of linked file */
54 } PHAR_TAR_PACK old_tar_header;
55 /* }}} */
56 
57 #if defined(__sgi)
58 # pragma pack 0
59 #endif
60 /**
61  * the new USTAR header format.
62  * Note that tar can determine that the USTAR format is being used by the
63  * presence of the null-terminated string "ustar" in the magic field.
64  */
65 typedef struct _tar_header {  /* {{{ */
66 	char name[100];     /* name of file */
67 	char mode[8];       /* file mode   */
68 	char uid[8];        /* owner user ID */
69 	char gid[8];        /* owner group ID */
70 	char size[12];      /* length of file in bytes */
71 	char mtime[12];     /* modify time of file */
72 	char checksum[8];   /* checksum for header */
73 	char typeflag;      /* type of file
74 	                         0 Regular file
75 	                         1 Link to another file already archived
76 	                         2 Symbolic link
77 	                         3 Character special device
78 	                         4 Block special device
79 	                         5 Directory
80 	                         6 FIFO special file
81 	                         7 Reserved */
82 	char linkname[100]; /* name of linked file */
83 	char magic[6];      /* USTAR indicator */
84 	char version[2];    /* USTAR version */
85 	char uname[32];     /* owner user name */
86 	char gname[32];     /* owner group name */
87 	char devmajor[8];   /* device major number */
88 	char devminor[8];   /* device minor number */
89 	char prefix[155];   /* prefix for file name;
90 	                       the value of the prefix field, if non-null,
91 	                       is prefixed to the name field to allow names
92 	                       longer then 100 characters */
93 	char padding[12];   /* unused zeroed bytes */
94 } PHAR_TAR_PACK tar_header;
95 /* }}} */
96 
97 #ifdef PHP_WIN32
98 #pragma pack()
99 #endif
100 
101 #endif /* __PHAR_TAR_H */
102