xref: /PHP-5.6/ext/zip/php_zip.h (revision d20f1d8f)
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 
19 
20 #ifndef PHP_ZIP_H
21 #define PHP_ZIP_H
22 
23 extern zend_module_entry zip_module_entry;
24 #define phpext_zip_ptr &zip_module_entry
25 
26 #ifdef ZTS
27 #include "TSRM.h"
28 #endif
29 
30 #if defined(HAVE_LIBZIP)
31 #include <zip.h>
32 #else
33 #include "lib/zip.h"
34 #endif
35 
36 #ifndef ZIP_OVERWRITE
37 #define ZIP_OVERWRITE ZIP_TRUNCATE
38 #endif
39 
40 #define PHP_ZIP_VERSION "1.12.5"
41 
42 #if ((PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 2) || PHP_MAJOR_VERSION >= 6)
43 # define PHP_ZIP_USE_OO 1
44 #endif
45 
46 #ifndef  Z_SET_REFCOUNT_P
47 # if PHP_MAJOR_VERSION < 6 && (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 3)
48 #  define Z_SET_REFCOUNT_P(pz, rc)  pz->refcount = rc
49 #  define Z_UNSET_ISREF_P(pz) pz->is_ref = 0
50 # endif
51 #endif
52 
53 /* {{{ ZIP_OPENBASEDIR_CHECKPATH(filename) */
54 #if PHP_API_VERSION < 20100412
55 # define ZIP_OPENBASEDIR_CHECKPATH(filename) \
56 	(PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(filename TSRMLS_CC)
57 #else
58 #define ZIP_OPENBASEDIR_CHECKPATH(filename) \
59 	php_check_open_basedir(filename TSRMLS_CC)
60 #endif
61 /* }}} */
62 
63 typedef struct _ze_zip_rsrc {
64 	struct zip *za;
65 	int index_current;
66 	int num_files;
67 } zip_rsrc;
68 
69 typedef zip_rsrc * zip_rsrc_ptr;
70 
71 typedef struct _ze_zip_read_rsrc {
72 	struct zip_file *zf;
73 	struct zip_stat sb;
74 } zip_read_rsrc;
75 
76 #ifdef PHP_ZIP_USE_OO
77 #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 },
78 #define ZIPARCHIVE_METHOD(name)	ZEND_NAMED_FUNCTION(c_ziparchive_ ##name)
79 
80 
81 /* Extends zend object */
82 typedef struct _ze_zip_object {
83 	zend_object zo;
84 	struct zip *za;
85 	int buffers_cnt;
86 	char **buffers;
87 	HashTable *prop_handler;
88 	char *filename;
89 	int filename_len;
90 } ze_zip_object;
91 
92 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);
93 php_stream *php_stream_zip_open(const char *filename, const char *path, const char *mode STREAMS_DC TSRMLS_DC);
94 
95 extern php_stream_wrapper php_stream_zip_wrapper;
96 #endif
97 
98 #endif	/* PHP_ZIP_H */
99 
100 /*
101  * Local variables:
102  * tab-width: 4
103  * c-basic-offset: 4
104  * End:
105  * vim600: noet sw=4 ts=4 fdm=marker
106  * vim<600: noet sw=4 ts=4
107  */
108