[ --enable-phar Enable phar support])
if test "$PHP_PHAR" != "no"; then
+ AC_MSG_CHECKING([for ZIP includes])
+ if test -f $abs_srcdir/include/php/ext/zip/lib/zip.h; then
+ zip_inc_path=$abs_srcdir/ext
+ AC_DEFINE(HAVE_PHAR_ZIP,1,[ ])
+ AC_MSG_RESULT($zip_inc_path)
+ elif test -f $abs_srcdir/ext/zip/lib/zip.h; then
+ zip_inc_path=$abs_srcdir/ext
+ AC_DEFINE(HAVE_PHAR_ZIP,1,[ ])
+ AC_MSG_RESULT($zip_inc_path)
+ elif test -f $prefix/include/php/ext/zip/lib/zip.h; then
+ zip_inc_path=$prefix/include/php/ext
+ AC_DEFINE(HAVE_PHAR_ZIP,1,[ ])
+ AC_MSG_RESULT($zip_inc_path)
+ else
+ zip_inc_path=/dev/null
+ AC_DEFINE(HAVE_PHAR_ZIP,0,[ ])
+ AC_MSG_RESULT([not found, disabling ZIP-based phar support])
+ fi
PHP_NEW_EXTENSION(phar, tar.c zip.c stream.c func_interceptors.c dirstream.c phar.c phar_object.c phar_path_check.c, $ext_shared)
- AC_DEFINE(HAVE_PHAR_ZIP,1,[ ])
PHP_ADD_BUILD_DIR($ext_builddir/lib, 1)
PHP_SUBST(PHAR_SHARED_LIBADD)
PHP_ADD_EXTENSION_DEP(phar, zip, true)
#endif
break;
case PHAR_ENT_COMPRESSED_BZ2:
-#if !HAVE_BZ2
- if (entry.metadata) {
- zval_ptr_dtor(&entry.metadata);
- }
- efree(entry.filename);
- MAPPHAR_FAIL("bz2 extension is required for bzip2 compressed .phar file \"%s\"");
-#else
if (!phar_has_bz2) {
if (entry.metadata) {
zval_ptr_dtor(&entry.metadata);
efree(entry.filename);
MAPPHAR_FAIL("bz2 extension is required for bzip2 compressed .phar file \"%s\"");
}
-#endif
break;
default:
if (entry.uncompressed_filesize != entry.compressed_filesize) {
#endif
continue;
} else if (!memcmp(pos, bz_magic, 3)) {
-#if !HAVE_BZ2
- MAPPHAR_ALLOC_FAIL("unable to decompress bzipped phar archive \"%s\" to temporary file, bzip2 disabled in phar compilation")
-#else
php_stream_filter *filter;
php_stream *temp;
if (!phar_has_bz2) {
- MAPPHAR_ALLOC_FAIL("unable to decompress bzipped phar archive \"%s\" to temporary file, enable bzip2 extension in php.ini")
+ MAPPHAR_ALLOC_FAIL("unable to decompress bzipped phar archive \"%s\" to temporary file, enable bz2 extension in php.ini")
}
/* entire file is bzip-compressed, uncompress to temporary file */
if (!(temp = php_stream_fopen_tmpfile())) {
/* now, start over */
test = '\0';
-#endif
continue;
}
if (!memcmp(pos, zip_magic, 4)) {
}
if (!entry->zip) {
if (entry->flags & PHAR_ENT_COMPRESSED_BZ2) {
-# if HAVE_BZ2
char *filter_name;
php_stream_filter *filter;
/* we have to decompress this by hand */
php_stream_filter_remove(filter, 1 TSRMLS_CC);
php_stream_close(fp);
return entry;
-# else /* #if HAVE_BZ2 */
- if (error) {
- spprintf(error, 4096, "phar error, cannot decompress bzip2-compressed entry");
- }
- return NULL;
-# endif /* #if HAVE_BZ2 */
} else {
/* uncompressed or zlib-compressed */
entry->zip = zip_fopen_index(phar->zip, entry->index, 0);
#else
php_info_print_table_row(2, "gzip compression", "unavailable");
#endif
-#if HAVE_BZ2
if (phar_has_bz2) {
php_info_print_table_row(2, "bzip2 compression", "enabled");
} else {
php_info_print_table_row(2, "bzip2 compression", "disabled (install pecl/bz2)");
}
-#else
- php_info_print_table_row(2, "bzip2 compression", "unavailable (install pecl/bz2)");
-#endif
php_info_print_table_end();
php_info_print_box_start(0);
#if HAVE_ZLIB
ZEND_MOD_OPTIONAL("zlib")
#endif
-#if HAVE_BZ2
ZEND_MOD_OPTIONAL("bz2")
-#endif
#if HAVE_SPL
ZEND_MOD_REQUIRED("spl")
#endif
#endif
case PHAR_ENT_COMPRESSED_BZ2:
-#if HAVE_BZ2
if (phar_has_bz2) {
RETURN_TRUE;
} else {
RETURN_FALSE;
}
-#else
- RETURN_FALSE;
-#endif
default:
-#if HAVE_ZLIB || HAVE_BZ2
- if (phar_has_zlib || phar_has_bz2) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-#else
- RETURN_FALSE;
-#endif
+ if (phar_has_zlib || phar_has_bz2) {
+ RETURN_TRUE;
+ } else {
+ RETURN_FALSE;
+ }
}
}
/* }}} */
add_next_index_stringl(return_value, "GZ", 2, 1);
}
#endif
-#if HAVE_BZ2
if (phar_has_bz2) {
add_next_index_stringl(return_value, "BZIP2", 5, 1);
}
-#endif
}
/* }}} */
#endif
case PHAR_ENT_COMPRESSED_BZ2:
-#if HAVE_BZ2
if (!phar_has_bz2) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress entire archive with bz2, enable ext/bz2 in php.ini");
}
flags = PHAR_FILE_COMPRESSED_BZ2;
break;
-#else
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Cannot compress entire archive with bz2, bz2 support unavailable");
-#endif
default:
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2");
"Cannot convert phar archive to zip format, zip-based phar archives are disabled (enable ext/zip in php.ini)");
return;
}
-#else
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Cannot convert phar archive to zip format, zip-based phar archives are unavailable");
- return;
-#endif
if (!zend_hash_num_elements(&phar_obj->arc.archive->manifest)) {
int ziperror;
}
phar_convert_to_other(phar_obj->arc.archive, 2, 0 TSRMLS_CC);
RETURN_TRUE;
+#else
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot convert phar archive to zip format, zip-based phar archives are unavailable");
+ return;
+#endif
}
/* }}} */
#endif
case PHAR_ENT_COMPRESSED_BZ2:
-#if HAVE_BZ2
if (!phar_has_bz2) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress entire archive with bz2, enable ext/bz2 in php.ini");
}
flags = PHAR_FILE_COMPRESSED_BZ2;
break;
-#else
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Cannot compress entire archive with bz2, bz2 support unavailable");
-#endif
default:
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2");
if (entry->is_deleted) {
return ZEND_HASH_APPLY_KEEP;
}
-#if !HAVE_BZ2
- if (entry->flags & PHAR_ENT_COMPRESSED_BZ2) {
- *(int *) argument = 0;
- }
-#else
if (!phar_has_bz2) {
if (entry->flags & PHAR_ENT_COMPRESSED_BZ2) {
*(int *) argument = 0;
}
}
-#endif
#if !HAVE_ZLIB
if (entry->flags & PHAR_ENT_COMPRESSED_GZ) {
*(int *) argument = 0;
*/
PHP_METHOD(Phar, compressAllFilesBZIP2)
{
-#if HAVE_BZ2
char *error;
-#endif
PHAR_ARCHIVE_OBJECT();
if (phar_obj->arc.archive->is_zip) {
"Phar is readonly, cannot change compression");
return;
}
-#if HAVE_BZ2
if (!phar_has_bz2) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress with Bzip2 compression, bz2 extension is not enabled");
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, error);
efree(error);
}
-#else
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Cannot compress with Bzip2 compression, bz2 extension is not enabled");
-#endif
}
/* }}} */
*/
PHP_METHOD(PharFileInfo, setCompressedBZIP2)
{
-#if HAVE_BZ2
char *error;
PHAR_ENTRY_OBJECT();
efree(error);
}
RETURN_TRUE;
-#else
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Cannot compress with Bzip2 compression, bzip2 extension is not enabled");
-#endif
}
/* }}} */
return;
}
#endif
-#if !HAVE_BZ2
- if (entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_BZ2) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Cannot uncompress Bzip2-compressed file, bzip2 extension is not enabled");
- return;
- }
-#else
if (!phar_has_bz2) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Cannot uncompress Bzip2-compressed file, bzip2 extension is not enabled");
+ "Cannot uncompress Bzip2-compressed file, bz2 extension is not enabled");
return;
}
-#endif
if (!entry_obj->ent.entry->fp) {
fname_len = spprintf(&fname, 0, "phar://%s/%s", entry_obj->ent.entry->phar->fname, entry_obj->ent.entry->filename);
entry_obj->ent.entry->fp = php_stream_open_wrapper_ex(fname, "rb", 0, 0, 0);