php_zip.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. +----------------------------------------------------------------------+
  3. | Copyright (c) The PHP Group |
  4. +----------------------------------------------------------------------+
  5. | This source file is subject to version 3.01 of the PHP license, |
  6. | that is bundled with this package in the file LICENSE, and is |
  7. | available through the world-wide-web at the following url: |
  8. | https://www.php.net/license/3_01.txt |
  9. | If you did not receive a copy of the PHP license and are unable to |
  10. | obtain it through the world-wide-web, please send a note to |
  11. | license@php.net so we can mail you a copy immediately. |
  12. +----------------------------------------------------------------------+
  13. | Author: Pierre-Alain Joye <pajoye@php.net> |
  14. +----------------------------------------------------------------------+
  15. */
  16. #ifndef PHP_ZIP_H
  17. #define PHP_ZIP_H
  18. extern zend_module_entry zip_module_entry;
  19. #define phpext_zip_ptr &zip_module_entry
  20. #ifdef ZTS
  21. #include "TSRM.h"
  22. #endif
  23. #include <zip.h>
  24. #ifndef ZIP_OVERWRITE
  25. #define ZIP_OVERWRITE ZIP_TRUNCATE
  26. #endif
  27. #define PHP_ZIP_VERSION "1.19.5"
  28. #define ZIP_OPENBASEDIR_CHECKPATH(filename) php_check_open_basedir(filename)
  29. typedef struct _ze_zip_rsrc {
  30. struct zip *za;
  31. zip_uint64_t index_current;
  32. zip_int64_t num_files;
  33. } zip_rsrc;
  34. typedef zip_rsrc * zip_rsrc_ptr;
  35. typedef struct _ze_zip_read_rsrc {
  36. struct zip_file *zf;
  37. struct zip_stat sb;
  38. } zip_read_rsrc;
  39. /* Extends zend object */
  40. typedef struct _ze_zip_object {
  41. struct zip *za;
  42. char **buffers;
  43. HashTable *prop_handler;
  44. char *filename;
  45. int filename_len;
  46. int buffers_cnt;
  47. zip_int64_t last_id;
  48. int err_zip;
  49. int err_sys;
  50. #ifdef HAVE_PROGRESS_CALLBACK
  51. zval progress_callback;
  52. #endif
  53. #ifdef HAVE_CANCEL_CALLBACK
  54. zval cancel_callback;
  55. #endif
  56. zend_object zo;
  57. } ze_zip_object;
  58. static inline ze_zip_object *php_zip_fetch_object(zend_object *obj) {
  59. return (ze_zip_object *)((char*)(obj) - XtOffsetOf(ze_zip_object, zo));
  60. }
  61. #define Z_ZIP_P(zv) php_zip_fetch_object(Z_OBJ_P((zv)))
  62. php_stream *php_stream_zip_opener(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC);
  63. php_stream *php_stream_zip_open(struct zip *arch, const char *path, const char *mode STREAMS_DC);
  64. extern const php_stream_wrapper php_stream_zip_wrapper;
  65. #endif /* PHP_ZIP_H */