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