1 /*
2 +----------------------------------------------------------------------+
3 | PHP Version 7 |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 1997-2018 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.15.4"
41
42 #define ZIP_OPENBASEDIR_CHECKPATH(filename) php_check_open_basedir(filename)
43
44 typedef struct _ze_zip_rsrc {
45 struct zip *za;
46 int index_current;
47 int num_files;
48 } zip_rsrc;
49
50 typedef zip_rsrc * zip_rsrc_ptr;
51
52 typedef struct _ze_zip_read_rsrc {
53 struct zip_file *zf;
54 struct zip_stat sb;
55 } zip_read_rsrc;
56
57 #define ZIPARCHIVE_ME(name, arg_info, flags) {#name, c_ziparchive_ ##name, arg_info,(uint32_t) (sizeof(arg_info)/sizeof(struct _zend_arg_info)-1), flags },
58 #define ZIPARCHIVE_METHOD(name) ZEND_NAMED_FUNCTION(c_ziparchive_ ##name)
59
60 /* Extends zend object */
61 typedef struct _ze_zip_object {
62 struct zip *za;
63 char **buffers;
64 HashTable *prop_handler;
65 char *filename;
66 int filename_len;
67 int buffers_cnt;
68 zend_object zo;
69 } ze_zip_object;
70
php_zip_fetch_object(zend_object * obj)71 static inline ze_zip_object *php_zip_fetch_object(zend_object *obj) {
72 return (ze_zip_object *)((char*)(obj) - XtOffsetOf(ze_zip_object, zo));
73 }
74
75 #define Z_ZIP_P(zv) php_zip_fetch_object(Z_OBJ_P((zv)))
76
77 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);
78 php_stream *php_stream_zip_open(const char *filename, const char *path, const char *mode STREAMS_DC);
79
80 extern const php_stream_wrapper php_stream_zip_wrapper;
81
82 #endif /* PHP_ZIP_H */
83
84 /*
85 * Local variables:
86 * tab-width: 4
87 * c-basic-offset: 4
88 * End:
89 * vim600: noet sw=4 ts=4 fdm=marker
90 * vim<600: noet sw=4 ts=4
91 */
92