php_zip.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2016 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. | http://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. | Author: Pierre-Alain Joye <pajoye@php.net> |
  16. +----------------------------------------------------------------------+
  17. */
  18. #ifndef PHP_ZIP_H
  19. #define PHP_ZIP_H
  20. extern zend_module_entry zip_module_entry;
  21. #define phpext_zip_ptr &zip_module_entry
  22. #ifdef ZTS
  23. #include "TSRM.h"
  24. #endif
  25. #if defined(HAVE_LIBZIP)
  26. #include <zip.h>
  27. #else
  28. #include "lib/zip.h"
  29. #endif
  30. #ifndef ZIP_OVERWRITE
  31. #define ZIP_OVERWRITE ZIP_TRUNCATE
  32. #endif
  33. #define PHP_ZIP_VERSION "1.12.5"
  34. #if ((PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 2) || PHP_MAJOR_VERSION >= 6)
  35. # define PHP_ZIP_USE_OO 1
  36. #endif
  37. #ifndef Z_SET_REFCOUNT_P
  38. # if PHP_MAJOR_VERSION < 6 && (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 3)
  39. # define Z_SET_REFCOUNT_P(pz, rc) pz->refcount = rc
  40. # define Z_UNSET_ISREF_P(pz) pz->is_ref = 0
  41. # endif
  42. #endif
  43. /* {{{ ZIP_OPENBASEDIR_CHECKPATH(filename) */
  44. #if PHP_API_VERSION < 20100412
  45. # define ZIP_OPENBASEDIR_CHECKPATH(filename) \
  46. (PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(filename TSRMLS_CC)
  47. #else
  48. #define ZIP_OPENBASEDIR_CHECKPATH(filename) \
  49. php_check_open_basedir(filename TSRMLS_CC)
  50. #endif
  51. /* }}} */
  52. typedef struct _ze_zip_rsrc {
  53. struct zip *za;
  54. int index_current;
  55. int num_files;
  56. } zip_rsrc;
  57. typedef zip_rsrc * zip_rsrc_ptr;
  58. typedef struct _ze_zip_read_rsrc {
  59. struct zip_file *zf;
  60. struct zip_stat sb;
  61. } zip_read_rsrc;
  62. #ifdef PHP_ZIP_USE_OO
  63. #define ZIPARCHIVE_ME(name, arg_info, flags) {#name, c_ziparchive_ ##name, arg_info,(zend_uint) (sizeof(arg_info)/sizeof(struct _zend_arg_info)-1), flags },
  64. #define ZIPARCHIVE_METHOD(name) ZEND_NAMED_FUNCTION(c_ziparchive_ ##name)
  65. /* Extends zend object */
  66. typedef struct _ze_zip_object {
  67. zend_object zo;
  68. struct zip *za;
  69. int buffers_cnt;
  70. char **buffers;
  71. HashTable *prop_handler;
  72. char *filename;
  73. int filename_len;
  74. } ze_zip_object;
  75. php_stream *php_stream_zip_opener(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
  76. php_stream *php_stream_zip_open(const char *filename, const char *path, const char *mode STREAMS_DC TSRMLS_DC);
  77. extern php_stream_wrapper php_stream_zip_wrapper;
  78. #endif
  79. #endif /* PHP_ZIP_H */
  80. /*
  81. * Local variables:
  82. * tab-width: 4
  83. * c-basic-offset: 4
  84. * End:
  85. * vim600: noet sw=4 ts=4 fdm=marker
  86. * vim<600: noet sw=4 ts=4
  87. */