tar.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #ifndef __PHAR_TAR_H
  2. #define __PHAR_TAR_H
  3. /*
  4. +----------------------------------------------------------------------+
  5. | TAR archive support for Phar |
  6. +----------------------------------------------------------------------+
  7. | Copyright (c) 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. | https://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@php.net> |
  18. | Gregory Beaver <cellog@php.net> |
  19. +----------------------------------------------------------------------+
  20. */
  21. #ifdef PHP_WIN32
  22. #pragma pack(1)
  23. # define PHAR_TAR_PACK
  24. #elif defined(__sgi)
  25. # define PHAR_TAR_PACK
  26. #elif defined(__GNUC__)
  27. # define PHAR_TAR_PACK __attribute__((__packed__))
  28. #else
  29. # define PHAR_TAR_PACK
  30. #endif
  31. #if defined(__sgi)
  32. # pragma pack 0
  33. #endif
  34. /**
  35. * the format of the header block for a file, in the older UNIX-compatible
  36. * TAR format
  37. */
  38. typedef struct _old_tar_header { /* {{{ */
  39. char name[100]; /* name of file;
  40. directory is indicated by a trailing slash (/) */
  41. char mode[8]; /* file mode */
  42. char uid[8]; /* owner user ID */
  43. char gid[8]; /* owner group ID */
  44. char size[12]; /* length of file in bytes */
  45. char mtime[12]; /* modify time of file */
  46. char checksum[8]; /* checksum for header */
  47. char link; /* indicator for links;
  48. 1 for a linked file,
  49. 2 for a symbolic link,
  50. 0 otherwise */
  51. char linkname[100]; /* name of linked file */
  52. } PHAR_TAR_PACK old_tar_header;
  53. /* }}} */
  54. #if defined(__sgi)
  55. # pragma pack 0
  56. #endif
  57. /**
  58. * the new USTAR header format.
  59. * Note that tar can determine that the USTAR format is being used by the
  60. * presence of the null-terminated string "ustar" in the magic field.
  61. */
  62. typedef struct _tar_header { /* {{{ */
  63. char name[100]; /* name of file */
  64. char mode[8]; /* file mode */
  65. char uid[8]; /* owner user ID */
  66. char gid[8]; /* owner group ID */
  67. char size[12]; /* length of file in bytes */
  68. char mtime[12]; /* modify time of file */
  69. char checksum[8]; /* checksum for header */
  70. char typeflag; /* type of file
  71. 0 Regular file
  72. 1 Link to another file already archived
  73. 2 Symbolic link
  74. 3 Character special device
  75. 4 Block special device
  76. 5 Directory
  77. 6 FIFO special file
  78. 7 Reserved */
  79. char linkname[100]; /* name of linked file */
  80. char magic[6]; /* USTAR indicator */
  81. char version[2]; /* USTAR version */
  82. char uname[32]; /* owner user name */
  83. char gname[32]; /* owner group name */
  84. char devmajor[8]; /* device major number */
  85. char devminor[8]; /* device minor number */
  86. char prefix[155]; /* prefix for file name;
  87. the value of the prefix field, if non-null,
  88. is prefixed to the name field to allow names
  89. longer then 100 characters */
  90. char padding[12]; /* unused zeroed bytes */
  91. } PHAR_TAR_PACK tar_header;
  92. /* }}} */
  93. #ifdef PHP_WIN32
  94. #pragma pack()
  95. #endif
  96. #endif /* __PHAR_TAR_H */