]> git.pld-linux.org Git - packages/php-pecl-archive.git/blame - branch.diff
up to 0.3.1 via branch.diff
[packages/php-pecl-archive.git] / branch.diff
CommitLineData
cfbe30dd
ER
1diff --git a/API.txt b/API.txt
2index b2c690e..6895062 100644
3--- a/API.txt
4+++ b/API.txt
5@@ -31,7 +31,8 @@ Classes:
6
7 class ArchiveReader {
8 /**
9- * ArchiveReader __construct (string filename[, int format[, int compression]])
10+ * ArchiveReader __construct (string filename[, int format[, int
11+ * compression [, int block_size]]])
12 *
13 * You need to specify format & compression params *only* if you need
14 * to support only these particular formats/compressions.
15diff --git a/archive.c b/archive.c
16index 045adfc..6239edd 100644
17--- a/archive.c
18+++ b/archive.c
19@@ -12,7 +12,7 @@
20 | obtain it through the world-wide-web, please send a note to |
21 | license@php.net so we can mail you a copy immediately. |
22 +----------------------------------------------------------------------+
23- | Author: Antony Dovgal <antony@zend.com> |
24+ | Author: Antony Dovgal <tony2001@php.net> |
25 +----------------------------------------------------------------------+
26 */
27
28@@ -33,11 +33,15 @@
29 #include "archive_clbk.h"
30 #include "php_archive_entry.h"
31
32+#if (PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 2)
33 #define archive_ce_Exception zend_exception_get_default()
34+#else
35+#define archive_ce_Exception zend_exception_get_default(TSRMLS_C)
36+#endif
37
38 /* {{{ archive_functions[]
39 */
40-function_entry archive_functions[] = {
41+zend_function_entry archive_functions[] = {
42 {NULL, NULL, NULL}
43 };
44 /* }}} */
45@@ -56,7 +60,7 @@ zend_module_entry archive_module_entry = {
46 NULL, /* here */
47 PHP_MINFO(archive),
48 #if ZEND_MODULE_API_NO >= 20010901
49- "0.1",
50+ PHP_ARCHIVE_VERSION,
51 #endif
52 STANDARD_MODULE_PROPERTIES
53 };
54@@ -65,9 +69,9 @@ zend_module_entry archive_module_entry = {
55 #ifdef COMPILE_DL_ARCHIVE
56 ZEND_GET_MODULE(archive)
57 #endif
58-
59+
60 static void _archive_desc_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC);
61-
62+
63 /* {{{ _archive_entries_hash_dtor
64 */
65 void _archive_entries_hash_dtor(void *data)
66@@ -83,20 +87,20 @@ void _archive_entries_hash_dtor(void *data)
67 */
68 static void _archive_desc_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
69 {
70- archive_file_t *arch = (archive_file_t *)rsrc->ptr;
71+ archive_file_t *arch = (archive_file_t *)rsrc->ptr;
72
73 if (arch->mode == PHP_ARCHIVE_READ_MODE) {
74- archive_read_finish(arch->arch);
75+ archive_read_free(arch->arch);
76 }
77 else if (arch->mode == PHP_ARCHIVE_WRITE_MODE) {
78 archive_write_close(arch->arch);
79- archive_write_finish(arch->arch);
80+ archive_write_free(arch->arch);
81 }
82-
83+
84 if (arch->stream) {
85 php_stream_close(arch->stream);
86 }
87-
88+
89 if (arch->filename) {
90 efree(arch->filename);
91 }
92@@ -116,12 +120,12 @@ static void _archive_desc_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
93 int _archive_get_rsrc_id(zval *this TSRMLS_DC)
94 {
95 zval **prop;
96-
97- if (zend_hash_find(Z_OBJPROP_P(this), "fd", sizeof("fd"), (void **)&prop) == FAILURE) {
98- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find archive file descriptor");
99- return 0;
100- }
101-
102+
103+ if (zend_hash_find(Z_OBJPROP_P(this), "fd", sizeof("fd"), (void **)&prop) == FAILURE) {
104+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find archive file descriptor");
105+ return 0;
106+ }
107+
108 return Z_LVAL_PP(prop);
109 }
110 /* }}} */
111@@ -131,7 +135,7 @@ int _archive_get_rsrc_id(zval *this TSRMLS_DC)
112 int _archive_get_fd(zval *this, archive_file_t **arch TSRMLS_DC)
113 {
114 int resource_id, type;
115-
116+
117
118 if ((resource_id = _archive_get_rsrc_id(this TSRMLS_CC))) {
119 *arch = (archive_file_t *) zend_list_find(resource_id, &type);
120@@ -149,12 +153,12 @@ int _archive_get_fd(zval *this, archive_file_t **arch TSRMLS_DC)
121 PHP_MINIT_FUNCTION(archive)
122 {
123 zend_class_entry tmp_ce_ArchiveException;
124-
125+
126 le_archive = zend_register_list_destructors_ex(_archive_desc_dtor, NULL, "archive descriptor", module_number);
127-
128+
129 INIT_CLASS_ENTRY(tmp_ce_ArchiveException, "ArchiveException", NULL);
130 ce_ArchiveException = zend_register_internal_class_ex(&tmp_ce_ArchiveException, archive_ce_Exception, NULL TSRMLS_CC);
131-
132+
133 PHP_MINIT(archive_entry)(INIT_FUNC_ARGS_PASSTHRU);
134 PHP_MINIT(archive_reader)(INIT_FUNC_ARGS_PASSTHRU);
135
136@@ -174,7 +178,7 @@ PHP_MINIT_FUNCTION(archive)
137 #endif
138 REGISTER_LONG_CONSTANT("ARCH_COMPRESSION_COMPRESS", PHP_ARCHIVE_COMPRESSION_COMPRESS, CONST_CS | CONST_PERSISTENT);
139 REGISTER_LONG_CONSTANT("ARCH_COMPRESSION_NONE", PHP_ARCHIVE_COMPRESSION_NONE, CONST_CS | CONST_PERSISTENT);
140-
141+
142 return SUCCESS;
143 }
144 /* }}} */
145@@ -185,7 +189,8 @@ PHP_MINFO_FUNCTION(archive)
146 {
147 php_info_print_table_start();
148 php_info_print_table_header(2, "archive support", "enabled");
149- php_info_print_table_row(2, "libarchive version", archive_version());
150+ php_info_print_table_row(2, "extension version", PHP_ARCHIVE_VERSION);
151+ php_info_print_table_row(2, "libarchive version", archive_version());
152 php_info_print_table_end();
153 }
154 /* }}} */
155diff --git a/archive_clbk.c b/archive_clbk.c
156index 3034e0a..3b09d8b 100644
157--- a/archive_clbk.c
158+++ b/archive_clbk.c
159@@ -12,7 +12,7 @@
160 | obtain it through the world-wide-web, please send a note to |
161 | license@php.net so we can mail you a copy immediately. |
162 +----------------------------------------------------------------------+
163- | Author: Antony Dovgal <antony@zend.com> |
164+ | Author: Antony Dovgal <tony2001@php.net> |
165 +----------------------------------------------------------------------+
166 */
167
168@@ -32,7 +32,6 @@ ssize_t _archive_read_clbk(struct archive *a, void *client_data, const void **bu
169 {
170 archive_file_t *arch = (archive_file_t *)client_data;
171 ssize_t len = 0;
172-
173 TSRMLS_FETCH();
174
175 if (arch->stream == NULL) {
176@@ -40,7 +39,7 @@ ssize_t _archive_read_clbk(struct archive *a, void *client_data, const void **bu
177 }
178
179 *buff = arch->buf;
180- if ((len = php_stream_read(arch->stream, arch->buf, PHP_ARCHIVE_BUF_LEN))) {
181+ if ((len = php_stream_read(arch->stream, arch->buf, arch->block_size))) {
182 return len;
183 }
184 return 0;
185@@ -49,11 +48,10 @@ ssize_t _archive_read_clbk(struct archive *a, void *client_data, const void **bu
186
187 /* {{{ _archive_write_clbk
188 */
189-ssize_t _archive_write_clbk(struct archive *a, void *client_data, void *buff, size_t buf_len)
190+ssize_t _archive_write_clbk(struct archive *a, void *client_data, const void *buff, size_t buf_len)
191 {
192 archive_file_t *arch = (archive_file_t *)client_data;
193 ssize_t len;
194-
195 TSRMLS_FETCH();
196
197 if (arch->stream == NULL) {
198@@ -67,12 +65,58 @@ ssize_t _archive_write_clbk(struct archive *a, void *client_data, void *buff, si
199 }
200 /* }}} */
201
202+/* {{{ _archive_skip_clbk
203+ * */
204+off_t _archive_skip_clbk(struct archive *a, void *client_data, off_t request)
205+{
206+ archive_file_t *arch = (archive_file_t *)client_data;
207+ off_t size;
208+ int r;
209+ TSRMLS_FETCH();
210+
211+ if(request == 0) {
212+ return 0;
213+ }
214+
215+ if(arch->stream){
216+ size = (request/arch->block_size) * arch->block_size;
217+ if(size == 0){ /*do not break a block*/
218+ return 0;
219+ }
220+ /*TODO maybe lasy seek is a better idea for performance
221+ * refer: libarchive archive_read_open_filename.c file_skip_lseek
222+ * */
223+ r = php_stream_seek(arch->stream, size, SEEK_CUR);
224+ if(r < 0){
225+ return 0;
226+ }
227+ return size;
228+ }
229+ return 0;
230+}
231+/*}}}*/
232+
233+/* {{{ _archive_seek_clbk
234+ * */
235+ssize_t _archive_seek_clbk(struct archive *a, void *client_data, off_t offset, int whence)
236+{
237+ int r;
238+ archive_file_t *arch = (archive_file_t *)client_data;
239+ TSRMLS_FETCH();
240+
241+ r = php_stream_seek(arch->stream, offset, whence);
242+ if(r == 0){
243+
244+ return php_stream_tell(arch->stream);
245+ }
246+ return r;
247+}/*}}}*/
248+
249 /* {{{ _archive_open_clbk
250 */
251 int _archive_open_clbk(struct archive *a, void *client_data)
252 {
253 archive_file_t *arch = (archive_file_t *)client_data;
254-
255 TSRMLS_FETCH();
256
257 if (arch->mode == PHP_ARCHIVE_WRITE_MODE) {
258@@ -80,8 +124,17 @@ int _archive_open_clbk(struct archive *a, void *client_data)
259 } else if (arch->mode == PHP_ARCHIVE_READ_MODE) {
260 arch->stream = php_stream_open_wrapper_ex(arch->filename, "r", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL, NULL);
261 }
262-
263+
264 if (arch->stream) {
265+ /* Use libarchive to manage buffer
266+ * here we set non-buffer of php stream
267+ * */
268+ arch->stream->flags |= PHP_STREAM_FLAG_NO_BUFFER;
269+ if((arch->stream->flags & PHP_STREAM_FLAG_NO_SEEK) == 0){
270+ archive_read_set_skip_callback(arch->arch, _archive_skip_clbk);
271+ /*TODO it is usually not a good idea to support seek
272+ * archive_read_set_seek_callback(arch->arch, _archive_seek_clbk);*/
273+ }
274 return 0;
275 }
276 return 1;
277@@ -93,7 +146,6 @@ int _archive_open_clbk(struct archive *a, void *client_data)
278 int _archive_close_clbk(struct archive *a, void *client_data)
279 {
280 archive_file_t *arch = (archive_file_t *)client_data;
281-
282 TSRMLS_FETCH();
283
284 if (arch->stream) {
285diff --git a/archive_clbk.h b/archive_clbk.h
286index 6196a29..626a5ad 100644
287--- a/archive_clbk.h
288+++ b/archive_clbk.h
289@@ -12,7 +12,7 @@
290 | obtain it through the world-wide-web, please send a note to |
291 | license@php.net so we can mail you a copy immediately. |
292 +----------------------------------------------------------------------+
293- | Author: Antony Dovgal <antony@zend.com> |
294+ | Author: Antony Dovgal <tony2001@php.net> |
295 +----------------------------------------------------------------------+
296 */
297
298@@ -24,7 +24,9 @@
299 ssize_t _archive_read_clbk(struct archive *, void *, const void **);
300 int _archive_open_clbk(struct archive *, void *);
301 int _archive_close_clbk(struct archive *, void *);
302-ssize_t _archive_write_clbk(struct archive *, void *, void *, size_t);
303+off_t _archive_skip_clbk(struct archive *, void *, off_t);
304+ssize_t _archive_seek_clbk(struct archive *, void *, off_t, int);
305+ssize_t _archive_write_clbk(struct archive *, void *, const void *, size_t);
306
307 #endif /* ARCHIVE_CLBK_H */
308
309diff --git a/archive_entry.c b/archive_entry.c
310index 2cc511b..df9c657 100644
311--- a/archive_entry.c
312+++ b/archive_entry.c
313@@ -12,7 +12,7 @@
314 | obtain it through the world-wide-web, please send a note to |
315 | license@php.net so we can mail you a copy immediately. |
316 +----------------------------------------------------------------------+
317- | Author: Antony Dovgal <antony@zend.com> |
318+ | Author: Antony Dovgal <tony2001@php.net> |
319 +----------------------------------------------------------------------+
320 */
321
322@@ -29,8 +29,8 @@
323 #include "php_archive.h"
324 #include "php_archive_entry.h"
325
326-/* function_entry funcs_ArchiveEntry {{{ */
327-function_entry funcs_ArchiveEntry[] = {
328+/* zend_function_entry funcs_ArchiveEntry {{{ */
329+zend_function_entry funcs_ArchiveEntry[] = {
330 ZEND_ME(ArchiveEntry, __construct, NULL, 0)
331 ZEND_ME(ArchiveEntry, isDir, NULL, 0)
332 ZEND_ME(ArchiveEntry, isFile, NULL, 0)
333@@ -50,12 +50,13 @@ function_entry funcs_ArchiveEntry[] = {
334 static void _archive_entry_desc_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC);
335
336 #define PHP_ENTRY_GET_STRUCT \
337- php_set_error_handling(EH_THROW, ce_ArchiveException TSRMLS_CC); \
338+ zend_error_handling error_handling; \
339+ zend_replace_error_handling(EH_THROW, ce_ArchiveException, &error_handling TSRMLS_CC); \
340 if(!_archive_get_entry_struct(this, &entry TSRMLS_CC)) { \
341- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC); \
342+ zend_restore_error_handling(&error_handling TSRMLS_CC); \
343 return; \
344 } \
345- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
346+ zend_restore_error_handling(&error_handling TSRMLS_CC);
347
348 /* {{{ _archive_entry_desc_dtor
349 */
350@@ -98,10 +99,10 @@ int _archive_get_entry_rsrc_id(zval *this TSRMLS_DC)
351 {
352 zval **prop;
353
354- if (zend_hash_find(Z_OBJPROP_P(this), "entry", sizeof("entry"), (void **)&prop) == FAILURE) {
355- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find entry descriptor");
356- return 0;
357- }
358+ if (zend_hash_find(Z_OBJPROP_P(this), "entry", sizeof("entry"), (void **)&prop) == FAILURE) {
359+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find entry descriptor");
360+ return 0;
361+ }
362
363 return Z_LVAL_PP(prop);
364 }
365@@ -149,27 +150,30 @@ ZEND_METHOD(ArchiveEntry, __construct)
366 archive_entry_t *entry;
367 struct stat *stat_sb;
368 php_stream_statbuf ssb;
369-
370- php_set_error_handling(EH_THROW, ce_ArchiveException TSRMLS_CC);
371+ zend_error_handling error_handling;
372+
373+ zend_replace_error_handling(EH_THROW, ce_ArchiveException, &error_handling TSRMLS_CC);
374
375 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
376- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
377+ zend_restore_error_handling(&error_handling TSRMLS_CC);
378 return;
379 }
380
381+#if PHP_API_VERSION < 20100412
382 if (PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
383- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
384+ zend_restore_error_handling(&error_handling TSRMLS_CC);
385 return;
386 }
387-
388+#endif
389+
390 if (php_check_open_basedir(filename TSRMLS_CC)) {
391- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
392+ zend_restore_error_handling(&error_handling TSRMLS_CC);
393 return;
394 }
395-
396+
397 if (php_stream_stat_path_ex((char *)filename, PHP_STREAM_URL_STAT_LINK, &ssb, NULL)) {
398 php_error_docref(NULL TSRMLS_CC, E_WARNING, "stat failed for %s", filename);
399- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
400+ zend_restore_error_handling(&error_handling TSRMLS_CC);
401 return;
402 }
403
404@@ -177,18 +181,18 @@ ZEND_METHOD(ArchiveEntry, __construct)
405
406 entry = (archive_entry_t *) emalloc(sizeof(archive_entry_t));
407 entry->resolved_filename = NULL;
408-
409+
410 #if (!defined(__BEOS__) && !defined(NETWARE) && HAVE_REALPATH) || defined(ZTS)
411 if (S_ISLNK(stat_sb->st_mode)) {
412 char resolved_path_buff[MAXPATHLEN];
413
414 if (VCWD_REALPATH(filename, resolved_path_buff)) {
415-/* TODO figure out if we need this check */
416+ /* TODO figure out if we need this check */
417 #if 0 && defined(ZTS)
418 if (VCWD_ACCESS(resolved_path_buff, F_OK)) {
419 efree(entry);
420 php_error_docref(NULL TSRMLS_CC, E_WARNING, "stat failed for %s", filename);
421- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
422+ zend_restore_error_handling(&error_handling TSRMLS_CC);
423 return;
424 }
425 #endif
426@@ -211,7 +215,7 @@ ZEND_METHOD(ArchiveEntry, __construct)
427 resource_id = zend_list_insert(entry,le_archive_entry);
428 add_property_resource(this, "entry", resource_id);
429
430- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
431+ zend_restore_error_handling(&error_handling TSRMLS_CC);
432 return;
433 }
434 /* }}} */
435diff --git a/archive_reader.c b/archive_reader.c
436index 0673a83..b0f070a 100644
437--- a/archive_reader.c
438+++ b/archive_reader.c
439@@ -12,7 +12,7 @@
440 | obtain it through the world-wide-web, please send a note to |
441 | license@php.net so we can mail you a copy immediately. |
442 +----------------------------------------------------------------------+
443- | Author: Antony Dovgal <antony@zend.com> |
444+ | Author: Antony Dovgal <tony2001@php.net> |
445 +----------------------------------------------------------------------+
446 */
447
448@@ -32,8 +32,8 @@
449 zend_class_entry *ce_ArchiveReader;
450 zend_class_entry *ce_ArchiveReaderInterface;
451
452-/* function_entry funcs_ArchiveReaderInterface {{{ */
453-function_entry funcs_ArchiveReaderInterface[] = {
454+/* zend_function_entry funcs_ArchiveReaderInterface {{{ */
455+zend_function_entry funcs_ArchiveReaderInterface[] = {
456 ZEND_ABSTRACT_ME(ArchiveReader, __construct, NULL)
457 ZEND_ABSTRACT_ME(ArchiveReader, getNextEntry, NULL)
458 ZEND_ABSTRACT_ME(ArchiveReader, getCurrentEntryData, NULL)
459@@ -43,8 +43,8 @@ function_entry funcs_ArchiveReaderInterface[] = {
460 };
461 /* }}} */
462
463-/* function_entry funcs_ArchiveReader {{{ */
464-function_entry funcs_ArchiveReader[] = {
465+/* zend_function_entry funcs_ArchiveReader {{{ */
466+zend_function_entry funcs_ArchiveReader[] = {
467 ZEND_ME(ArchiveReader, __construct, NULL, 0)
468 ZEND_ME(ArchiveReader, getNextEntry, NULL, 0)
469 ZEND_ME(ArchiveReader, getCurrentEntryData, NULL, 0)
470@@ -83,24 +83,30 @@ ZEND_METHOD(ArchiveReader, __construct)
471 zval *this = getThis();
472 const char *error_string = NULL;
473 char *filename;
474- int error_num, filename_len, result, format = 0, compression = 0;
475+ long error_num, filename_len, result, format = 0, compression = 0, block_size = 0;
476+ zend_error_handling error_handling;
477
478- php_set_error_handling(EH_THROW, ce_ArchiveException TSRMLS_CC);
479+ zend_replace_error_handling(EH_THROW, ce_ArchiveException, &error_handling TSRMLS_CC);
480
481- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ll", &filename, &filename_len, &format, &compression) == FAILURE) {
482- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
483+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lll", &filename, &filename_len, &format, &compression, &block_size) == FAILURE) {
484+ zend_restore_error_handling(&error_handling TSRMLS_CC);
485 return;
486 }
487-
488+#if PHP_API_VERSION < 20100412
489 if (PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
490- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
491+ zend_restore_error_handling(&error_handling TSRMLS_CC);
492 return;
493 }
494+#endif
495
496 if (php_check_open_basedir(filename TSRMLS_CC)) {
497- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
498+ zend_restore_error_handling(&error_handling TSRMLS_CC);
499 return;
500 }
501+
502+ if(block_size <= 0){
503+ block_size = PHP_ARCHIVE_BUF_LEN;
504+ }
505
506 arch = (archive_file_t *) emalloc(sizeof(archive_file_t));
507
508@@ -108,69 +114,53 @@ ZEND_METHOD(ArchiveReader, __construct)
509 arch->current_entry = NULL;
510 arch->entries = NULL;
511 arch->struct_state = ARCHIVE_OK;
512+ arch->block_size = block_size;
513 arch->mode = PHP_ARCHIVE_READ_MODE;
514- arch->buf = emalloc(PHP_ARCHIVE_BUF_LEN + 1);
515+ arch->buf = emalloc(arch->block_size + 1);
516 arch->filename = estrndup(filename, filename_len);
517 arch->arch = archive_read_new();
518
519
520- _php_archive_read_support_compression_all(arch->arch);
521-
522- if (format == 0) {
523- /* support all by default */
524- archive_read_support_format_all(arch->arch);
525- }
526- else {
527- if (format & PHP_ARCHIVE_FORMAT_TAR) {
528- archive_read_support_format_tar(arch->arch);
529- }
530-
531- if (format & PHP_ARCHIVE_FORMAT_CPIO) {
532- archive_read_support_format_cpio(arch->arch);
533- }
534- }
535+ archive_read_support_filter_all(arch->arch);
536+ switch(format){
537+ case PHP_ARCHIVE_FORMAT_TAR:
538+ archive_read_support_format_tar(arch->arch);
539+ break;
540+ case PHP_ARCHIVE_FORMAT_CPIO:
541+ archive_read_support_format_cpio(arch->arch);
542+ break;
543+ default:
544+ archive_read_support_format_all(arch->arch);
545+ break;
546+ }
547
548- if (compression == 0) {
549- /* support all possible compression types by default */
550- _php_archive_read_support_compression_all(arch->arch);
551- }
552- else {
553- if (compression & PHP_ARCHIVE_COMPRESSION_NONE) {
554- /* none */
555- }
556- else {
557- if (compression & PHP_ARCHIVE_COMPRESSION_GZIP) {
558-#ifdef HAVE_ZLIB
559- archive_read_support_compression_gzip(arch->arch);
560-#else
561+ switch(compression){
562+ case PHP_ARCHIVE_COMPRESSION_NONE:
563+ break;
564+ case PHP_ARCHIVE_COMPRESSION_GZIP:
565+ if(archive_read_support_filter_gzip(arch->arch) != ARCHIVE_OK){
566 efree(arch->filename);
567 efree(arch->buf);
568 efree(arch);
569 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Gzip compression support is not available in this build ");
570- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
571- return;
572-#endif
573- }
574-
575- if (compression & PHP_ARCHIVE_COMPRESSION_BZIP2) {
576-#ifdef HAVE_BZ2
577- archive_read_support_compression_bzip2(arch->arch);
578-#else
579+ zend_restore_error_handling(&error_handling TSRMLS_CC);
580+ return;
581+ }
582+ break;
583+ case PHP_ARCHIVE_COMPRESSION_BZIP2:
584+ if(archive_read_support_filter_gzip(arch->arch) != ARCHIVE_OK){
585 efree(arch->filename);
586 efree(arch->buf);
587 efree(arch);
588 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bzip2 compression support is not available in this build ");
589- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
590+ zend_restore_error_handling(&error_handling TSRMLS_CC);
591 return;
592-#endif
593- }
594-
595- /* compress support is always available */
596- if (compression & PHP_ARCHIVE_COMPRESSION_COMPRESS) {
597- archive_read_support_compression_compress(arch->arch);
598- }
599- }
600- }
601+ }
602+ default:
603+ archive_read_support_filter_all(arch->arch);
604+ break;
605+ }
606+
607 result = archive_read_open(arch->arch, arch, _archive_open_clbk, _archive_read_clbk, _archive_close_clbk);
608
609 if (result) {
610@@ -188,14 +178,14 @@ ZEND_METHOD(ArchiveReader, __construct)
611 else {
612 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to open file %s for reading: unknown error %d", filename, result);
613 }
614- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
615+ zend_restore_error_handling(&error_handling TSRMLS_CC);
616 return;
617 }
618
619 resource_id = zend_list_insert(arch,le_archive);
620 add_property_resource(this, "fd", resource_id);
621
622- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
623+ zend_restore_error_handling(&error_handling TSRMLS_CC);
624 return;
625 }
626 /* }}} */
627@@ -212,19 +202,20 @@ ZEND_METHOD(ArchiveReader, getNextEntry)
628 zend_bool fetch_entry_data = 0;
629 archive_entry_t *entry;
630 struct archive_entry *current_entry;
631- int len;
632+ size_t len;
633 off_t offset;
634 char *buf;
635+ zend_error_handling error_handling;
636
637- php_set_error_handling(EH_THROW, ce_ArchiveException TSRMLS_CC);
638+ zend_replace_error_handling(EH_THROW, ce_ArchiveException, &error_handling TSRMLS_CC);
639
640 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &fetch_entry_data) == FAILURE) {
641- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
642+ zend_restore_error_handling(&error_handling TSRMLS_CC);
643 return;
644 }
645
646 if (!_archive_get_fd(this, &arch TSRMLS_CC)) {
647- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
648+ zend_restore_error_handling(&error_handling TSRMLS_CC);
649 return;
650 }
651
652@@ -240,7 +231,7 @@ ZEND_METHOD(ArchiveReader, getNextEntry)
653 arch->current_entry = entry;
654 }
655 else {
656- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
657+ zend_restore_error_handling(&error_handling TSRMLS_CC);
658 RETURN_FALSE;
659 }
660
661@@ -256,14 +247,14 @@ ZEND_METHOD(ArchiveReader, getNextEntry)
662 else {
663 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to read file %s: unknown error %d", arch->filename, result);
664 }
665- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
666+ zend_restore_error_handling(&error_handling TSRMLS_CC);
667 return;
668 }
669
670 if (result == ARCHIVE_EOF) {
671 arch->current_entry = NULL;
672 efree(entry);
673- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
674+ zend_restore_error_handling(&error_handling TSRMLS_CC);
675 RETURN_FALSE;
676 }
677
678@@ -287,7 +278,7 @@ ZEND_METHOD(ArchiveReader, getNextEntry)
679 else {
680 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to read file %s: unknown error %d", arch->filename, result);
681 }
682- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
683+ zend_restore_error_handling(&error_handling TSRMLS_CC);
684 return;
685 }
686 }
687@@ -297,7 +288,7 @@ ZEND_METHOD(ArchiveReader, getNextEntry)
688 add_property_resource(return_value, "entry", resource_id);
689 }
690
691- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
692+ zend_restore_error_handling(&error_handling TSRMLS_CC);
693 }
694 /* }}} */
695
696@@ -313,22 +304,23 @@ ZEND_METHOD(ArchiveReader, getCurrentEntryData)
697 off_t offset;
698 const char *error_string;
699 char *buf;
700+ zend_error_handling error_handling;
701
702- php_set_error_handling(EH_THROW, ce_ArchiveException TSRMLS_CC);
703+ zend_replace_error_handling(EH_THROW, ce_ArchiveException, &error_handling TSRMLS_CC);
704
705 if (!_archive_get_fd(this, &arch TSRMLS_CC)) {
706- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
707+ zend_restore_error_handling(&error_handling TSRMLS_CC);
708 return;
709 }
710
711 if (arch->current_entry == NULL) {
712 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Current archive entry is not available");
713- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
714+ zend_restore_error_handling(&error_handling TSRMLS_CC);
715 return;
716 }
717
718 if (arch->current_entry->data) {
719- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
720+ zend_restore_error_handling(&error_handling TSRMLS_CC);
721 RETURN_STRINGL(arch->current_entry->data, arch->current_entry->data_len, 1);
722 }
723
724@@ -348,11 +340,11 @@ ZEND_METHOD(ArchiveReader, getCurrentEntryData)
725 else {
726 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to read entry data: unknown error %d", result);
727 }
728- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
729+ zend_restore_error_handling(&error_handling TSRMLS_CC);
730 return;
731 }
732
733- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
734+ zend_restore_error_handling(&error_handling TSRMLS_CC);
735 RETURN_STRINGL(arch->current_entry->data, arch->current_entry->data_len, 1);
736 }
737 /* }}} */
738@@ -366,22 +358,23 @@ ZEND_METHOD(ArchiveReader, extractCurrentEntry)
739 archive_file_t *arch;
740 int result, error_num, flags = 0;
741 const char *error_string;
742+ zend_error_handling error_handling;
743
744- php_set_error_handling(EH_THROW, ce_ArchiveException TSRMLS_CC);
745+ zend_replace_error_handling(EH_THROW, ce_ArchiveException, &error_handling TSRMLS_CC);
746
747 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags) == FAILURE) {
748- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
749+ zend_restore_error_handling(&error_handling TSRMLS_CC);
750 return;
751 }
752
753 if (!_archive_get_fd(this, &arch TSRMLS_CC)) {
754- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
755+ zend_restore_error_handling(&error_handling TSRMLS_CC);
756 return;
757 }
758
759 if (arch->current_entry == NULL) {
760 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Current archive entry is not available");
761- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
762+ zend_restore_error_handling(&error_handling TSRMLS_CC);
763 return;
764 }
765
766@@ -389,7 +382,7 @@ ZEND_METHOD(ArchiveReader, extractCurrentEntry)
767 /* again, rather annoying libarchive limitation: you can't extract or
768 * read entry anymore if it had been extracted/read before.
769 * */
770- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
771+ zend_restore_error_handling(&error_handling TSRMLS_CC);
772 RETURN_FALSE;
773 }
774
775@@ -406,10 +399,10 @@ ZEND_METHOD(ArchiveReader, extractCurrentEntry)
776 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to extract entry: unknown error %d", result);
777 }
778
779- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
780+ zend_restore_error_handling(&error_handling TSRMLS_CC);
781 return;
782 }
783- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
784+ zend_restore_error_handling(&error_handling TSRMLS_CC);
785 RETURN_TRUE;
786 }
787 /* }}} */
788@@ -421,18 +414,19 @@ ZEND_METHOD(ArchiveReader, close)
789 {
790 zval *this = getThis();
791 int resourse_id;
792+ zend_error_handling error_handling;
793
794- php_set_error_handling(EH_THROW, ce_ArchiveException TSRMLS_CC);
795+ zend_replace_error_handling(EH_THROW, ce_ArchiveException, &error_handling TSRMLS_CC);
796
797 if ((resourse_id = _archive_get_rsrc_id(this TSRMLS_CC))) {
798 add_property_resource(this, "fd", 0);
799 zend_list_delete(resourse_id);
800- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
801+ zend_restore_error_handling(&error_handling TSRMLS_CC);
802 RETURN_TRUE;
803 }
804
805 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to close archive file descriptor");
806- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
807+ zend_restore_error_handling(&error_handling TSRMLS_CC);
808 }
809 /* }}} */
810
811diff --git a/archive_reader.h b/archive_reader.h
812index ed1c7f9..29d3acc 100644
813--- a/archive_reader.h
814+++ b/archive_reader.h
815@@ -12,7 +12,7 @@
816 | obtain it through the world-wide-web, please send a note to |
817 | license@php.net so we can mail you a copy immediately. |
818 +----------------------------------------------------------------------+
819- | Author: Antony Dovgal <antony@zend.com> |
820+ | Author: Antony Dovgal <tony2001@php.net> |
821 +----------------------------------------------------------------------+
822 */
823
824diff --git a/archive_util.c b/archive_util.c
825index 9838820..5e4c477 100644
826--- a/archive_util.c
827+++ b/archive_util.c
828@@ -12,7 +12,7 @@
829 | obtain it through the world-wide-web, please send a note to |
830 | license@php.net so we can mail you a copy immediately. |
831 +----------------------------------------------------------------------+
832- | Author: Antony Dovgal <antony@zend.com> |
833+ | Author: Antony Dovgal <tony2001@php.net> |
834 +----------------------------------------------------------------------+
835 */
836
837@@ -48,11 +48,11 @@ int _archive_pathname_compare(const void *a, const void *b TSRMLS_DC)
838 s = *((Bucket **) b);
839
840 Z_TYPE(first) = IS_STRING;
841- Z_STRVAL(first) = f->arKey;
842+ Z_STRVAL(first) = (char *)f->arKey;
843 Z_STRLEN(first) = f->nKeyLength-1;
844
845 Z_TYPE(second) = IS_STRING;
846- Z_STRVAL(second) = s->arKey;
847+ Z_STRVAL(second) = (char *)s->arKey;
848 Z_STRLEN(second) = s->nKeyLength-1;
849
850 if (string_compare_function(&result, &first, &second TSRMLS_CC) != SUCCESS) {
851diff --git a/archive_util.h b/archive_util.h
852index c897738..100493d 100644
853--- a/archive_util.h
854+++ b/archive_util.h
855@@ -12,7 +12,7 @@
856 | obtain it through the world-wide-web, please send a note to |
857 | license@php.net so we can mail you a copy immediately. |
858 +----------------------------------------------------------------------+
859- | Author: Antony Dovgal <antony@zend.com> |
860+ | Author: Antony Dovgal <tony2001@php.net> |
861 +----------------------------------------------------------------------+
862 */
863
864diff --git a/archive_writer.c b/archive_writer.c
865index 30647bf..2637633 100644
866--- a/archive_writer.c
867+++ b/archive_writer.c
868@@ -12,7 +12,7 @@
869 | obtain it through the world-wide-web, please send a note to |
870 | license@php.net so we can mail you a copy immediately. |
871 +----------------------------------------------------------------------+
872- | Author: Antony Dovgal <antony@zend.com> |
873+ | Author: Antony Dovgal <tony2001@php.net> |
874 +----------------------------------------------------------------------+
875 */
876
877@@ -35,8 +35,8 @@
878 zend_class_entry *ce_ArchiveWriter;
879 zend_class_entry *ce_ArchiveWriterInterface;
880
881-/* function_entry funcs_ArchiveWriterInterface {{{ */
882-function_entry funcs_ArchiveWriterInterface[] = {
883+/* zend_function_entry funcs_ArchiveWriterInterface {{{ */
884+zend_function_entry funcs_ArchiveWriterInterface[] = {
885 ZEND_ABSTRACT_ME(ArchiveWriter, __construct, NULL)
886 ZEND_ABSTRACT_ME(ArchiveWriter, addEntry, NULL)
887 ZEND_ABSTRACT_ME(ArchiveWriter, finish, NULL)
888@@ -44,8 +44,8 @@ function_entry funcs_ArchiveWriterInterface[] = {
889 };
890 /* }}} */
891
892-/* function_entry funcs_ArchiveWriter {{{ */
893-function_entry funcs_ArchiveWriter[] = {
894+/* zend_function_entry funcs_ArchiveWriter {{{ */
895+zend_function_entry funcs_ArchiveWriter[] = {
896 ZEND_ME(ArchiveWriter, __construct, NULL, 0)
897 ZEND_ME(ArchiveWriter, addEntry, NULL, 0)
898 ZEND_ME(ArchiveWriter, finish, NULL, 0)
899@@ -83,21 +83,24 @@ ZEND_METHOD(ArchiveWriter, __construct)
900 const char *error_string = NULL;
901 char *filename;
902 int error_num, filename_len, result, format=0, compression=0;
903+ zend_error_handling error_handling;
904
905- php_set_error_handling(EH_THROW, ce_ArchiveException TSRMLS_CC);
906+ zend_replace_error_handling(EH_THROW, ce_ArchiveException, &error_handling TSRMLS_CC);
907
908 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ll", &filename, &filename_len, &format, &compression) == FAILURE) {
909- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
910+ zend_restore_error_handling(&error_handling TSRMLS_CC);
911 return;
912 }
913
914+#if PHP_API_VERSION < 20100412
915 if (PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
916- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
917+ zend_restore_error_handling(&error_handling TSRMLS_CC);
918 return;
919 }
920+#endif
921
922 if (php_check_open_basedir(filename TSRMLS_CC)) {
923- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
924+ zend_restore_error_handling(&error_handling TSRMLS_CC);
925 return;
926 }
927
928@@ -114,36 +117,28 @@ ZEND_METHOD(ArchiveWriter, __construct)
929 arch->arch = archive_write_new();
930
931 switch (compression) {
932-#ifdef HAVE_ZLIB
933 case PHP_ARCHIVE_COMPRESSION_GZIP:
934- archive_write_set_compression_gzip(arch->arch);
935+ if(archive_write_add_filter_gzip(arch->arch) != ARCHIVE_OK){
936+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Gzip compression is not supported in this build");
937+ zend_restore_error_handling(&error_handling TSRMLS_CC);
938+ return;
939+ }
940 break;
941-#else
942- case PHP_ARCHIVE_COMPRESSION_GZIP:
943- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Gzip compression is not supported in this build");
944- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
945- return;
946- break;
947-#endif
948
949-#ifdef HAVE_BZ2
950 case PHP_ARCHIVE_COMPRESSION_BZIP2:
951- archive_write_set_compression_bzip2(arch->arch);
952- break;
953-#else
954- case PHP_ARCHIVE_COMPRESSION_BZIP2:
955- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bzip2 compression is not supported in this build");
956- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
957- return;
958+ if(archive_write_add_filter_bzip2(arch->arch) != ARCHIVE_OK){
959+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bzip2 compression is not supported in this build");
960+ zend_restore_error_handling(&error_handling TSRMLS_CC);
961+ return;
962+ }
963 break;
964-#endif
965 case 0: /* default value */
966 case PHP_ARCHIVE_COMPRESSION_NONE:
967 /* always supported */
968 break;
969 default:
970 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported compression type %d", compression);
971- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
972+ zend_restore_error_handling(&error_handling TSRMLS_CC);
973 return;
974 break;
975 }
976@@ -168,7 +163,7 @@ ZEND_METHOD(ArchiveWriter, __construct)
977 break;
978 default:
979 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported archive format: %d", format);
980- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
981+ zend_restore_error_handling(&error_handling TSRMLS_CC);
982 return;
983 break;
984 }
985@@ -190,14 +185,14 @@ ZEND_METHOD(ArchiveWriter, __construct)
986 else {
987 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to open file %s for writing: unknown error %d", filename, result);
988 }
989- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
990+ zend_restore_error_handling(&error_handling TSRMLS_CC);
991 return;
992 }
993
994 resource_id = zend_list_insert(arch,le_archive);
995 add_property_resource(this, "fd", resource_id);
996
997- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
998+ zend_restore_error_handling(&error_handling TSRMLS_CC);
999 return;
1000 }
1001 /* }}} */
1002@@ -214,27 +209,28 @@ ZEND_METHOD(ArchiveWriter, addEntry)
1003 char *pathname;
1004 int pathname_len;
1005 const struct stat *stat_sb;
1006+ zend_error_handling error_handling;
1007
1008- php_set_error_handling(EH_THROW, ce_ArchiveException TSRMLS_CC);
1009+ zend_replace_error_handling(EH_THROW, ce_ArchiveException, &error_handling TSRMLS_CC);
1010
1011 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &entry_obj) == FAILURE) {
1012- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
1013+ zend_restore_error_handling(&error_handling TSRMLS_CC);
1014 return;
1015 }
1016
1017 if (!_archive_get_fd(this, &arch TSRMLS_CC)) {
1018- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
1019+ zend_restore_error_handling(&error_handling TSRMLS_CC);
1020 return;
1021 }
1022
1023 if (!instanceof_function(Z_OBJCE_P(entry_obj), ce_ArchiveEntry TSRMLS_CC)) {
1024 php_error_docref(NULL TSRMLS_CC, E_WARNING, "An instance of ArchiveEntry is required");
1025- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
1026+ zend_restore_error_handling(&error_handling TSRMLS_CC);
1027 return;
1028 }
1029
1030 if(!_archive_get_entry_struct(entry_obj, &entry TSRMLS_CC)) {
1031- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
1032+ zend_restore_error_handling(&error_handling TSRMLS_CC);
1033 return;
1034 }
1035
1036@@ -245,7 +241,7 @@ ZEND_METHOD(ArchiveWriter, addEntry)
1037
1038 if (pathname_len == 0 || pathname[0] == '\0') {
1039 /* user is probably trying to add "./", "/", ".." or ".", ignoring it silently */
1040- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
1041+ zend_restore_error_handling(&error_handling TSRMLS_CC);
1042 RETURN_TRUE;
1043 }
1044
1045@@ -265,7 +261,7 @@ ZEND_METHOD(ArchiveWriter, addEntry)
1046
1047 /* ..and add it to the hash */
1048 zend_hash_update(arch->entries, pathname, pathname_len + 1, &entry_copy, sizeof(archive_entry_t), NULL);
1049- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
1050+ zend_restore_error_handling(&error_handling TSRMLS_CC);
1051 RETURN_TRUE;
1052 }
1053 /* }}} */
1054@@ -284,11 +280,12 @@ ZEND_METHOD(ArchiveWriter, finish)
1055 const char *error_string;
1056 mode_t mode;
1057 php_stream *stream;
1058+ zend_error_handling error_handling;
1059
1060- php_set_error_handling(EH_THROW, ce_ArchiveException TSRMLS_CC);
1061+ zend_replace_error_handling(EH_THROW, ce_ArchiveException, &error_handling TSRMLS_CC);
1062
1063 if (!_archive_get_fd(this, &arch TSRMLS_CC)) {
1064- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
1065+ zend_restore_error_handling(&error_handling TSRMLS_CC);
1066 return;
1067 }
1068
1069@@ -313,7 +310,7 @@ ZEND_METHOD(ArchiveWriter, finish)
1070 result = archive_write_header(arch->arch, (*entry)->entry);
1071 if (result == ARCHIVE_FATAL) {
1072 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to write entry header for file %s: fatal error", (*entry)->filename);
1073- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
1074+ zend_restore_error_handling(&error_handling TSRMLS_CC);
1075 return;
1076 }
1077 header_written = 1;
1078@@ -331,7 +328,7 @@ ZEND_METHOD(ArchiveWriter, finish)
1079 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to write file %s: unknown error %d", (*entry)->filename, result);
1080 }
1081 php_stream_close(stream);
1082- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
1083+ zend_restore_error_handling(&error_handling TSRMLS_CC);
1084 return;
1085 }
1086 }
1087@@ -342,7 +339,7 @@ ZEND_METHOD(ArchiveWriter, finish)
1088 result = archive_write_header(arch->arch, (*entry)->entry);
1089 if (result == ARCHIVE_FATAL) {
1090 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to write entry header for file %s: fatal error", (*entry)->filename);
1091- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
1092+ zend_restore_error_handling(&error_handling TSRMLS_CC);
1093 return;
1094 }
1095 }
1096@@ -352,12 +349,12 @@ ZEND_METHOD(ArchiveWriter, finish)
1097 if ((resource_id = _archive_get_rsrc_id(this TSRMLS_CC))) {
1098 add_property_resource(this, "fd", 0);
1099 zend_list_delete(resource_id);
1100- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
1101+ zend_restore_error_handling(&error_handling TSRMLS_CC);
1102 RETURN_TRUE;
1103 }
1104
1105 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to finish writing of archive file");
1106- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
1107+ zend_restore_error_handling(&error_handling TSRMLS_CC);
1108 }
1109 /* }}} */
1110
1111diff --git a/archive_writer.h b/archive_writer.h
1112index f87909c..e51b3a4 100644
1113--- a/archive_writer.h
1114+++ b/archive_writer.h
1115@@ -12,7 +12,7 @@
1116 | obtain it through the world-wide-web, please send a note to |
1117 | license@php.net so we can mail you a copy immediately. |
1118 +----------------------------------------------------------------------+
1119- | Author: Antony Dovgal <antony@zend.com> |
1120+ | Author: Antony Dovgal <tony2001@php.net> |
1121 +----------------------------------------------------------------------+
1122 */
1123
1124diff --git a/package.xml b/package.xml
1125index cb319ed..9cefd16 100644
1126diff --git a/php_archive.h b/php_archive.h
1127index ad3724b..21094f8 100644
1128--- a/php_archive.h
1129+++ b/php_archive.h
1130@@ -12,7 +12,7 @@
1131 | obtain it through the world-wide-web, please send a note to |
1132 | license@php.net so we can mail you a copy immediately. |
1133 +----------------------------------------------------------------------+
1134- | Author: Antony Dovgal <antony@zend.com> |
1135+ | Author: Antony Dovgal <tony2001@php.net> |
1136 +----------------------------------------------------------------------+
1137 */
1138
1139@@ -24,6 +24,7 @@
1140 #include <archive.h>
1141 #include <archive_entry.h>
1142
1143+#define PHP_ARCHIVE_VERSION "0.3.1-dev"
1144
1145 #define PHP_ARCHIVE_FORMAT_TAR (1<<0)
1146 #define PHP_ARCHIVE_FORMAT_CPIO (1<<1)
1147@@ -58,33 +59,43 @@ typedef struct archive_file {
1148 char *filename;
1149 char *buf;
1150 int struct_state;
1151+ int block_size;
1152 HashTable *entries;
1153 } archive_file_t;
1154
1155 #define PHP_ARCHIVE_BUF_LEN 8196
1156
1157-#if defined(HAVE_BZ2) && defined(HAVE_ZLIB)
1158-#define _php_archive_read_support_compression_all(arch) \
1159- archive_read_support_compression_bzip2(arch); \
1160- archive_read_support_compression_gzip(arch); \
1161- archive_read_support_compression_compress(arch);
1162+#if ARCHIVE_VERSION_NUMBER < 3000000
1163+#define archive_read_free archive_read_finish
1164+#define archive_write_free archive_write_finish
1165+
1166+#define archive_read_support_filter_all archive_read_support_compression_all
1167+#define archive_read_support_filter_bzip2 archive_read_support_compression_bzip2
1168+#define archive_read_support_filter_compress archive_read_support_compression_compress
1169+#define archive_read_support_filter_gzip archive_read_support_compression_gzip
1170+#define archive_read_support_filter_lzip archive_read_support_compression_lzip
1171+#define archive_read_support_filter_lzma archive_read_support_compression_lzma
1172+#define archive_read_support_filter_none archive_read_support_compression_none
1173+#define archive_read_support_filter_program archive_read_support_compression_program
1174+#define archive_read_support_filter_program_signature archive_read_support_compression_program_signature
1175+#define archive_read_support_filter_rpm archive_read_support_compression_rpm
1176+#define archive_read_support_filter_uu archive_read_support_compression_uu
1177+#define archive_read_support_filter_xz archive_read_support_compression_xz
1178+
1179+#define archive_write_add_filter_bzip2 archive_write_set_compression_bzip2
1180+#define archive_write_add_filter_compress archive_write_set_compression_compress
1181+#define archive_write_add_filter_gzip archive_write_set_compression_gzip
1182+#define archive_write_add_filter_lzip archive_write_set_compression_lzip
1183+#define archive_write_add_filter_lzma archive_write_set_compression_lzma
1184+#define archive_write_add_filter_none archive_write_set_compression_none
1185+#define archive_write_add_filter_program archive_write_set_compression_program
1186+#define archive_write_add_filter_xz archive_write_set_compression_xz
1187 #endif
1188
1189-#if defined(HAVE_BZ2) && !defined(HAVE_ZLIB)
1190-#define _php_archive_read_support_compression_all(arch) \
1191- archive_read_support_compression_bzip2(arch); \
1192- archive_read_support_compression_compress(arch);
1193-#endif
1194-
1195-#if !defined(HAVE_BZ2) && defined(HAVE_ZLIB)
1196-#define _php_archive_read_support_compression_all(arch) \
1197- archive_read_support_compression_gzip(arch); \
1198- archive_read_support_compression_compress(arch);
1199-#endif
1200-
1201-#if !defined(HAVE_BZ2) && !defined(HAVE_ZLIB)
1202-#define _php_archive_read_support_compression_all(arch) \
1203- archive_read_support_compression_compress(arch);
1204+#if ZEND_MODULE_API_NO < 20090626
1205+typedef int zend_error_handling;
1206+#define zend_replace_error_handling(type, exception, current) php_set_error_handling((type), (exception) TSRMLS_CC)
1207+#define zend_restore_error_handling(exception) php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC)
1208 #endif
1209
1210 PHPAPI zend_class_entry *ce_ArchiveException;
1211diff --git a/php_archive_entry.h b/php_archive_entry.h
1212index 88479ed..1bb7914 100644
1213--- a/php_archive_entry.h
1214+++ b/php_archive_entry.h
1215@@ -12,7 +12,7 @@
1216 | obtain it through the world-wide-web, please send a note to |
1217 | license@php.net so we can mail you a copy immediately. |
1218 +----------------------------------------------------------------------+
1219- | Author: Antony Dovgal <antony@zend.com> |
1220+ | Author: Antony Dovgal <tony2001@php.net> |
1221 +----------------------------------------------------------------------+
1222 */
1223
This page took 0.24463 seconds and 4 git commands to generate.