1 /*
2 +----------------------------------------------------------------------+
3 | PHP Version 7 |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 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 #include <zip.h>
31
32 #ifndef ZIP_OVERWRITE
33 #define ZIP_OVERWRITE ZIP_TRUNCATE
34 #endif
35
36 #define PHP_ZIP_VERSION "1.15.6"
37
38 #define ZIP_OPENBASEDIR_CHECKPATH(filename) php_check_open_basedir(filename)
39
40 typedef struct _ze_zip_rsrc {
41 struct zip *za;
42 zip_uint64_t index_current;
43 zip_int64_t num_files;
44 } zip_rsrc;
45
46 typedef zip_rsrc * zip_rsrc_ptr;
47
48 typedef struct _ze_zip_read_rsrc {
49 struct zip_file *zf;
50 struct zip_stat sb;
51 } zip_read_rsrc;
52
53 #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 },
54 #define ZIPARCHIVE_METHOD(name) ZEND_NAMED_FUNCTION(c_ziparchive_ ##name)
55
56 /* Extends zend object */
57 typedef struct _ze_zip_object {
58 struct zip *za;
59 char **buffers;
60 HashTable *prop_handler;
61 char *filename;
62 int filename_len;
63 int buffers_cnt;
64 zend_object zo;
65 } ze_zip_object;
66
php_zip_fetch_object(zend_object * obj)67 static inline ze_zip_object *php_zip_fetch_object(zend_object *obj) {
68 return (ze_zip_object *)((char*)(obj) - XtOffsetOf(ze_zip_object, zo));
69 }
70
71 #define Z_ZIP_P(zv) php_zip_fetch_object(Z_OBJ_P((zv)))
72
73 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);
74 php_stream *php_stream_zip_open(const char *filename, const char *path, const char *mode STREAMS_DC);
75
76 extern const php_stream_wrapper php_stream_zip_wrapper;
77
78 #endif /* PHP_ZIP_H */
79