// vim:ft=javascript
ARG_ENABLE("phar", "enable phar support", "no");
-ARG_WITH("phar-zip", "for zip-based phar support", "no");
if (PHP_PHAR != "no") {
EXTENSION("phar", "tar.c zip.c stream.c dirstream.c func_interceptors.c phar.c phar_object.c phar_path_check.c");
+ ADD_EXTENSION_DEP('phar', 'zip');
if (PHP_ZIP_SHARED) {
ADD_FLAG("CFLAGS_PHAR", "/D COMPILE_DL_ZIP ");
}
ADD_FLAG("CFLAGS_PHAR", "/D COMPILE_DL_PHAR ");
}
if (PHP_ZIP != "no") {
- ADD_EXTENSION_DEP('phar', 'zip', true);
AC_DEFINE('HAVE_PHAR_ZIP', 1);
}
ADD_EXTENSION_DEP('phar', 'zlib', true);
offset += entry.compressed_filesize;
switch (entry.flags & PHAR_ENT_COMPRESSION_MASK) {
case PHAR_ENT_COMPRESSED_GZ:
-#if !HAVE_ZLIB
- if (entry.metadata) {
- zval_ptr_dtor(&entry.metadata);
- }
- efree(entry.filename);
- MAPPHAR_FAIL("zlib extension is required for gz compressed .phar file \"%s\"");
-#else
if (!phar_has_zlib) {
if (entry.metadata) {
zval_ptr_dtor(&entry.metadata);
efree(entry.filename);
MAPPHAR_FAIL("zlib extension is required for gz compressed .phar file \"%s\"");
}
-#endif
break;
case PHAR_ENT_COMPRESSED_BZ2:
if (!phar_has_bz2) {
test = '\1';
pos = buffer+tokenlen;
if (!memcmp(pos, gz_magic, 3)) {
-#if !HAVE_ZLIB
- MAPPHAR_ALLOC_FAIL("unable to decompress gzipped phar archive \"%s\" to temporary file, zlib disabled in phar compilation")
-#else
char err = 0;
php_stream_filter *filter;
php_stream *temp;
/* now, start over */
test = '\0';
-#endif
continue;
} else if (!memcmp(pos, bz_magic, 3)) {
php_stream_filter *filter;
#else
php_info_print_table_row(2, "ZIP-based phar archives", "unavailable");
#endif
-#if HAVE_ZLIB
if (phar_has_zlib) {
php_info_print_table_row(2, "gzip compression", "enabled");
} else {
php_info_print_table_row(2, "gzip compression", "disabled (install ext/zlib)");
}
-#else
- php_info_print_table_row(2, "gzip compression", "unavailable");
-#endif
if (phar_has_bz2) {
php_info_print_table_row(2, "bzip2 compression", "enabled");
} else {
#if HAVE_PHAR_ZIP
ZEND_MOD_OPTIONAL_EX("zip", ">=", "1.8.11")
#endif
-#if HAVE_ZLIB
ZEND_MOD_OPTIONAL("zlib")
-#endif
ZEND_MOD_OPTIONAL("bz2")
#if HAVE_SPL
ZEND_MOD_REQUIRED("spl")
switch (method) {
case PHAR_ENT_COMPRESSED_GZ:
-#if HAVE_ZLIB
if (phar_has_zlib) {
RETURN_TRUE;
} else {
RETURN_FALSE;
}
-#else
- RETURN_FALSE;
-#endif
case PHAR_ENT_COMPRESSED_BZ2:
if (phar_has_bz2) {
{
array_init(return_value);
-#if HAVE_ZLIB
if (phar_has_zlib) {
add_next_index_stringl(return_value, "GZ", 2, 1);
}
-#endif
if (phar_has_bz2) {
add_next_index_stringl(return_value, "BZIP2", 5, 1);
}
flags = PHAR_FILE_COMPRESSED_NONE;
break;
case PHAR_ENT_COMPRESSED_GZ:
-#if HAVE_ZLIB
if (!phar_has_zlib) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress entire archive with gzip, enable ext/zlib in php.ini");
}
flags = PHAR_FILE_COMPRESSED_GZ;
break;
-#else
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Cannot compress entire archive with gzip, support unavailable");
-#endif
case PHAR_ENT_COMPRESSED_BZ2:
if (!phar_has_bz2) {
flags = PHAR_FILE_COMPRESSED_NONE;
break;
case PHAR_ENT_COMPRESSED_GZ:
-#if HAVE_ZLIB
if (!phar_has_zlib) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress entire archive with gzip, enable ext/zlib in php.ini");
}
flags = PHAR_FILE_COMPRESSED_GZ;
break;
-#else
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Cannot compress entire archive with gzip, support unavailable");
-#endif
case PHAR_ENT_COMPRESSED_BZ2:
if (!phar_has_bz2) {
*(int *) argument = 0;
}
}
-#if !HAVE_ZLIB
- if (entry->flags & PHAR_ENT_COMPRESSED_GZ) {
- *(int *) argument = 0;
- }
-#else
if (!phar_has_zlib) {
if (entry->flags & PHAR_ENT_COMPRESSED_GZ) {
*(int *) argument = 0;
}
}
-#endif
return ZEND_HASH_APPLY_KEEP;
}
/* }}} */
*/
PHP_METHOD(Phar, compressAllFilesGZ)
{
-#if HAVE_ZLIB
char *error;
-#endif
PHAR_ARCHIVE_OBJECT();
if (PHAR_G(readonly)) {
"Phar is readonly, cannot change compression");
return;
}
-#if HAVE_ZLIB
if (!phar_has_zlib) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress with Gzip compression, zlib 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 Gzip compression, zlib extension is not enabled");
-#endif
}
/* }}} */
*/
PHP_METHOD(PharFileInfo, setCompressedGZ)
{
-#if HAVE_ZLIB
char *error;
PHAR_ENTRY_OBJECT();
efree(error);
}
RETURN_TRUE;
-#else
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Cannot compress with Gzip compression, zlib extension is not enabled");
-#endif
}
/* }}} */
"Cannot compress deleted file");
return;
}
-#if !HAVE_ZLIB
- if (entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_GZ) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Cannot uncompress Gzip-compressed file, zlib extension is not enabled");
- return;
- }
-#else
if (!phar_has_zlib) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot uncompress Gzip-compressed file, zlib extension is not enabled");
return;
}
-#endif
if (!phar_has_bz2) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot uncompress Bzip2-compressed file, bz2 extension is not enabled");