summaryrefslogtreecommitdiff
path: root/ext/phar
diff options
context:
space:
mode:
Diffstat (limited to 'ext/phar')
-rw-r--r--ext/phar/Makefile.frag2
-rw-r--r--ext/phar/config.m42
-rw-r--r--ext/phar/config.w322
-rw-r--r--ext/phar/dirstream.c220
-rw-r--r--ext/phar/dirstream.h18
-rw-r--r--ext/phar/func_interceptors.c373
-rw-r--r--ext/phar/func_interceptors.h12
-rw-r--r--ext/phar/makestub.php2
-rw-r--r--ext/phar/phar.c795
-rw-r--r--ext/phar/phar_internal.h194
-rw-r--r--ext/phar/phar_object.c2221
-rw-r--r--ext/phar/pharzip.h8
-rw-r--r--ext/phar/php_phar.h2
-rw-r--r--ext/phar/stream.c398
-rw-r--r--ext/phar/stream.h24
-rw-r--r--ext/phar/stub.h4
-rw-r--r--ext/phar/tar.c215
-rw-r--r--ext/phar/tests/017.phpt2
-rw-r--r--ext/phar/tests/017U.phpt2
-rw-r--r--ext/phar/tests/018.phpt2
-rw-r--r--ext/phar/tests/018U.phpt2
-rw-r--r--ext/phar/tests/019b.phpt2
-rw-r--r--ext/phar/tests/019bU.phpt2
-rw-r--r--ext/phar/tests/019c.phpt2
-rw-r--r--ext/phar/tests/019cU.phpt2
-rw-r--r--ext/phar/tests/027.phpt2
-rw-r--r--ext/phar/tests/027U.phpt2
-rw-r--r--ext/phar/tests/badparameters.phpt41
-rw-r--r--ext/phar/tests/bug45218_SLOWTEST.phpt2
-rw-r--r--ext/phar/tests/bug45218_SLOWTESTU.phpt2
-rw-r--r--ext/phar/tests/bug46032.phpt2
-rw-r--r--ext/phar/tests/bug60261.phpt8
-rw-r--r--ext/phar/tests/bug69441.phpt2
-rw-r--r--ext/phar/tests/bug69453.phpt2
-rw-r--r--ext/phar/tests/bug69720.phpt2
-rw-r--r--ext/phar/tests/bug71331.phpt2
-rw-r--r--ext/phar/tests/bug71625.phpt2
-rw-r--r--ext/phar/tests/cache_list/frontcontroller11.phpt2
-rw-r--r--ext/phar/tests/cache_list/frontcontroller12.phpt2
-rw-r--r--ext/phar/tests/cache_list/frontcontroller13.phpt2
-rw-r--r--ext/phar/tests/cache_list/frontcontroller18.phpt2
-rw-r--r--ext/phar/tests/cache_list/frontcontroller19.phpt2
-rw-r--r--ext/phar/tests/cache_list/frontcontroller20.phpt2
-rw-r--r--ext/phar/tests/cache_list/frontcontroller29.phpt7
-rw-r--r--ext/phar/tests/cached_manifest_1.phpt2
-rw-r--r--ext/phar/tests/cached_manifest_1U.phpt2
-rw-r--r--ext/phar/tests/create_new_and_modify.phpt2
-rw-r--r--ext/phar/tests/create_path_error.phpt10
-rw-r--r--ext/phar/tests/fgc_edgecases.phpt2
-rw-r--r--ext/phar/tests/files/phar_test.inc2
-rw-r--r--ext/phar/tests/fopen_edgecases2U.phpt4
-rw-r--r--ext/phar/tests/frontcontroller11.phpt2
-rw-r--r--ext/phar/tests/frontcontroller12.phpt2
-rw-r--r--ext/phar/tests/frontcontroller13.phpt2
-rw-r--r--ext/phar/tests/frontcontroller18.phpt2
-rw-r--r--ext/phar/tests/frontcontroller19.phpt2
-rw-r--r--ext/phar/tests/frontcontroller20.phpt2
-rw-r--r--ext/phar/tests/frontcontroller29.phpt7
-rw-r--r--ext/phar/tests/ini_set_off.phpt2
-rw-r--r--ext/phar/tests/ini_set_offU.phpt2
-rw-r--r--ext/phar/tests/metadata_read.phpt2
-rw-r--r--ext/phar/tests/metadata_readU.phpt2
-rw-r--r--ext/phar/tests/metadata_write.phpt2
-rw-r--r--ext/phar/tests/metadata_writeU.phpt2
-rw-r--r--ext/phar/tests/metadata_write_commit.phpt2
-rw-r--r--ext/phar/tests/metadata_write_commitU.phpt2
-rw-r--r--ext/phar/tests/mounteddir.phpt2
-rw-r--r--ext/phar/tests/mounteddirU.phpt2
-rw-r--r--ext/phar/tests/phar_begin_setstub_commit.phpt2
-rw-r--r--ext/phar/tests/phar_begin_setstub_commitU.phpt2
-rw-r--r--ext/phar/tests/phar_bz2.phpt2
-rw-r--r--ext/phar/tests/phar_gzip.phpt2
-rw-r--r--ext/phar/tests/phar_gzipU.phpt2
-rw-r--r--ext/phar/tests/phar_metadata_read.phpt2
-rw-r--r--ext/phar/tests/phar_metadata_readU.phpt2
-rw-r--r--ext/phar/tests/phar_metadata_write.phpt2
-rw-r--r--ext/phar/tests/phar_metadata_writeU.phpt2
-rw-r--r--ext/phar/tests/phar_oo_001.phpt2
-rw-r--r--ext/phar/tests/phar_oo_001U.phpt2
-rw-r--r--ext/phar/tests/phar_oo_002.phpt2
-rw-r--r--ext/phar/tests/phar_oo_002U.phpt2
-rw-r--r--ext/phar/tests/phar_oo_004.phpt2
-rw-r--r--ext/phar/tests/phar_oo_004U.phpt2
-rw-r--r--ext/phar/tests/phar_oo_005U.phpt2
-rw-r--r--ext/phar/tests/pharfileinfo_chmod.phpt2
-rw-r--r--ext/phar/tests/pharfileinfo_compression.phpt2
-rw-r--r--ext/phar/tests/pharfileinfo_construct.phpt13
-rw-r--r--ext/phar/tests/phpinfo_004.phpt4
-rw-r--r--ext/phar/tests/readfile_edgecasesU.phpt2
-rw-r--r--ext/phar/tests/tar/all.phpt2
-rw-r--r--ext/phar/tests/tar/allU.phpt2
-rw-r--r--ext/phar/tests/tar/create_new_and_modify.phpt2
-rw-r--r--ext/phar/tests/tar/frontcontroller11.phar.phpt2
-rw-r--r--ext/phar/tests/tar/frontcontroller12.phar.phpt2
-rw-r--r--ext/phar/tests/tar/frontcontroller13.phar.phpt2
-rw-r--r--ext/phar/tests/tar/frontcontroller18.phar.phpt2
-rw-r--r--ext/phar/tests/tar/frontcontroller19.phar.phpt2
-rw-r--r--ext/phar/tests/tar/frontcontroller20.phar.phpt2
-rw-r--r--ext/phar/tests/tar/phar_begin_setstub_commit.phpt2
-rw-r--r--ext/phar/tests/tar/phar_begin_setstub_commitU.phpt2
-rw-r--r--ext/phar/tests/tar/tar_004.phpt2
-rw-r--r--ext/phar/tests/tar/tar_004U.phpt2
-rw-r--r--ext/phar/tests/tar/tar_bz2.phpt2
-rw-r--r--ext/phar/tests/tar/tar_bz2U.phpt2
-rw-r--r--ext/phar/tests/tar/tar_gzip.phpt2
-rw-r--r--ext/phar/tests/tar/tar_gzipU.phpt2
-rw-r--r--ext/phar/tests/zip/all.phpt2
-rw-r--r--ext/phar/tests/zip/allU.phpt2
-rw-r--r--ext/phar/tests/zip/create_new_and_modify.phpt2
-rw-r--r--ext/phar/tests/zip/frontcontroller11.phar.phpt2
-rw-r--r--ext/phar/tests/zip/frontcontroller12.phar.phpt2
-rw-r--r--ext/phar/tests/zip/frontcontroller13.phar.phpt2
-rw-r--r--ext/phar/tests/zip/frontcontroller18.phar.phpt2
-rw-r--r--ext/phar/tests/zip/frontcontroller19.phar.phpt2
-rw-r--r--ext/phar/tests/zip/frontcontroller20.phar.phpt2
-rw-r--r--ext/phar/tests/zip/metadata_write_commit.phpt2
-rw-r--r--ext/phar/tests/zip/metadata_write_commitU.phpt2
-rw-r--r--ext/phar/tests/zip/phar_begin_setstub_commit.phpt2
-rw-r--r--ext/phar/tests/zip/phar_begin_setstub_commitU.phpt2
-rw-r--r--ext/phar/tests/zip/phar_magic.phpt2
-rw-r--r--ext/phar/tests/zip/phar_magicU.phpt2
-rw-r--r--ext/phar/util.c621
-rw-r--r--ext/phar/zip.c267
123 files changed, 2790 insertions, 2876 deletions
diff --git a/ext/phar/Makefile.frag b/ext/phar/Makefile.frag
index b8b1b42d43..e58795deea 100644
--- a/ext/phar/Makefile.frag
+++ b/ext/phar/Makefile.frag
@@ -3,7 +3,7 @@ $(srcdir)/phar_path_check.c: $(srcdir)/phar_path_check.re
pharcmd: $(builddir)/phar.php $(builddir)/phar.phar
-PHP_PHARCMD_SETTINGS = -d 'open_basedir=' -d 'output_buffering=0' -d 'memory_limit=-1' -d phar.readonly=0 -d 'safe_mode=0'
+PHP_PHARCMD_SETTINGS = -n -d 'open_basedir=' -d 'output_buffering=0' -d 'memory_limit=-1' -d phar.readonly=0 -d 'safe_mode=0'
PHP_PHARCMD_EXECUTABLE = ` \
if test -x "$(top_builddir)/$(SAPI_CLI_PATH)"; then \
$(top_srcdir)/build/shtool echo -n -- "$(top_builddir)/$(SAPI_CLI_PATH) -n"; \
diff --git a/ext/phar/config.m4 b/ext/phar/config.m4
index 614d672eab..8b91caaedc 100644
--- a/ext/phar/config.m4
+++ b/ext/phar/config.m4
@@ -5,7 +5,7 @@ PHP_ARG_ENABLE(phar, for phar archive support,
[ --disable-phar Disable phar support], yes)
if test "$PHP_PHAR" != "no"; then
- PHP_NEW_EXTENSION(phar, util.c tar.c zip.c stream.c func_interceptors.c dirstream.c phar.c phar_object.c phar_path_check.c, $ext_shared)
+ PHP_NEW_EXTENSION(phar, util.c tar.c zip.c stream.c func_interceptors.c dirstream.c phar.c phar_object.c phar_path_check.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
AC_MSG_CHECKING([for phar openssl support])
if test "$PHP_HASH_SHARED" != "yes"; then
if test "$PHP_HASH" != "no"; then
diff --git a/ext/phar/config.w32 b/ext/phar/config.w32
index 93504f61fb..6dba20affb 100644
--- a/ext/phar/config.w32
+++ b/ext/phar/config.w32
@@ -9,7 +9,7 @@ if (PHP_PHAR_NATIVE_SSL != "no") {
}
if (PHP_PHAR != "no") {
- EXTENSION("phar", "dirstream.c func_interceptors.c phar.c phar_object.c phar_path_check.c stream.c tar.c util.c zip.c");
+ EXTENSION("phar", "dirstream.c func_interceptors.c phar.c phar_object.c phar_path_check.c stream.c tar.c util.c zip.c", PHP_PHAR_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
if (PHP_PHAR_SHARED || (PHP_PHAR_NATIVE_SSL_SHARED && PHP_SNAPSHOT_BUILD == "no")) {
ADD_FLAG("CFLAGS_PHAR", "/D COMPILE_DL_PHAR ");
}
diff --git a/ext/phar/dirstream.c b/ext/phar/dirstream.c
index f843501b58..33dfffc3c0 100644
--- a/ext/phar/dirstream.c
+++ b/ext/phar/dirstream.c
@@ -22,7 +22,7 @@
#include "dirstream.h"
BEGIN_EXTERN_C()
-void phar_dostat(phar_archive_data *phar, phar_entry_info *data, php_stream_statbuf *ssb, zend_bool is_dir TSRMLS_DC);
+void phar_dostat(phar_archive_data *phar, phar_entry_info *data, php_stream_statbuf *ssb, zend_bool is_dir);
END_EXTERN_C()
php_stream_ops phar_dir_ops = {
@@ -40,13 +40,13 @@ php_stream_ops phar_dir_ops = {
/**
* Used for closedir($fp) where $fp is an opendir('phar://...') directory handle
*/
-static int phar_dir_close(php_stream *stream, int close_handle TSRMLS_DC) /* {{{ */
+static int phar_dir_close(php_stream *stream, int close_handle) /* {{{ */
{
HashTable *data = (HashTable *)stream->abstract;
- if (data && data->arBuckets) {
+ if (data && data->u.flags) {
zend_hash_destroy(data);
- data->arBuckets = 0;
+ data->u.flags = 0;
FREE_HASHTABLE(data);
stream->abstract = NULL;
}
@@ -58,7 +58,7 @@ static int phar_dir_close(php_stream *stream, int close_handle TSRMLS_DC) /* {{
/**
* Used for seeking on a phar directory handle
*/
-static int phar_dir_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC) /* {{{ */
+static int phar_dir_seek(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffset) /* {{{ */
{
HashTable *data = (HashTable *)stream->abstract;
@@ -90,27 +90,26 @@ static int phar_dir_seek(php_stream *stream, off_t offset, int whence, off_t *ne
/**
* Used for readdir() on an opendir()ed phar directory handle
*/
-static size_t phar_dir_read(php_stream *stream, char *buf, size_t count TSRMLS_DC) /* {{{ */
+static size_t phar_dir_read(php_stream *stream, char *buf, size_t count) /* {{{ */
{
size_t to_read;
HashTable *data = (HashTable *)stream->abstract;
- char *str_key;
- uint keylen;
- ulong unused;
+ zend_string *str_key;
+ zend_ulong unused;
- if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(data, &str_key, &keylen, &unused, 0, NULL)) {
+ if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key(data, &str_key, &unused)) {
return 0;
}
zend_hash_move_forward(data);
- to_read = MIN(keylen, count);
+ to_read = MIN(ZSTR_LEN(str_key), count);
- if (to_read == 0 || count < keylen) {
+ if (to_read == 0 || count < ZSTR_LEN(str_key)) {
return 0;
}
memset(buf, 0, sizeof(php_stream_dirent));
- memcpy(((php_stream_dirent *) buf)->d_name, str_key, to_read);
+ memcpy(((php_stream_dirent *) buf)->d_name, ZSTR_VAL(str_key), to_read);
((php_stream_dirent *) buf)->d_name[to_read + 1] = '\0';
return sizeof(php_stream_dirent);
@@ -120,7 +119,7 @@ static size_t phar_dir_read(php_stream *stream, char *buf, size_t count TSRMLS_D
/**
* Dummy: Used for writing to a phar directory (i.e. not used)
*/
-static size_t phar_dir_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC) /* {{{ */
+static size_t phar_dir_write(php_stream *stream, const char *buf, size_t count) /* {{{ */
{
return 0;
}
@@ -129,7 +128,7 @@ static size_t phar_dir_write(php_stream *stream, const char *buf, size_t count T
/**
* Dummy: Used for flushing writes to a phar directory (i.e. not used)
*/
-static int phar_dir_flush(php_stream *stream TSRMLS_DC) /* {{{ */
+static int phar_dir_flush(php_stream *stream) /* {{{ */
{
return EOF;
}
@@ -143,24 +142,25 @@ static int phar_dir_flush(php_stream *stream TSRMLS_DC) /* {{{ */
*/
static int phar_add_empty(HashTable *ht, char *arKey, uint nKeyLength) /* {{{ */
{
- void *dummy = (char *) 1;
+ zval dummy;
- return zend_hash_update(ht, arKey, nKeyLength, (void *) &dummy, sizeof(void *), NULL);
+ ZVAL_NULL(&dummy);
+ return (zend_hash_str_update(ht, arKey, nKeyLength, &dummy) != NULL) ? SUCCESS : FAILURE;
}
/* }}} */
/**
* Used for sorting directories alphabetically
*/
-static int phar_compare_dir_name(const void *a, const void *b TSRMLS_DC) /* {{{ */
+static int phar_compare_dir_name(const void *a, const void *b) /* {{{ */
{
Bucket *f;
Bucket *s;
int result;
- f = *((Bucket **) a);
- s = *((Bucket **) b);
- result = zend_binary_strcmp(f->arKey, f->nKeyLength, s->arKey, s->nKeyLength);
+ f = (Bucket *) a;
+ s = (Bucket *) b;
+ result = zend_binary_strcmp(ZSTR_VAL(f->key), ZSTR_LEN(f->key), ZSTR_VAL(s->key), ZSTR_LEN(s->key));
if (result < 0) {
return -1;
@@ -177,13 +177,14 @@ static int phar_compare_dir_name(const void *a, const void *b TSRMLS_DC) /* {{{
* files in a phar and retrieving its relative path. From this, construct
* a list of files/directories that are "in" the directory represented by dir
*/
-static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC) /* {{{ */
+static php_stream *phar_make_dirstream(char *dir, HashTable *manifest) /* {{{ */
{
HashTable *data;
int dirlen = strlen(dir);
- char *entry, *found, *save, *str_key;
+ char *entry, *found, *save;
+ zend_string *str_key;
uint keylen;
- ulong unused;
+ zend_ulong unused;
ALLOC_HASHTABLE(data);
zend_hash_init(data, 64, NULL, NULL, 0);
@@ -199,12 +200,13 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC)
while (FAILURE != zend_hash_has_more_elements(manifest)) {
keylen = 0;
- if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(manifest, &str_key, &keylen, &unused, 0, NULL)) {
+ if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key(manifest, &str_key, &unused)) {
break;
}
+ keylen = ZSTR_LEN(str_key);
if (keylen <= (uint)dirlen) {
- if (keylen == 0 || keylen < (uint)dirlen || !strncmp(str_key, dir, dirlen)) {
+ if (keylen == 0 || keylen < (uint)dirlen || !strncmp(ZSTR_VAL(str_key), dir, dirlen)) {
if (SUCCESS != zend_hash_move_forward(manifest)) {
break;
}
@@ -214,7 +216,7 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC)
if (*dir == '/') {
/* root directory */
- if (keylen >= sizeof(".phar")-1 && !memcmp(str_key, ".phar", sizeof(".phar")-1)) {
+ if (keylen >= sizeof(".phar")-1 && !memcmp(ZSTR_VAL(str_key), ".phar", sizeof(".phar")-1)) {
/* do not add any magic entries to this directory */
if (SUCCESS != zend_hash_move_forward(manifest)) {
break;
@@ -222,28 +224,28 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC)
continue;
}
- if (NULL != (found = (char *) memchr(str_key, '/', keylen))) {
+ if (NULL != (found = (char *) memchr(ZSTR_VAL(str_key), '/', keylen))) {
/* the entry has a path separator and is a subdirectory */
- entry = (char *) safe_emalloc(found - str_key, 1, 1);
- memcpy(entry, str_key, found - str_key);
- keylen = found - str_key;
+ entry = (char *) safe_emalloc(found - ZSTR_VAL(str_key), 1, 1);
+ memcpy(entry, ZSTR_VAL(str_key), found - ZSTR_VAL(str_key));
+ keylen = found - ZSTR_VAL(str_key);
entry[keylen] = '\0';
} else {
entry = (char *) safe_emalloc(keylen, 1, 1);
- memcpy(entry, str_key, keylen);
+ memcpy(entry, ZSTR_VAL(str_key), keylen);
entry[keylen] = '\0';
}
goto PHAR_ADD_ENTRY;
} else {
- if (0 != memcmp(str_key, dir, dirlen)) {
+ if (0 != memcmp(ZSTR_VAL(str_key), dir, dirlen)) {
/* entry in directory not found */
if (SUCCESS != zend_hash_move_forward(manifest)) {
break;
}
continue;
} else {
- if (str_key[dirlen] != '/') {
+ if (ZSTR_VAL(str_key)[dirlen] != '/') {
if (SUCCESS != zend_hash_move_forward(manifest)) {
break;
}
@@ -252,7 +254,7 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC)
}
}
- save = str_key;
+ save = ZSTR_VAL(str_key);
save += dirlen + 1; /* seek to just past the path separator */
if (NULL != (found = (char *) memchr(save, '/', keylen - dirlen - 1))) {
@@ -284,7 +286,7 @@ PHAR_ADD_ENTRY:
if (FAILURE != zend_hash_has_more_elements(data)) {
efree(dir);
- if (zend_hash_sort(data, zend_qsort, phar_compare_dir_name, 0 TSRMLS_CC) == FAILURE) {
+ if (zend_hash_sort(data, phar_compare_dir_name, 0) == FAILURE) {
FREE_HASHTABLE(data);
return NULL;
}
@@ -299,50 +301,50 @@ PHAR_ADD_ENTRY:
/**
* Open a directory handle within a phar archive
*/
-php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) /* {{{ */
+php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC) /* {{{ */
{
php_url *resource = NULL;
php_stream *ret;
- char *internal_file, *error, *str_key;
- uint keylen;
- ulong unused;
+ char *internal_file, *error;
+ zend_string *str_key;
+ zend_ulong unused;
phar_archive_data *phar;
phar_entry_info *entry = NULL;
uint host_len;
- if ((resource = phar_parse_url(wrapper, path, mode, options TSRMLS_CC)) == NULL) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar url \"%s\" is unknown", path);
+ if ((resource = phar_parse_url(wrapper, path, mode, options)) == NULL) {
+ php_stream_wrapper_log_error(wrapper, options, "phar url \"%s\" is unknown", path);
return NULL;
}
/* we must have at the very least phar://alias.phar/ */
if (!resource->scheme || !resource->host || !resource->path) {
if (resource->host && !resource->path) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: no directory in \"%s\", must have at least phar://%s/ for root directory (always use full path to a new phar)", path, resource->host);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: no directory in \"%s\", must have at least phar://%s/ for root directory (always use full path to a new phar)", path, resource->host);
php_url_free(resource);
return NULL;
}
php_url_free(resource);
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: invalid url \"%s\", must have at least phar://%s/", path, path);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: invalid url \"%s\", must have at least phar://%s/", path, path);
return NULL;
}
if (strcasecmp("phar", resource->scheme)) {
php_url_free(resource);
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: not a phar url \"%s\"", path);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: not a phar url \"%s\"", path);
return NULL;
}
host_len = strlen(resource->host);
- phar_request_initialize(TSRMLS_C);
+ phar_request_initialize();
internal_file = resource->path + 1; /* strip leading "/" */
- if (FAILURE == phar_get_archive(&phar, resource->host, host_len, NULL, 0, &error TSRMLS_CC)) {
+ if (FAILURE == phar_get_archive(&phar, resource->host, host_len, NULL, 0, &error)) {
if (error) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", error);
+ php_stream_wrapper_log_error(wrapper, options, "%s", error);
efree(error);
} else {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar file \"%s\" is unknown", resource->host);
+ php_stream_wrapper_log_error(wrapper, options, "phar file \"%s\" is unknown", resource->host);
}
php_url_free(resource);
return NULL;
@@ -355,17 +357,17 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path,
if (*internal_file == '\0') {
/* root directory requested */
internal_file = estrndup(internal_file - 1, 1);
- ret = phar_make_dirstream(internal_file, &phar->manifest TSRMLS_CC);
+ ret = phar_make_dirstream(internal_file, &phar->manifest);
php_url_free(resource);
return ret;
}
- if (!phar->manifest.arBuckets) {
+ if (!phar->manifest.u.flags) {
php_url_free(resource);
return NULL;
}
- if (SUCCESS == zend_hash_find(&phar->manifest, internal_file, strlen(internal_file), (void**)&entry) && !entry->is_dir) {
+ if (NULL != (entry = zend_hash_str_find_ptr(&phar->manifest, internal_file, strlen(internal_file))) && !entry->is_dir) {
php_url_free(resource);
return NULL;
} else if (entry && entry->is_dir) {
@@ -375,22 +377,21 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path,
}
internal_file = estrdup(internal_file);
php_url_free(resource);
- return phar_make_dirstream(internal_file, &phar->manifest TSRMLS_CC);
+ return phar_make_dirstream(internal_file, &phar->manifest);
} else {
int i_len = strlen(internal_file);
/* search for directory */
zend_hash_internal_pointer_reset(&phar->manifest);
while (FAILURE != zend_hash_has_more_elements(&phar->manifest)) {
- if (HASH_KEY_NON_EXISTENT !=
- zend_hash_get_current_key_ex(
- &phar->manifest, &str_key, &keylen, &unused, 0, NULL)) {
- if (keylen > (uint)i_len && 0 == memcmp(str_key, internal_file, i_len)) {
+ if (HASH_KEY_NON_EXISTENT !=
+ zend_hash_get_current_key(&phar->manifest, &str_key, &unused)) {
+ if (ZSTR_LEN(str_key) > (uint)i_len && 0 == memcmp(ZSTR_VAL(str_key), internal_file, i_len)) {
/* directory found */
internal_file = estrndup(internal_file,
i_len);
php_url_free(resource);
- return phar_make_dirstream(internal_file, &phar->manifest TSRMLS_CC);
+ return phar_make_dirstream(internal_file, &phar->manifest);
}
}
@@ -408,7 +409,7 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path,
/**
* Make a new directory within a phar archive
*/
-int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mode, int options, php_stream_context *context TSRMLS_DC) /* {{{ */
+int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mode, int options, php_stream_context *context) /* {{{ */
{
phar_entry_info entry, *e;
phar_archive_data *phar = NULL;
@@ -418,12 +419,12 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mo
uint host_len;
/* pre-readonly check, we need to know if this is a data phar */
- if (FAILURE == phar_split_fname(url_from, strlen(url_from), &arch, &arch_len, &entry2, &entry_len, 2, 2 TSRMLS_CC)) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot create directory \"%s\", no phar archive specified", url_from);
+ if (FAILURE == phar_split_fname(url_from, strlen(url_from), &arch, &arch_len, &entry2, &entry_len, 2, 2)) {
+ php_stream_wrapper_log_error(wrapper, options, "phar error: cannot create directory \"%s\", no phar archive specified", url_from);
return 0;
}
- if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL TSRMLS_CC)) {
+ if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL)) {
phar = NULL;
}
@@ -431,63 +432,63 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mo
efree(entry2);
if (PHAR_G(readonly) && (!phar || !phar->is_data)) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot create directory \"%s\", write operations disabled", url_from);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: cannot create directory \"%s\", write operations disabled", url_from);
return 0;
}
- if ((resource = phar_parse_url(wrapper, url_from, "w", options TSRMLS_CC)) == NULL) {
+ if ((resource = phar_parse_url(wrapper, url_from, "w", options)) == NULL) {
return 0;
}
/* we must have at the very least phar://alias.phar/internalfile.php */
if (!resource->scheme || !resource->host || !resource->path) {
php_url_free(resource);
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: invalid url \"%s\"", url_from);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: invalid url \"%s\"", url_from);
return 0;
}
if (strcasecmp("phar", resource->scheme)) {
php_url_free(resource);
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: not a phar stream url \"%s\"", url_from);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: not a phar stream url \"%s\"", url_from);
return 0;
}
host_len = strlen(resource->host);
- if (FAILURE == phar_get_archive(&phar, resource->host, host_len, NULL, 0, &error TSRMLS_CC)) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot create directory \"%s\" in phar \"%s\", error retrieving phar information: %s", resource->path+1, resource->host, error);
+ if (FAILURE == phar_get_archive(&phar, resource->host, host_len, NULL, 0, &error)) {
+ php_stream_wrapper_log_error(wrapper, options, "phar error: cannot create directory \"%s\" in phar \"%s\", error retrieving phar information: %s", resource->path+1, resource->host, error);
efree(error);
php_url_free(resource);
return 0;
}
- if ((e = phar_get_entry_info_dir(phar, resource->path + 1, strlen(resource->path + 1), 2, &error, 1 TSRMLS_CC))) {
+ if ((e = phar_get_entry_info_dir(phar, resource->path + 1, strlen(resource->path + 1), 2, &error, 1))) {
/* directory exists, or is a subdirectory of an existing file */
if (e->is_temp_dir) {
efree(e->filename);
efree(e);
}
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot create directory \"%s\" in phar \"%s\", directory already exists", resource->path+1, resource->host);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: cannot create directory \"%s\" in phar \"%s\", directory already exists", resource->path+1, resource->host);
php_url_free(resource);
return 0;
}
if (error) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot create directory \"%s\" in phar \"%s\", %s", resource->path+1, resource->host, error);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: cannot create directory \"%s\" in phar \"%s\", %s", resource->path+1, resource->host, error);
efree(error);
php_url_free(resource);
return 0;
}
- if (phar_get_entry_info_dir(phar, resource->path + 1, strlen(resource->path + 1), 0, &error, 1 TSRMLS_CC)) {
+ if (phar_get_entry_info_dir(phar, resource->path + 1, strlen(resource->path + 1), 0, &error, 1)) {
/* entry exists as a file */
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot create directory \"%s\" in phar \"%s\", file already exists", resource->path+1, resource->host);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: cannot create directory \"%s\" in phar \"%s\", file already exists", resource->path+1, resource->host);
php_url_free(resource);
return 0;
}
if (error) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot create directory \"%s\" in phar \"%s\", %s", resource->path+1, resource->host, error);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: cannot create directory \"%s\" in phar \"%s\", %s", resource->path+1, resource->host, error);
efree(error);
php_url_free(resource);
return 0;
@@ -516,23 +517,23 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mo
entry.flags = PHAR_ENT_PERM_DEF_DIR;
entry.old_flags = PHAR_ENT_PERM_DEF_DIR;
- if (SUCCESS != zend_hash_add(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info), NULL)) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot create directory \"%s\" in phar \"%s\", adding to manifest failed", entry.filename, phar->fname);
+ if (NULL == zend_hash_str_add_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info))) {
+ php_stream_wrapper_log_error(wrapper, options, "phar error: cannot create directory \"%s\" in phar \"%s\", adding to manifest failed", entry.filename, phar->fname);
efree(error);
efree(entry.filename);
return 0;
}
- phar_flush(phar, 0, 0, 0, &error TSRMLS_CC);
+ phar_flush(phar, 0, 0, 0, &error);
if (error) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot create directory \"%s\" in phar \"%s\", %s", entry.filename, phar->fname, error);
- zend_hash_del(&phar->manifest, entry.filename, entry.filename_len);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: cannot create directory \"%s\" in phar \"%s\", %s", entry.filename, phar->fname, error);
+ zend_hash_str_del(&phar->manifest, entry.filename, entry.filename_len);
efree(error);
return 0;
}
- phar_add_virtual_dirs(phar, entry.filename, entry.filename_len TSRMLS_CC);
+ phar_add_virtual_dirs(phar, entry.filename, entry.filename_len);
return 1;
}
/* }}} */
@@ -540,7 +541,7 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mo
/**
* Remove a directory within a phar archive
*/
-int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context TSRMLS_DC) /* {{{ */
+int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context) /* {{{ */
{
phar_entry_info *entry;
phar_archive_data *phar = NULL;
@@ -548,18 +549,17 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options
int arch_len, entry_len;
php_url *resource = NULL;
uint host_len;
- char *str_key;
- uint key_len;
- ulong unused;
+ zend_string *str_key;
+ zend_ulong unused;
uint path_len;
/* pre-readonly check, we need to know if this is a data phar */
- if (FAILURE == phar_split_fname(url, strlen(url), &arch, &arch_len, &entry2, &entry_len, 2, 2 TSRMLS_CC)) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot remove directory \"%s\", no phar archive specified, or phar archive does not exist", url);
+ if (FAILURE == phar_split_fname(url, strlen(url), &arch, &arch_len, &entry2, &entry_len, 2, 2)) {
+ php_stream_wrapper_log_error(wrapper, options, "phar error: cannot remove directory \"%s\", no phar archive specified, or phar archive does not exist", url);
return 0;
}
- if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL TSRMLS_CC)) {
+ if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL)) {
phar = NULL;
}
@@ -567,31 +567,31 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options
efree(entry2);
if (PHAR_G(readonly) && (!phar || !phar->is_data)) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot rmdir directory \"%s\", write operations disabled", url);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: cannot rmdir directory \"%s\", write operations disabled", url);
return 0;
}
- if ((resource = phar_parse_url(wrapper, url, "w", options TSRMLS_CC)) == NULL) {
+ if ((resource = phar_parse_url(wrapper, url, "w", options)) == NULL) {
return 0;
}
/* we must have at the very least phar://alias.phar/internalfile.php */
if (!resource->scheme || !resource->host || !resource->path) {
php_url_free(resource);
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: invalid url \"%s\"", url);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: invalid url \"%s\"", url);
return 0;
}
if (strcasecmp("phar", resource->scheme)) {
php_url_free(resource);
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: not a phar stream url \"%s\"", url);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: not a phar stream url \"%s\"", url);
return 0;
}
host_len = strlen(resource->host);
- if (FAILURE == phar_get_archive(&phar, resource->host, host_len, NULL, 0, &error TSRMLS_CC)) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot remove directory \"%s\" in phar \"%s\", error retrieving phar information: %s", resource->path+1, resource->host, error);
+ if (FAILURE == phar_get_archive(&phar, resource->host, host_len, NULL, 0, &error)) {
+ php_stream_wrapper_log_error(wrapper, options, "phar error: cannot remove directory \"%s\" in phar \"%s\", error retrieving phar information: %s", resource->path+1, resource->host, error);
efree(error);
php_url_free(resource);
return 0;
@@ -599,12 +599,12 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options
path_len = strlen(resource->path+1);
- if (!(entry = phar_get_entry_info_dir(phar, resource->path + 1, path_len, 2, &error, 1 TSRMLS_CC))) {
+ if (!(entry = phar_get_entry_info_dir(phar, resource->path + 1, path_len, 2, &error, 1))) {
if (error) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot remove directory \"%s\" in phar \"%s\", %s", resource->path+1, resource->host, error);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: cannot remove directory \"%s\" in phar \"%s\", %s", resource->path+1, resource->host, error);
efree(error);
} else {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot remove directory \"%s\" in phar \"%s\", directory does not exist", resource->path+1, resource->host);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: cannot remove directory \"%s\" in phar \"%s\", directory does not exist", resource->path+1, resource->host);
}
php_url_free(resource);
return 0;
@@ -612,13 +612,13 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options
if (!entry->is_deleted) {
for (zend_hash_internal_pointer_reset(&phar->manifest);
- HASH_KEY_NON_EXISTENT != zend_hash_get_current_key_ex(&phar->manifest, &str_key, &key_len, &unused, 0, NULL);
+ HASH_KEY_NON_EXISTENT != zend_hash_get_current_key(&phar->manifest, &str_key, &unused);
zend_hash_move_forward(&phar->manifest)
) {
- if (key_len > path_len &&
- memcmp(str_key, resource->path+1, path_len) == 0 &&
- IS_SLASH(str_key[path_len])) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: Directory not empty");
+ if (ZSTR_LEN(str_key) > path_len &&
+ memcmp(ZSTR_VAL(str_key), resource->path+1, path_len) == 0 &&
+ IS_SLASH(ZSTR_VAL(str_key)[path_len])) {
+ php_stream_wrapper_log_error(wrapper, options, "phar error: Directory not empty");
if (entry->is_temp_dir) {
efree(entry->filename);
efree(entry);
@@ -629,13 +629,13 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options
}
for (zend_hash_internal_pointer_reset(&phar->virtual_dirs);
- HASH_KEY_NON_EXISTENT != zend_hash_get_current_key_ex(&phar->virtual_dirs, &str_key, &key_len, &unused, 0, NULL);
+ HASH_KEY_NON_EXISTENT != zend_hash_get_current_key(&phar->virtual_dirs, &str_key, &unused);
zend_hash_move_forward(&phar->virtual_dirs)) {
-
- if (key_len > path_len &&
- memcmp(str_key, resource->path+1, path_len) == 0 &&
- IS_SLASH(str_key[path_len])) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: Directory not empty");
+
+ if (ZSTR_LEN(str_key) > path_len &&
+ memcmp(ZSTR_VAL(str_key), resource->path+1, path_len) == 0 &&
+ IS_SLASH(ZSTR_VAL(str_key)[path_len])) {
+ php_stream_wrapper_log_error(wrapper, options, "phar error: Directory not empty");
if (entry->is_temp_dir) {
efree(entry->filename);
efree(entry);
@@ -647,16 +647,16 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options
}
if (entry->is_temp_dir) {
- zend_hash_del(&phar->virtual_dirs, resource->path+1, path_len);
+ zend_hash_str_del(&phar->virtual_dirs, resource->path+1, path_len);
efree(entry->filename);
efree(entry);
} else {
entry->is_deleted = 1;
entry->is_modified = 1;
- phar_flush(phar, 0, 0, 0, &error TSRMLS_CC);
+ phar_flush(phar, 0, 0, 0, &error);
if (error) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot remove directory \"%s\" in phar \"%s\", %s", entry->filename, phar->fname, error);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: cannot remove directory \"%s\" in phar \"%s\", %s", entry->filename, phar->fname, error);
php_url_free(resource);
efree(error);
return 0;
diff --git a/ext/phar/dirstream.h b/ext/phar/dirstream.h
index 4626f2c0fa..3f9bc884ac 100644
--- a/ext/phar/dirstream.h
+++ b/ext/phar/dirstream.h
@@ -20,20 +20,20 @@
/* $Id$ */
BEGIN_EXTERN_C()
-int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mode, int options, php_stream_context *context TSRMLS_DC);
-int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context TSRMLS_DC);
+int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mode, int options, php_stream_context *context);
+int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context);
#ifdef PHAR_DIRSTREAM
-php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const char *mode, int options TSRMLS_DC);
+php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const char *mode, int options);
/* directory handlers */
-static size_t phar_dir_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC);
-static size_t phar_dir_read( php_stream *stream, char *buf, size_t count TSRMLS_DC);
-static int phar_dir_close(php_stream *stream, int close_handle TSRMLS_DC);
-static int phar_dir_flush(php_stream *stream TSRMLS_DC);
-static int phar_dir_seek( php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC);
+static size_t phar_dir_write(php_stream *stream, const char *buf, size_t count);
+static size_t phar_dir_read( php_stream *stream, char *buf, size_t count);
+static int phar_dir_close(php_stream *stream, int close_handle);
+static int phar_dir_flush(php_stream *stream);
+static int phar_dir_seek( php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffset);
#else
-php_stream* phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
+php_stream* phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC);
#endif
END_EXTERN_C()
diff --git a/ext/phar/func_interceptors.c b/ext/phar/func_interceptors.c
index 6de88007ed..54610939dd 100644
--- a/ext/phar/func_interceptors.c
+++ b/ext/phar/func_interceptors.c
@@ -26,26 +26,26 @@
PHAR_FUNC(phar_opendir) /* {{{ */
{
char *filename;
- int filename_len;
+ size_t filename_len;
zval *zcontext = NULL;
if (!PHAR_G(intercepted)) {
goto skip_phar;
}
- if ((PHAR_GLOBALS->phar_fname_map.arBuckets && !zend_hash_num_elements(&(PHAR_GLOBALS->phar_fname_map)))
- && !cached_phars.arBuckets) {
+ if ((PHAR_G(phar_fname_map.u.flags) && !zend_hash_num_elements(&(PHAR_G(phar_fname_map))))
+ && !cached_phars.u.flags) {
goto skip_phar;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|z", &filename, &filename_len, &zcontext) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z", &filename, &filename_len, &zcontext) == FAILURE) {
return;
}
if (!IS_ABSOLUTE_PATH(filename, filename_len) && !strstr(filename, "://")) {
char *arch, *entry, *fname;
int arch_len, entry_len, fname_len;
- fname = (char*)zend_get_executed_filename(TSRMLS_C);
+ fname = (char*)zend_get_executed_filename();
/* we are checking for existence of a file within the relative path. Chances are good that this is
retrieving something from within the phar archive */
@@ -54,7 +54,7 @@ PHAR_FUNC(phar_opendir) /* {{{ */
goto skip_phar;
}
fname_len = strlen(fname);
- if (SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0 TSRMLS_CC)) {
+ if (SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0)) {
php_stream_context *context = NULL;
php_stream *stream;
char *name;
@@ -64,7 +64,7 @@ PHAR_FUNC(phar_opendir) /* {{{ */
/* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
entry_len = filename_len;
/* retrieving a file within the current directory, so use this if possible */
- entry = phar_fix_filepath(entry, &entry_len, 1 TSRMLS_CC);
+ entry = phar_fix_filepath(entry, &entry_len, 1);
if (entry[0] == '/') {
spprintf(&name, 4096, "phar://%s%s", arch, entry);
@@ -94,41 +94,41 @@ skip_phar:
PHAR_FUNC(phar_file_get_contents) /* {{{ */
{
char *filename;
- int filename_len;
- char *contents;
+ size_t filename_len;
+ zend_string *contents;
zend_bool use_include_path = 0;
php_stream *stream;
- int len;
- long offset = -1;
- long maxlen = PHP_STREAM_COPY_ALL;
+ zend_long offset = -1;
+ zend_long maxlen = PHP_STREAM_COPY_ALL;
zval *zcontext = NULL;
if (!PHAR_G(intercepted)) {
goto skip_phar;
}
- if ((PHAR_GLOBALS->phar_fname_map.arBuckets && !zend_hash_num_elements(&(PHAR_GLOBALS->phar_fname_map)))
- && !cached_phars.arBuckets) {
+ if ((PHAR_G(phar_fname_map.u.flags) && !zend_hash_num_elements(&(PHAR_G(phar_fname_map))))
+ && !cached_phars.u.flags) {
goto skip_phar;
}
/* Parse arguments */
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "p|br!ll", &filename, &filename_len, &use_include_path, &zcontext, &offset, &maxlen) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "p|br!ll", &filename, &filename_len, &use_include_path, &zcontext, &offset, &maxlen) == FAILURE) {
goto skip_phar;
}
if (use_include_path || (!IS_ABSOLUTE_PATH(filename, filename_len) && !strstr(filename, "://"))) {
char *arch, *entry, *fname;
+ zend_string *entry_str = NULL;
int arch_len, entry_len, fname_len;
php_stream_context *context = NULL;
- fname = (char*)zend_get_executed_filename(TSRMLS_C);
+ fname = (char*)zend_get_executed_filename();
if (strncasecmp(fname, "phar://", 7)) {
goto skip_phar;
}
fname_len = strlen(fname);
- if (SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0 TSRMLS_CC)) {
+ if (SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0)) {
char *name;
phar_archive_data *phar;
@@ -139,18 +139,18 @@ PHAR_FUNC(phar_file_get_contents) /* {{{ */
if (ZEND_NUM_ARGS() == 5 && maxlen < 0) {
efree(arch);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "length must be greater than or equal to zero");
+ php_error_docref(NULL, E_WARNING, "length must be greater than or equal to zero");
RETURN_FALSE;
}
/* retrieving a file defaults to within the current directory, so use this if possible */
- if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL TSRMLS_CC)) {
+ if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL)) {
efree(arch);
goto skip_phar;
}
if (use_include_path) {
- if ((entry = phar_find_in_include_path(entry, entry_len, NULL TSRMLS_CC))) {
- name = entry;
+ if ((entry_str = phar_find_in_include_path(entry, entry_len, NULL))) {
+ name = ZSTR_VAL(entry_str);
goto phar_it;
} else {
/* this file is not in the phar, use the original path */
@@ -158,9 +158,9 @@ PHAR_FUNC(phar_file_get_contents) /* {{{ */
goto skip_phar;
}
} else {
- entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1 TSRMLS_CC);
+ entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1);
if (entry[0] == '/') {
- if (!zend_hash_exists(&(phar->manifest), entry + 1, entry_len - 1)) {
+ if (!zend_hash_str_exists(&(phar->manifest), entry + 1, entry_len - 1)) {
/* this file is not in the phar, use the original path */
notfound:
efree(arch);
@@ -168,7 +168,7 @@ notfound:
goto skip_phar;
}
} else {
- if (!zend_hash_exists(&(phar->manifest), entry, entry_len)) {
+ if (!zend_hash_str_exists(&(phar->manifest), entry, entry_len)) {
goto notfound;
}
}
@@ -189,29 +189,28 @@ phar_it:
context = php_stream_context_from_zval(zcontext, 0);
}
stream = php_stream_open_wrapper_ex(name, "rb", 0 | REPORT_ERRORS, NULL, context);
- efree(name);
+ if (entry_str) {
+ zend_string_release(entry_str);
+ } else {
+ efree(name);
+ }
if (!stream) {
RETURN_FALSE;
}
if (offset > 0 && php_stream_seek(stream, offset, SEEK_SET) < 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream", offset);
+ php_error_docref(NULL, E_WARNING, "Failed to seek to position %pd in the stream", offset);
php_stream_close(stream);
RETURN_FALSE;
}
/* uses mmap if possible */
- if ((len = php_stream_copy_to_mem(stream, &contents, maxlen, 0)) > 0) {
-#if PHP_API_VERSION < 20100412
- if (PG(magic_quotes_runtime)) {
- int newlen;
- contents = php_addslashes(contents, len, &newlen, 1 TSRMLS_CC); /* 1 = free source string */
- len = newlen;
- }
-#endif
- RETVAL_STRINGL(contents, len, 0);
- } else if (len == 0) {
+ contents = php_stream_copy_to_mem(stream, maxlen, 0);
+ if (contents && ZSTR_LEN(contents) > 0) {
+ RETVAL_STR(contents);
+ } else if (contents) {
+ zend_string_release(contents);
RETVAL_EMPTY_STRING();
} else {
RETVAL_FALSE;
@@ -230,7 +229,7 @@ skip_phar:
PHAR_FUNC(phar_readfile) /* {{{ */
{
char *filename;
- int filename_len;
+ size_t filename_len;
int size = 0;
zend_bool use_include_path = 0;
zval *zcontext = NULL;
@@ -240,26 +239,27 @@ PHAR_FUNC(phar_readfile) /* {{{ */
goto skip_phar;
}
- if ((PHAR_GLOBALS->phar_fname_map.arBuckets && !zend_hash_num_elements(&(PHAR_GLOBALS->phar_fname_map)))
- && !cached_phars.arBuckets) {
+ if ((PHAR_G(phar_fname_map.u.flags) && !zend_hash_num_elements(&(PHAR_G(phar_fname_map))))
+ && !cached_phars.u.flags) {
goto skip_phar;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "p|br!", &filename, &filename_len, &use_include_path, &zcontext) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "p|br!", &filename, &filename_len, &use_include_path, &zcontext) == FAILURE) {
goto skip_phar;
}
if (use_include_path || (!IS_ABSOLUTE_PATH(filename, filename_len) && !strstr(filename, "://"))) {
char *arch, *entry, *fname;
+ zend_string *entry_str = NULL;
int arch_len, entry_len, fname_len;
php_stream_context *context = NULL;
char *name;
phar_archive_data *phar;
- fname = (char*)zend_get_executed_filename(TSRMLS_C);
+ fname = (char*)zend_get_executed_filename();
if (strncasecmp(fname, "phar://", 7)) {
goto skip_phar;
}
fname_len = strlen(fname);
- if (FAILURE == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0 TSRMLS_CC)) {
+ if (FAILURE == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0)) {
goto skip_phar;
}
@@ -268,22 +268,22 @@ PHAR_FUNC(phar_readfile) /* {{{ */
/* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
entry_len = filename_len;
/* retrieving a file defaults to within the current directory, so use this if possible */
- if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL TSRMLS_CC)) {
+ if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL)) {
efree(arch);
goto skip_phar;
}
if (use_include_path) {
- if (!(entry = phar_find_in_include_path(entry, entry_len, NULL TSRMLS_CC))) {
+ if (!(entry_str = phar_find_in_include_path(entry, entry_len, NULL))) {
/* this file is not in the phar, use the original path */
efree(arch);
goto skip_phar;
} else {
- name = entry;
+ name = ZSTR_VAL(entry_str);
}
} else {
- entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1 TSRMLS_CC);
+ entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1);
if (entry[0] == '/') {
- if (!zend_hash_exists(&(phar->manifest), entry + 1, entry_len - 1)) {
+ if (!zend_hash_str_exists(&(phar->manifest), entry + 1, entry_len - 1)) {
/* this file is not in the phar, use the original path */
notfound:
efree(entry);
@@ -291,7 +291,7 @@ notfound:
goto skip_phar;
}
} else {
- if (!zend_hash_exists(&(phar->manifest), entry, entry_len)) {
+ if (!zend_hash_str_exists(&(phar->manifest), entry, entry_len)) {
goto notfound;
}
}
@@ -307,7 +307,11 @@ notfound:
efree(arch);
context = php_stream_context_from_zval(zcontext, 0);
stream = php_stream_open_wrapper_ex(name, "rb", 0 | REPORT_ERRORS, NULL, context);
- efree(name);
+ if (entry_str) {
+ zend_string_release(entry_str);
+ } else {
+ efree(name);
+ }
if (stream == NULL) {
RETURN_FALSE;
}
@@ -326,7 +330,7 @@ skip_phar:
PHAR_FUNC(phar_fopen) /* {{{ */
{
char *filename, *mode;
- int filename_len, mode_len;
+ size_t filename_len, mode_len;
zend_bool use_include_path = 0;
zval *zcontext = NULL;
php_stream *stream;
@@ -335,27 +339,28 @@ PHAR_FUNC(phar_fopen) /* {{{ */
goto skip_phar;
}
- if ((PHAR_GLOBALS->phar_fname_map.arBuckets && !zend_hash_num_elements(&(PHAR_GLOBALS->phar_fname_map)))
- && !cached_phars.arBuckets) {
+ if ((PHAR_G(phar_fname_map.u.flags) && !zend_hash_num_elements(&(PHAR_G(phar_fname_map))))
+ && !cached_phars.u.flags) {
/* no need to check, include_path not even specified in fopen/ no active phars */
goto skip_phar;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "ps|br", &filename, &filename_len, &mode, &mode_len, &use_include_path, &zcontext) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "ps|br", &filename, &filename_len, &mode, &mode_len, &use_include_path, &zcontext) == FAILURE) {
goto skip_phar;
}
if (use_include_path || (!IS_ABSOLUTE_PATH(filename, filename_len) && !strstr(filename, "://"))) {
char *arch, *entry, *fname;
+ zend_string *entry_str = NULL;
int arch_len, entry_len, fname_len;
php_stream_context *context = NULL;
char *name;
phar_archive_data *phar;
- fname = (char*)zend_get_executed_filename(TSRMLS_C);
+ fname = (char*)zend_get_executed_filename();
if (strncasecmp(fname, "phar://", 7)) {
goto skip_phar;
}
fname_len = strlen(fname);
- if (FAILURE == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0 TSRMLS_CC)) {
+ if (FAILURE == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0)) {
goto skip_phar;
}
@@ -364,22 +369,22 @@ PHAR_FUNC(phar_fopen) /* {{{ */
/* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
entry_len = filename_len;
/* retrieving a file defaults to within the current directory, so use this if possible */
- if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL TSRMLS_CC)) {
+ if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL)) {
efree(arch);
goto skip_phar;
}
if (use_include_path) {
- if (!(entry = phar_find_in_include_path(entry, entry_len, NULL TSRMLS_CC))) {
+ if (!(entry_str = phar_find_in_include_path(entry, entry_len, NULL))) {
/* this file is not in the phar, use the original path */
efree(arch);
goto skip_phar;
} else {
- name = entry;
+ name = ZSTR_VAL(entry_str);
}
} else {
- entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1 TSRMLS_CC);
+ entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1);
if (entry[0] == '/') {
- if (!zend_hash_exists(&(phar->manifest), entry + 1, entry_len - 1)) {
+ if (!zend_hash_str_exists(&(phar->manifest), entry + 1, entry_len - 1)) {
/* this file is not in the phar, use the original path */
notfound:
efree(entry);
@@ -387,7 +392,7 @@ notfound:
goto skip_phar;
}
} else {
- if (!zend_hash_exists(&(phar->manifest), entry, entry_len)) {
+ if (!zend_hash_str_exists(&(phar->manifest), entry, entry_len)) {
/* this file is not in the phar, use the original path */
goto notfound;
}
@@ -404,13 +409,17 @@ notfound:
efree(arch);
context = php_stream_context_from_zval(zcontext, 0);
stream = php_stream_open_wrapper_ex(name, mode, 0 | REPORT_ERRORS, NULL, context);
- efree(name);
+ if (entry_str) {
+ zend_string_release(entry_str);
+ } else {
+ efree(name);
+ }
if (stream == NULL) {
RETURN_FALSE;
}
php_stream_to_zval(stream, return_value);
if (zcontext) {
- zend_list_addref(Z_RESVAL_P(zcontext));
+ Z_ADDREF_P(zcontext);
}
return;
}
@@ -420,18 +429,6 @@ skip_phar:
}
/* }}} */
-#ifndef S_ISDIR
-#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
-#endif
-#ifndef S_ISREG
-#define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG)
-#endif
-#ifndef S_ISLNK
-#define S_ISLNK(mode) (((mode)&S_IFMT) == S_IFLNK)
-#endif
-
-#define S_IXROOT ( S_IXUSR | S_IXGRP | S_IXOTH )
-
#define IS_LINK_OPERATION(__t) ((__t) == FS_TYPE || (__t) == FS_IS_LINK || (__t) == FS_LSTAT)
#define IS_EXISTS_CHECK(__t) ((__t) == FS_EXISTS || (__t) == FS_IS_W || (__t) == FS_IS_R || (__t) == FS_IS_X || (__t) == FS_IS_FILE || (__t) == FS_IS_DIR || (__t) == FS_IS_LINK)
#define IS_ABLE_CHECK(__t) ((__t) == FS_IS_R || (__t) == FS_IS_W || (__t) == FS_IS_X)
@@ -439,10 +436,10 @@ skip_phar:
/* {{{ php_stat
*/
-static void phar_fancy_stat(struct stat *stat_sb, int type, zval *return_value TSRMLS_DC)
+static void phar_fancy_stat(zend_stat_t *stat_sb, int type, zval *return_value)
{
- zval *stat_dev, *stat_ino, *stat_mode, *stat_nlink, *stat_uid, *stat_gid, *stat_rdev,
- *stat_size, *stat_atime, *stat_mtime, *stat_ctime, *stat_blksize, *stat_blocks;
+ zval stat_dev, stat_ino, stat_mode, stat_nlink, stat_uid, stat_gid, stat_rdev,
+ stat_size, stat_atime, stat_mtime, stat_ctime, stat_blksize, stat_blocks;
int rmask=S_IROTH, wmask=S_IWOTH, xmask=S_IXOTH; /* access rights defaults to other */
char *stat_sb_names[13] = {
"dev", "ino", "mode", "nlink", "uid", "gid", "rdev",
@@ -483,43 +480,43 @@ static void phar_fancy_stat(struct stat *stat_sb, int type, zval *return_value T
switch (type) {
case FS_PERMS:
- RETURN_LONG((long)stat_sb->st_mode);
+ RETURN_LONG((zend_long)stat_sb->st_mode);
case FS_INODE:
- RETURN_LONG((long)stat_sb->st_ino);
+ RETURN_LONG((zend_long)stat_sb->st_ino);
case FS_SIZE:
- RETURN_LONG((long)stat_sb->st_size);
+ RETURN_LONG((zend_long)stat_sb->st_size);
case FS_OWNER:
- RETURN_LONG((long)stat_sb->st_uid);
+ RETURN_LONG((zend_long)stat_sb->st_uid);
case FS_GROUP:
- RETURN_LONG((long)stat_sb->st_gid);
+ RETURN_LONG((zend_long)stat_sb->st_gid);
case FS_ATIME:
#ifdef NETWARE
- RETURN_LONG((long)stat_sb->st_atime.tv_sec);
+ RETURN_LONG((zend_long)stat_sb->st_atime.tv_sec);
#else
- RETURN_LONG((long)stat_sb->st_atime);
+ RETURN_LONG((zend_long)stat_sb->st_atime);
#endif
case FS_MTIME:
#ifdef NETWARE
- RETURN_LONG((long)stat_sb->st_mtime.tv_sec);
+ RETURN_LONG((zend_long)stat_sb->st_mtime.tv_sec);
#else
- RETURN_LONG((long)stat_sb->st_mtime);
+ RETURN_LONG((zend_long)stat_sb->st_mtime);
#endif
case FS_CTIME:
#ifdef NETWARE
- RETURN_LONG((long)stat_sb->st_ctime.tv_sec);
+ RETURN_LONG((zend_long)stat_sb->st_ctime.tv_sec);
#else
- RETURN_LONG((long)stat_sb->st_ctime);
+ RETURN_LONG((zend_long)stat_sb->st_ctime);
#endif
case FS_TYPE:
if (S_ISLNK(stat_sb->st_mode)) {
- RETURN_STRING("link", 1);
+ RETURN_STRING("link");
}
switch(stat_sb->st_mode & S_IFMT) {
- case S_IFDIR: RETURN_STRING("dir", 1);
- case S_IFREG: RETURN_STRING("file", 1);
+ case S_IFDIR: RETURN_STRING("dir");
+ case S_IFREG: RETURN_STRING("file");
}
- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unknown file type (%u)", stat_sb->st_mode & S_IFMT);
- RETURN_STRING("unknown", 1);
+ php_error_docref(NULL, E_NOTICE, "Unknown file type (%u)", stat_sb->st_mode & S_IFMT);
+ RETURN_STRING("unknown");
case FS_IS_W:
RETURN_BOOL((stat_sb->st_mode & wmask) != 0);
case FS_IS_R:
@@ -539,71 +536,71 @@ static void phar_fancy_stat(struct stat *stat_sb, int type, zval *return_value T
case FS_STAT:
array_init(return_value);
- MAKE_LONG_ZVAL_INCREF(stat_dev, stat_sb->st_dev);
- MAKE_LONG_ZVAL_INCREF(stat_ino, stat_sb->st_ino);
- MAKE_LONG_ZVAL_INCREF(stat_mode, stat_sb->st_mode);
- MAKE_LONG_ZVAL_INCREF(stat_nlink, stat_sb->st_nlink);
- MAKE_LONG_ZVAL_INCREF(stat_uid, stat_sb->st_uid);
- MAKE_LONG_ZVAL_INCREF(stat_gid, stat_sb->st_gid);
+ ZVAL_LONG(&stat_dev, stat_sb->st_dev);
+ ZVAL_LONG(&stat_ino, stat_sb->st_ino);
+ ZVAL_LONG(&stat_mode, stat_sb->st_mode);
+ ZVAL_LONG(&stat_nlink, stat_sb->st_nlink);
+ ZVAL_LONG(&stat_uid, stat_sb->st_uid);
+ ZVAL_LONG(&stat_gid, stat_sb->st_gid);
#ifdef HAVE_ST_RDEV
- MAKE_LONG_ZVAL_INCREF(stat_rdev, stat_sb->st_rdev);
+ ZVAL_LONG(&stat_rdev, stat_sb->st_rdev);
#else
- MAKE_LONG_ZVAL_INCREF(stat_rdev, -1);
+ ZVAL_LONG(&stat_rdev, -1);
#endif
- MAKE_LONG_ZVAL_INCREF(stat_size, stat_sb->st_size);
+ ZVAL_LONG(&stat_size, stat_sb->st_size);
#ifdef NETWARE
- MAKE_LONG_ZVAL_INCREF(stat_atime, (stat_sb->st_atime).tv_sec);
- MAKE_LONG_ZVAL_INCREF(stat_mtime, (stat_sb->st_mtime).tv_sec);
- MAKE_LONG_ZVAL_INCREF(stat_ctime, (stat_sb->st_ctime).tv_sec);
+ ZVAL_LONG(&stat_atime, (stat_sb->st_atime).tv_sec);
+ ZVAL_LONG(&stat_mtime, (stat_sb->st_mtime).tv_sec);
+ ZVAL_LONG(&stat_ctime, (stat_sb->st_ctime).tv_sec);
#else
- MAKE_LONG_ZVAL_INCREF(stat_atime, stat_sb->st_atime);
- MAKE_LONG_ZVAL_INCREF(stat_mtime, stat_sb->st_mtime);
- MAKE_LONG_ZVAL_INCREF(stat_ctime, stat_sb->st_ctime);
+ ZVAL_LONG(&stat_atime, stat_sb->st_atime);
+ ZVAL_LONG(&stat_mtime, stat_sb->st_mtime);
+ ZVAL_LONG(&stat_ctime, stat_sb->st_ctime);
#endif
#ifdef HAVE_ST_BLKSIZE
- MAKE_LONG_ZVAL_INCREF(stat_blksize, stat_sb->st_blksize);
+ ZVAL_LONG(&stat_blksize, stat_sb->st_blksize);
#else
- MAKE_LONG_ZVAL_INCREF(stat_blksize,-1);
+ ZVAL_LONG(&stat_blksize,-1);
#endif
#ifdef HAVE_ST_BLOCKS
- MAKE_LONG_ZVAL_INCREF(stat_blocks, stat_sb->st_blocks);
+ ZVAL_LONG(&stat_blocks, stat_sb->st_blocks);
#else
- MAKE_LONG_ZVAL_INCREF(stat_blocks,-1);
+ ZVAL_LONG(&stat_blocks,-1);
#endif
/* Store numeric indexes in proper order */
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_dev, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_ino, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_mode, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_nlink, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_uid, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_gid, sizeof(zval *), NULL);
-
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_rdev, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_size, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_atime, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_mtime, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_ctime, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_blksize, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_blocks, sizeof(zval *), NULL);
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &stat_dev);
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &stat_ino);
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &stat_mode);
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &stat_nlink);
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &stat_uid);
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &stat_gid);
+
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &stat_rdev);
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &stat_size);
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &stat_atime);
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &stat_mtime);
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &stat_ctime);
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &stat_blksize);
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &stat_blocks);
/* Store string indexes referencing the same zval*/
- zend_hash_update(HASH_OF(return_value), stat_sb_names[0], strlen(stat_sb_names[0])+1, (void *) &stat_dev, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[1], strlen(stat_sb_names[1])+1, (void *) &stat_ino, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[2], strlen(stat_sb_names[2])+1, (void *) &stat_mode, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[3], strlen(stat_sb_names[3])+1, (void *) &stat_nlink, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[4], strlen(stat_sb_names[4])+1, (void *) &stat_uid, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[5], strlen(stat_sb_names[5])+1, (void *) &stat_gid, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[6], strlen(stat_sb_names[6])+1, (void *) &stat_rdev, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[7], strlen(stat_sb_names[7])+1, (void *) &stat_size, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[8], strlen(stat_sb_names[8])+1, (void *) &stat_atime, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[9], strlen(stat_sb_names[9])+1, (void *) &stat_mtime, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[10], strlen(stat_sb_names[10])+1, (void *) &stat_ctime, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[11], strlen(stat_sb_names[11])+1, (void *) &stat_blksize, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[12], strlen(stat_sb_names[12])+1, (void *) &stat_blocks, sizeof(zval *), NULL);
+ zend_hash_str_update(Z_ARRVAL_P(return_value), stat_sb_names[0], strlen(stat_sb_names[0]), &stat_dev);
+ zend_hash_str_update(Z_ARRVAL_P(return_value), stat_sb_names[1], strlen(stat_sb_names[1]), &stat_ino);
+ zend_hash_str_update(Z_ARRVAL_P(return_value), stat_sb_names[2], strlen(stat_sb_names[2]), &stat_mode);
+ zend_hash_str_update(Z_ARRVAL_P(return_value), stat_sb_names[3], strlen(stat_sb_names[3]), &stat_nlink);
+ zend_hash_str_update(Z_ARRVAL_P(return_value), stat_sb_names[4], strlen(stat_sb_names[4]), &stat_uid);
+ zend_hash_str_update(Z_ARRVAL_P(return_value), stat_sb_names[5], strlen(stat_sb_names[5]), &stat_gid);
+ zend_hash_str_update(Z_ARRVAL_P(return_value), stat_sb_names[6], strlen(stat_sb_names[6]), &stat_rdev);
+ zend_hash_str_update(Z_ARRVAL_P(return_value), stat_sb_names[7], strlen(stat_sb_names[7]), &stat_size);
+ zend_hash_str_update(Z_ARRVAL_P(return_value), stat_sb_names[8], strlen(stat_sb_names[8]), &stat_atime);
+ zend_hash_str_update(Z_ARRVAL_P(return_value), stat_sb_names[9], strlen(stat_sb_names[9]), &stat_mtime);
+ zend_hash_str_update(Z_ARRVAL_P(return_value), stat_sb_names[10], strlen(stat_sb_names[10]), &stat_ctime);
+ zend_hash_str_update(Z_ARRVAL_P(return_value), stat_sb_names[11], strlen(stat_sb_names[11]), &stat_blksize);
+ zend_hash_str_update(Z_ARRVAL_P(return_value), stat_sb_names[12], strlen(stat_sb_names[12]), &stat_blocks);
return;
}
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Didn't understand stat call");
+ php_error_docref(NULL, E_WARNING, "Didn't understand stat call");
RETURN_FALSE;
}
/* }}} */
@@ -617,11 +614,11 @@ static void phar_file_stat(const char *filename, php_stat_len filename_length, i
if (!IS_ABSOLUTE_PATH(filename, filename_length) && !strstr(filename, "://")) {
char *arch, *entry, *fname;
int arch_len, entry_len, fname_len;
- struct stat sb = {0};
+ zend_stat_t sb = {0};
phar_entry_info *data = NULL;
phar_archive_data *phar;
- fname = (char*)zend_get_executed_filename(TSRMLS_C);
+ fname = (char*)zend_get_executed_filename();
/* we are checking for existence of a file within the relative path. Chances are good that this is
retrieving something from within the phar archive */
@@ -639,31 +636,31 @@ static void phar_file_stat(const char *filename, php_stat_len filename_length, i
phar = PHAR_G(last_phar);
goto splitted;
}
- if (SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0 TSRMLS_CC)) {
+ if (SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0)) {
efree(entry);
entry = estrndup(filename, filename_length);
/* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
entry_len = (int) filename_length;
- if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL TSRMLS_CC)) {
+ if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL)) {
efree(arch);
efree(entry);
goto skip_phar;
}
splitted:
- entry = phar_fix_filepath(entry, &entry_len, 1 TSRMLS_CC);
+ entry = phar_fix_filepath(entry, &entry_len, 1);
if (entry[0] == '/') {
- if (SUCCESS == zend_hash_find(&(phar->manifest), entry + 1, entry_len - 1, (void **) &data)) {
+ if (NULL != (data = zend_hash_str_find_ptr(&(phar->manifest), entry + 1, entry_len - 1))) {
efree(entry);
goto stat_entry;
}
goto notfound;
}
- if (SUCCESS == zend_hash_find(&(phar->manifest), entry, entry_len, (void **) &data)) {
+ if (NULL != (data = zend_hash_str_find_ptr(&(phar->manifest), entry, entry_len))) {
efree(entry);
goto stat_entry;
}
- if (zend_hash_exists(&(phar->virtual_dirs), entry, entry_len)) {
+ if (zend_hash_str_exists(&(phar->virtual_dirs), entry, entry_len)) {
efree(entry);
efree(arch);
if (IS_EXISTS_CHECK(type)) {
@@ -696,8 +693,8 @@ notfound:
PHAR_G(cwd) = "/";
PHAR_G(cwd_len) = 0;
/* clean path without cwd */
- entry = phar_fix_filepath(entry, &entry_len, 1 TSRMLS_CC);
- if (SUCCESS == zend_hash_find(&(phar->manifest), entry + 1, entry_len - 1, (void **) &data)) {
+ entry = phar_fix_filepath(entry, &entry_len, 1);
+ if (NULL != (data = zend_hash_str_find_ptr(&(phar->manifest), entry + 1, entry_len - 1))) {
PHAR_G(cwd) = save;
PHAR_G(cwd_len) = save_len;
efree(entry);
@@ -707,7 +704,7 @@ notfound:
}
goto stat_entry;
}
- if (zend_hash_exists(&(phar->virtual_dirs), entry + 1, entry_len - 1)) {
+ if (zend_hash_str_exists(&(phar->virtual_dirs), entry + 1, entry_len - 1)) {
PHAR_G(cwd) = save;
PHAR_G(cwd_len) = save_len;
efree(entry);
@@ -735,7 +732,7 @@ notfound:
efree(arch);
/* Error Occurred */
if (!IS_EXISTS_CHECK(type)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%sstat failed for %s", IS_LINK_OPERATION(type) ? "L" : "", filename);
+ php_error_docref(NULL, E_WARNING, "%sstat failed for %s", IS_LINK_OPERATION(type) ? "L" : "", filename);
}
RETURN_FALSE;
}
@@ -795,7 +792,7 @@ statme_baby:
sb.st_blksize = -1;
sb.st_blocks = -1;
#endif
- phar_fancy_stat(&sb, type, return_value TSRMLS_CC);
+ phar_fancy_stat(&sb, type, return_value);
return;
}
}
@@ -811,9 +808,9 @@ void fname(INTERNAL_FUNCTION_PARAMETERS) { \
PHAR_G(orig)(INTERNAL_FUNCTION_PARAM_PASSTHRU); \
} else { \
char *filename; \
- int filename_len; \
+ size_t filename_len; \
\
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) { \
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &filename, &filename_len) == FAILURE) { \
return; \
} \
\
@@ -895,23 +892,23 @@ PharFileFunction(phar_is_dir, FS_IS_DIR, orig_is_dir)
PHAR_FUNC(phar_is_file) /* {{{ */
{
char *filename;
- int filename_len;
+ size_t filename_len;
if (!PHAR_G(intercepted)) {
goto skip_phar;
}
- if ((PHAR_GLOBALS->phar_fname_map.arBuckets && !zend_hash_num_elements(&(PHAR_GLOBALS->phar_fname_map)))
- && !cached_phars.arBuckets) {
+ if ((PHAR_G(phar_fname_map.u.flags) && !zend_hash_num_elements(&(PHAR_G(phar_fname_map))))
+ && !cached_phars.u.flags) {
goto skip_phar;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "p", &filename, &filename_len) == FAILURE) {
goto skip_phar;
}
if (!IS_ABSOLUTE_PATH(filename, filename_len) && !strstr(filename, "://")) {
char *arch, *entry, *fname;
int arch_len, entry_len, fname_len;
- fname = (char*)zend_get_executed_filename(TSRMLS_C);
+ fname = (char*)zend_get_executed_filename();
/* we are checking for existence of a file within the relative path. Chances are good that this is
retrieving something from within the phar archive */
@@ -920,7 +917,7 @@ PHAR_FUNC(phar_is_file) /* {{{ */
goto skip_phar;
}
fname_len = strlen(fname);
- if (SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0 TSRMLS_CC)) {
+ if (SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0)) {
phar_archive_data *phar;
efree(entry);
@@ -928,12 +925,12 @@ PHAR_FUNC(phar_is_file) /* {{{ */
/* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
entry_len = filename_len;
/* retrieving a file within the current directory, so use this if possible */
- if (SUCCESS == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL TSRMLS_CC)) {
+ if (SUCCESS == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL)) {
phar_entry_info *etemp;
- entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1 TSRMLS_CC);
+ entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1);
if (entry[0] == '/') {
- if (SUCCESS == zend_hash_find(&(phar->manifest), entry + 1, entry_len - 1, (void **) &etemp)) {
+ if (NULL != (etemp = zend_hash_str_find_ptr(&(phar->manifest), entry + 1, entry_len - 1))) {
/* this file is not in the current directory, use the original path */
found_it:
efree(entry);
@@ -941,7 +938,7 @@ found_it:
RETURN_BOOL(!etemp->is_dir);
}
} else {
- if (SUCCESS == zend_hash_find(&(phar->manifest), entry, entry_len, (void **) &etemp)) {
+ if (NULL != (etemp = zend_hash_str_find_ptr(&(phar->manifest), entry, entry_len))) {
goto found_it;
}
}
@@ -962,23 +959,23 @@ skip_phar:
PHAR_FUNC(phar_is_link) /* {{{ */
{
char *filename;
- int filename_len;
+ size_t filename_len;
if (!PHAR_G(intercepted)) {
goto skip_phar;
}
- if ((PHAR_GLOBALS->phar_fname_map.arBuckets && !zend_hash_num_elements(&(PHAR_GLOBALS->phar_fname_map)))
- && !cached_phars.arBuckets) {
+ if ((PHAR_G(phar_fname_map.u.flags) && !zend_hash_num_elements(&(PHAR_G(phar_fname_map))))
+ && !cached_phars.u.flags) {
goto skip_phar;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "p", &filename, &filename_len) == FAILURE) {
goto skip_phar;
}
if (!IS_ABSOLUTE_PATH(filename, filename_len) && !strstr(filename, "://")) {
char *arch, *entry, *fname;
int arch_len, entry_len, fname_len;
- fname = (char*)zend_get_executed_filename(TSRMLS_C);
+ fname = (char*)zend_get_executed_filename();
/* we are checking for existence of a file within the relative path. Chances are good that this is
retrieving something from within the phar archive */
@@ -987,7 +984,7 @@ PHAR_FUNC(phar_is_link) /* {{{ */
goto skip_phar;
}
fname_len = strlen(fname);
- if (SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0 TSRMLS_CC)) {
+ if (SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0)) {
phar_archive_data *phar;
efree(entry);
@@ -995,12 +992,12 @@ PHAR_FUNC(phar_is_link) /* {{{ */
/* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
entry_len = filename_len;
/* retrieving a file within the current directory, so use this if possible */
- if (SUCCESS == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL TSRMLS_CC)) {
+ if (SUCCESS == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL)) {
phar_entry_info *etemp;
- entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1 TSRMLS_CC);
+ entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1);
if (entry[0] == '/') {
- if (SUCCESS == zend_hash_find(&(phar->manifest), entry + 1, entry_len - 1, (void **) &etemp)) {
+ if (NULL != (etemp = zend_hash_str_find_ptr(&(phar->manifest), entry + 1, entry_len - 1))) {
/* this file is not in the current directory, use the original path */
found_it:
efree(entry);
@@ -1008,7 +1005,7 @@ found_it:
RETURN_BOOL(etemp->link);
}
} else {
- if (SUCCESS == zend_hash_find(&(phar->manifest), entry, entry_len, (void **) &etemp)) {
+ if (NULL != (etemp = zend_hash_str_find_ptr(&(phar->manifest), entry, entry_len))) {
goto found_it;
}
}
@@ -1034,8 +1031,8 @@ PharFileFunction(phar_lstat, FS_LSTAT, orig_lstat)
PharFileFunction(phar_stat, FS_STAT, orig_stat)
/* }}} */
-/* {{{ void phar_intercept_functions(TSRMLS_D) */
-void phar_intercept_functions(TSRMLS_D)
+/* {{{ void phar_intercept_functions(void) */
+void phar_intercept_functions(void)
{
if (!PHAR_G(request_init)) {
PHAR_G(cwd) = NULL;
@@ -1045,22 +1042,22 @@ void phar_intercept_functions(TSRMLS_D)
}
/* }}} */
-/* {{{ void phar_release_functions(TSRMLS_D) */
-void phar_release_functions(TSRMLS_D)
+/* {{{ void phar_release_functions(void) */
+void phar_release_functions(void)
{
PHAR_G(intercepted) = 0;
}
/* }}} */
-/* {{{ void phar_intercept_functions_init(TSRMLS_D) */
+/* {{{ void phar_intercept_functions_init(void) */
#define PHAR_INTERCEPT(func) \
PHAR_G(orig_##func) = NULL; \
- if (SUCCESS == zend_hash_find(CG(function_table), #func, sizeof(#func), (void **)&orig)) { \
+ if (NULL != (orig = zend_hash_str_find_ptr(CG(function_table), #func, sizeof(#func)-1))) { \
PHAR_G(orig_##func) = orig->internal_function.handler; \
orig->internal_function.handler = phar_##func; \
}
-void phar_intercept_functions_init(TSRMLS_D)
+void phar_intercept_functions_init(void)
{
zend_function *orig;
@@ -1090,14 +1087,14 @@ void phar_intercept_functions_init(TSRMLS_D)
}
/* }}} */
-/* {{{ void phar_intercept_functions_shutdown(TSRMLS_D) */
+/* {{{ void phar_intercept_functions_shutdown(void) */
#define PHAR_RELEASE(func) \
- if (PHAR_G(orig_##func) && SUCCESS == zend_hash_find(CG(function_table), #func, sizeof(#func), (void **)&orig)) { \
+ if (PHAR_G(orig_##func) && NULL != (orig = zend_hash_str_find_ptr(CG(function_table), #func, sizeof(#func)-1))) { \
orig->internal_function.handler = PHAR_G(orig_##func); \
} \
PHAR_G(orig_##func) = NULL;
-void phar_intercept_functions_shutdown(TSRMLS_D)
+void phar_intercept_functions_shutdown(void)
{
zend_function *orig;
@@ -1151,7 +1148,7 @@ static struct _phar_orig_functions {
void (*orig_stat)(INTERNAL_FUNCTION_PARAMETERS);
} phar_orig_functions = {NULL};
-void phar_save_orig_functions(TSRMLS_D) /* {{{ */
+void phar_save_orig_functions(void) /* {{{ */
{
phar_orig_functions.orig_fopen = PHAR_G(orig_fopen);
phar_orig_functions.orig_file_get_contents = PHAR_G(orig_file_get_contents);
@@ -1178,7 +1175,7 @@ void phar_save_orig_functions(TSRMLS_D) /* {{{ */
}
/* }}} */
-void phar_restore_orig_functions(TSRMLS_D) /* {{{ */
+void phar_restore_orig_functions(void) /* {{{ */
{
PHAR_G(orig_fopen) = phar_orig_functions.orig_fopen;
PHAR_G(orig_file_get_contents) = phar_orig_functions.orig_file_get_contents;
diff --git a/ext/phar/func_interceptors.h b/ext/phar/func_interceptors.h
index 55e8c37609..f7bc3db613 100644
--- a/ext/phar/func_interceptors.h
+++ b/ext/phar/func_interceptors.h
@@ -20,12 +20,12 @@
/* $Id$ */
BEGIN_EXTERN_C()
-void phar_intercept_functions(TSRMLS_D);
-void phar_release_functions(TSRMLS_D);
-void phar_intercept_functions_init(TSRMLS_D);
-void phar_intercept_functions_shutdown(TSRMLS_D);
-void phar_save_orig_functions(TSRMLS_D);
-void phar_restore_orig_functions(TSRMLS_D);
+void phar_intercept_functions(void);
+void phar_release_functions(void);
+void phar_intercept_functions_init(void);
+void phar_intercept_functions_shutdown(void);
+void phar_save_orig_functions(void);
+void phar_restore_orig_functions(void);
END_EXTERN_C()
/*
diff --git a/ext/phar/makestub.php b/ext/phar/makestub.php
index 2bb30e96d8..2f3c09fa4d 100644
--- a/ext/phar/makestub.php
+++ b/ext/phar/makestub.php
@@ -50,7 +50,7 @@ $stub = '/*
/* $Id$ */
-static inline void phar_get_stub(const char *index_php, const char *web, size_t *len, char **stub, const int name_len, const int web_len TSRMLS_DC)
+static inline void phar_get_stub(const char *index_php, const char *web, size_t *len, char **stub, const int name_len, const int web_len)
{
';
$s1split = str_split($s1, 2046);
diff --git a/ext/phar/phar.c b/ext/phar/phar.c
index 14b80e175e..860f5132d4 100644
--- a/ext/phar/phar.c
+++ b/ext/phar/phar.c
@@ -24,18 +24,18 @@
#include "SAPI.h"
#include "func_interceptors.h"
-static void destroy_phar_data(void *pDest);
+static void destroy_phar_data(zval *zv);
ZEND_DECLARE_MODULE_GLOBALS(phar)
-char *(*phar_save_resolve_path)(const char *filename, int filename_len TSRMLS_DC);
+zend_string *(*phar_save_resolve_path)(const char *filename, int filename_len);
/**
* set's phar->is_writeable based on the current INI value
*/
-static int phar_set_writeable_bit(void *pDest, void *argument TSRMLS_DC) /* {{{ */
+static int phar_set_writeable_bit(zval *zv, void *argument) /* {{{ */
{
zend_bool keep = *(zend_bool *)argument;
- phar_archive_data *phar = *(phar_archive_data **)pDest;
+ phar_archive_data *phar = (phar_archive_data *)Z_PTR_P(zv);
if (!phar->is_data) {
phar->is_writeable = !keep;
@@ -50,28 +50,28 @@ ZEND_INI_MH(phar_ini_modify_handler) /* {{{ */
{
zend_bool old, ini;
- if (entry->name_length == 14) {
+ if (ZSTR_LEN(entry->name) == sizeof("phar.readonly")-1) {
old = PHAR_G(readonly_orig);
} else {
old = PHAR_G(require_hash_orig);
}
- if (new_value_length == 2 && !strcasecmp("on", new_value)) {
+ if (ZSTR_LEN(new_value) == 2 && !strcasecmp("on", ZSTR_VAL(new_value))) {
ini = (zend_bool) 1;
}
- else if (new_value_length == 3 && !strcasecmp("yes", new_value)) {
+ else if (ZSTR_LEN(new_value) == 3 && !strcasecmp("yes", ZSTR_VAL(new_value))) {
ini = (zend_bool) 1;
}
- else if (new_value_length == 4 && !strcasecmp("true", new_value)) {
+ else if (ZSTR_LEN(new_value) == 4 && !strcasecmp("true", ZSTR_VAL(new_value))) {
ini = (zend_bool) 1;
}
else {
- ini = (zend_bool) atoi(new_value);
+ ini = (zend_bool) atoi(ZSTR_VAL(new_value));
}
/* do not allow unsetting in runtime */
if (stage == ZEND_INI_STAGE_STARTUP) {
- if (entry->name_length == 14) {
+ if (ZSTR_LEN(entry->name) == sizeof("phar.readonly")-1) {
PHAR_G(readonly_orig) = ini;
} else {
PHAR_G(require_hash_orig) = ini;
@@ -80,10 +80,10 @@ ZEND_INI_MH(phar_ini_modify_handler) /* {{{ */
return FAILURE;
}
- if (entry->name_length == 14) {
+ if (ZSTR_LEN(entry->name) == sizeof("phar.readonly")-1) {
PHAR_G(readonly) = ini;
- if (PHAR_GLOBALS->request_init && PHAR_GLOBALS->phar_fname_map.arBuckets) {
- zend_hash_apply_with_argument(&(PHAR_GLOBALS->phar_fname_map), phar_set_writeable_bit, (void *)&ini TSRMLS_CC);
+ if (PHAR_G(request_init) && PHAR_G(phar_fname_map.u.flags)) {
+ zend_hash_apply_with_argument(&(PHAR_G(phar_fname_map)), phar_set_writeable_bit, (void *)&ini);
}
} else {
PHAR_G(require_hash) = ini;
@@ -97,7 +97,7 @@ ZEND_INI_MH(phar_ini_modify_handler) /* {{{ */
HashTable cached_phars;
HashTable cached_alias;
-static void phar_split_cache_list(TSRMLS_D) /* {{{ */
+static void phar_split_cache_list(void) /* {{{ */
{
char *tmp;
char *key, *lasts, *end;
@@ -105,30 +105,29 @@ static void phar_split_cache_list(TSRMLS_D) /* {{{ */
phar_archive_data *phar;
uint i = 0;
- if (!PHAR_GLOBALS->cache_list || !(PHAR_GLOBALS->cache_list[0])) {
+ if (!PHAR_G(cache_list) || !(PHAR_G(cache_list)[0])) {
return;
}
ds[0] = DEFAULT_DIR_SEPARATOR;
ds[1] = '\0';
- tmp = estrdup(PHAR_GLOBALS->cache_list);
+ tmp = estrdup(PHAR_G(cache_list));
/* fake request startup */
- PHAR_GLOBALS->request_init = 1;
- if (zend_hash_init(&EG(regular_list), 0, NULL, NULL, 0) == SUCCESS) {
- EG(regular_list).nNextFreeElement=1; /* we don't want resource id 0 */
- }
+ PHAR_G(request_init) = 1;
+ zend_hash_init(&EG(regular_list), 0, NULL, NULL, 0);
+ EG(regular_list).nNextFreeElement=1; /* we don't want resource id 0 */
- PHAR_G(has_bz2) = zend_hash_exists(&module_registry, "bz2", sizeof("bz2"));
- PHAR_G(has_zlib) = zend_hash_exists(&module_registry, "zlib", sizeof("zlib"));
+ PHAR_G(has_bz2) = zend_hash_str_exists(&module_registry, "bz2", sizeof("bz2")-1);
+ PHAR_G(has_zlib) = zend_hash_str_exists(&module_registry, "zlib", sizeof("zlib")-1);
/* these two are dummies and will be destroyed later */
zend_hash_init(&cached_phars, sizeof(phar_archive_data*), zend_get_hash_value, destroy_phar_data, 1);
zend_hash_init(&cached_alias, sizeof(phar_archive_data*), zend_get_hash_value, NULL, 1);
/* these two are real and will be copied over cached_phars/cached_alias later */
- zend_hash_init(&(PHAR_GLOBALS->phar_fname_map), sizeof(phar_archive_data*), zend_get_hash_value, destroy_phar_data, 1);
- zend_hash_init(&(PHAR_GLOBALS->phar_alias_map), sizeof(phar_archive_data*), zend_get_hash_value, NULL, 1);
- PHAR_GLOBALS->manifest_cached = 1;
- PHAR_GLOBALS->persist = 1;
+ zend_hash_init(&(PHAR_G(phar_fname_map)), sizeof(phar_archive_data*), zend_get_hash_value, destroy_phar_data, 1);
+ zend_hash_init(&(PHAR_G(phar_alias_map)), sizeof(phar_archive_data*), zend_get_hash_value, NULL, 1);
+ PHAR_G(manifest_cached) = 1;
+ PHAR_G(persist) = 1;
for (key = php_strtok_r(tmp, ds, &lasts);
key;
@@ -136,30 +135,30 @@ static void phar_split_cache_list(TSRMLS_D) /* {{{ */
end = strchr(key, DEFAULT_DIR_SEPARATOR);
if (end) {
- if (SUCCESS == phar_open_from_filename(key, end - key, NULL, 0, 0, &phar, NULL TSRMLS_CC)) {
+ if (SUCCESS == phar_open_from_filename(key, end - key, NULL, 0, 0, &phar, NULL)) {
finish_up:
phar->phar_pos = i++;
php_stream_close(phar->fp);
phar->fp = NULL;
} else {
finish_error:
- PHAR_GLOBALS->persist = 0;
- PHAR_GLOBALS->manifest_cached = 0;
+ PHAR_G(persist) = 0;
+ PHAR_G(manifest_cached) = 0;
efree(tmp);
zend_hash_destroy(&(PHAR_G(phar_fname_map)));
- PHAR_GLOBALS->phar_fname_map.arBuckets = 0;
+ PHAR_G(phar_fname_map.u.flags) = 0;
zend_hash_destroy(&(PHAR_G(phar_alias_map)));
- PHAR_GLOBALS->phar_alias_map.arBuckets = 0;
+ PHAR_G(phar_alias_map.u.flags) = 0;
zend_hash_destroy(&cached_phars);
zend_hash_destroy(&cached_alias);
zend_hash_graceful_reverse_destroy(&EG(regular_list));
memset(&EG(regular_list), 0, sizeof(HashTable));
/* free cached manifests */
- PHAR_GLOBALS->request_init = 0;
+ PHAR_G(request_init) = 0;
return;
}
} else {
- if (SUCCESS == phar_open_from_filename(key, strlen(key), NULL, 0, 0, &phar, NULL TSRMLS_CC)) {
+ if (SUCCESS == phar_open_from_filename(key, strlen(key), NULL, 0, 0, &phar, NULL)) {
goto finish_up;
} else {
goto finish_error;
@@ -167,15 +166,15 @@ finish_error:
}
}
- PHAR_GLOBALS->persist = 0;
- PHAR_GLOBALS->request_init = 0;
+ PHAR_G(persist) = 0;
+ PHAR_G(request_init) = 0;
/* destroy dummy values from before */
zend_hash_destroy(&cached_phars);
zend_hash_destroy(&cached_alias);
- cached_phars = PHAR_GLOBALS->phar_fname_map;
- cached_alias = PHAR_GLOBALS->phar_alias_map;
- PHAR_GLOBALS->phar_fname_map.arBuckets = 0;
- PHAR_GLOBALS->phar_alias_map.arBuckets = 0;
+ cached_phars = PHAR_G(phar_fname_map);
+ cached_alias = PHAR_G(phar_alias_map);
+ PHAR_G(phar_fname_map.u.flags) = 0;
+ PHAR_G(phar_alias_map.u.flags) = 0;
zend_hash_graceful_reverse_destroy(&EG(regular_list));
memset(&EG(regular_list), 0, sizeof(HashTable));
efree(tmp);
@@ -184,10 +183,10 @@ finish_error:
ZEND_INI_MH(phar_ini_cache_list) /* {{{ */
{
- PHAR_G(cache_list) = new_value;
+ PHAR_G(cache_list) = ZSTR_VAL(new_value);
if (stage == ZEND_INI_STAGE_STARTUP) {
- phar_split_cache_list(TSRMLS_C);
+ phar_split_cache_list();
}
return SUCCESS;
@@ -204,7 +203,7 @@ PHP_INI_END()
* When all uses of a phar have been concluded, this frees the manifest
* and the phar slot
*/
-void phar_destroy_phar_data(phar_archive_data *phar TSRMLS_DC) /* {{{ */
+void phar_destroy_phar_data(phar_archive_data *phar) /* {{{ */
{
if (phar->alias && phar->alias != phar->fname) {
pefree(phar->alias, phar->is_persistent);
@@ -221,26 +220,26 @@ void phar_destroy_phar_data(phar_archive_data *phar TSRMLS_DC) /* {{{ */
phar->signature = NULL;
}
- if (phar->manifest.arBuckets) {
+ if (phar->manifest.u.flags) {
zend_hash_destroy(&phar->manifest);
- phar->manifest.arBuckets = NULL;
+ phar->manifest.u.flags = 0;
}
- if (phar->mounted_dirs.arBuckets) {
+ if (phar->mounted_dirs.u.flags) {
zend_hash_destroy(&phar->mounted_dirs);
- phar->mounted_dirs.arBuckets = NULL;
+ phar->mounted_dirs.u.flags = 0;
}
- if (phar->virtual_dirs.arBuckets) {
+ if (phar->virtual_dirs.u.flags) {
zend_hash_destroy(&phar->virtual_dirs);
- phar->virtual_dirs.arBuckets = NULL;
+ phar->virtual_dirs.u.flags = 0;
}
- if (phar->metadata) {
+ if (Z_TYPE(phar->metadata) != IS_UNDEF) {
if (phar->is_persistent) {
if (phar->metadata_len) {
/* for zip comments that are strings */
- free(phar->metadata);
+ free(Z_PTR(phar->metadata));
} else {
zval_internal_ptr_dtor(&phar->metadata);
}
@@ -248,7 +247,7 @@ void phar_destroy_phar_data(phar_archive_data *phar TSRMLS_DC) /* {{{ */
zval_ptr_dtor(&phar->metadata);
}
phar->metadata_len = 0;
- phar->metadata = 0;
+ ZVAL_UNDEF(&phar->metadata);
}
if (phar->fp) {
@@ -268,16 +267,16 @@ void phar_destroy_phar_data(phar_archive_data *phar TSRMLS_DC) /* {{{ */
/**
* Delete refcount and destruct if needed. On destruct return 1 else 0.
*/
-int phar_archive_delref(phar_archive_data *phar TSRMLS_DC) /* {{{ */
+int phar_archive_delref(phar_archive_data *phar) /* {{{ */
{
if (phar->is_persistent) {
return 0;
}
if (--phar->refcount < 0) {
- if (PHAR_GLOBALS->request_done
- || zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), phar->fname, phar->fname_len) != SUCCESS) {
- phar_destroy_phar_data(phar TSRMLS_CC);
+ if (PHAR_G(request_done)
+ || zend_hash_str_del(&(PHAR_G(phar_fname_map)), phar->fname, phar->fname_len) != SUCCESS) {
+ phar_destroy_phar_data(phar);
}
return 1;
} else if (!phar->refcount) {
@@ -297,8 +296,8 @@ int phar_archive_delref(phar_archive_data *phar TSRMLS_DC) /* {{{ */
if (!zend_hash_num_elements(&phar->manifest)) {
/* this is a new phar that has perhaps had an alias/metadata set, but has never
been flushed */
- if (zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), phar->fname, phar->fname_len) != SUCCESS) {
- phar_destroy_phar_data(phar TSRMLS_CC);
+ if (zend_hash_str_del(&(PHAR_G(phar_fname_map)), phar->fname, phar->fname_len) != SUCCESS) {
+ phar_destroy_phar_data(phar);
}
return 1;
}
@@ -310,13 +309,12 @@ int phar_archive_delref(phar_archive_data *phar TSRMLS_DC) /* {{{ */
/**
* Destroy phar's in shutdown, here we don't care about aliases
*/
-static void destroy_phar_data_only(void *pDest) /* {{{ */
+static void destroy_phar_data_only(zval *zv) /* {{{ */
{
- phar_archive_data *phar_data = *(phar_archive_data **) pDest;
- TSRMLS_FETCH();
+ phar_archive_data *phar_data = (phar_archive_data *) Z_PTR_P(zv);
if (EG(exception) || --phar_data->refcount < 0) {
- phar_destroy_phar_data(phar_data TSRMLS_CC);
+ phar_destroy_phar_data(phar_data);
}
}
/* }}}*/
@@ -324,18 +322,18 @@ static void destroy_phar_data_only(void *pDest) /* {{{ */
/**
* Delete aliases to phar's that got kicked out of the global table
*/
-static int phar_unalias_apply(void *pDest, void *argument TSRMLS_DC) /* {{{ */
+static int phar_unalias_apply(zval *zv, void *argument) /* {{{ */
{
- return *(void**)pDest == argument ? ZEND_HASH_APPLY_REMOVE : ZEND_HASH_APPLY_KEEP;
+ return Z_PTR_P(zv) == argument ? ZEND_HASH_APPLY_REMOVE : ZEND_HASH_APPLY_KEEP;
}
/* }}} */
/**
* Delete aliases to phar's that got kicked out of the global table
*/
-static int phar_tmpclose_apply(void *pDest TSRMLS_DC) /* {{{ */
+static int phar_tmpclose_apply(zval *zv) /* {{{ */
{
- phar_entry_info *entry = (phar_entry_info *) pDest;
+ phar_entry_info *entry = (phar_entry_info *) Z_PTR_P(zv);
if (entry->fp_type != PHAR_TMP) {
return ZEND_HASH_APPLY_KEEP;
@@ -353,23 +351,22 @@ static int phar_tmpclose_apply(void *pDest TSRMLS_DC) /* {{{ */
/**
* Filename map destructor
*/
-static void destroy_phar_data(void *pDest) /* {{{ */
+static void destroy_phar_data(zval *zv) /* {{{ */
{
- phar_archive_data *phar_data = *(phar_archive_data **) pDest;
- TSRMLS_FETCH();
+ phar_archive_data *phar_data = (phar_archive_data *)Z_PTR_P(zv);
- if (PHAR_GLOBALS->request_ends) {
+ if (PHAR_G(request_ends)) {
/* first, iterate over the manifest and close all PHAR_TMP entry fp handles,
this prevents unnecessary unfreed stream resources */
- zend_hash_apply(&(phar_data->manifest), phar_tmpclose_apply TSRMLS_CC);
- destroy_phar_data_only(pDest);
+ zend_hash_apply(&(phar_data->manifest), phar_tmpclose_apply);
+ destroy_phar_data_only(zv);
return;
}
- zend_hash_apply_with_argument(&(PHAR_GLOBALS->phar_alias_map), phar_unalias_apply, phar_data TSRMLS_CC);
+ zend_hash_apply_with_argument(&(PHAR_G(phar_alias_map)), phar_unalias_apply, phar_data);
if (--phar_data->refcount < 0) {
- phar_destroy_phar_data(phar_data TSRMLS_CC);
+ phar_destroy_phar_data(phar_data);
}
}
/* }}}*/
@@ -377,10 +374,8 @@ static void destroy_phar_data(void *pDest) /* {{{ */
/**
* destructor for the manifest hash, frees each file's entry
*/
-void destroy_phar_manifest_entry(void *pDest) /* {{{ */
+void destroy_phar_manifest_entry_int(phar_entry_info *entry) /* {{{ */
{
- phar_entry_info *entry = (phar_entry_info *)pDest;
- TSRMLS_FETCH();
if (entry->cfp) {
php_stream_close(entry->cfp);
@@ -392,11 +387,11 @@ void destroy_phar_manifest_entry(void *pDest) /* {{{ */
entry->fp = 0;
}
- if (entry->metadata) {
+ if (Z_TYPE(entry->metadata) != IS_UNDEF) {
if (entry->is_persistent) {
if (entry->metadata_len) {
/* for zip comments that are strings */
- free(entry->metadata);
+ free(Z_PTR(entry->metadata));
} else {
zval_internal_ptr_dtor(&entry->metadata);
}
@@ -404,12 +399,12 @@ void destroy_phar_manifest_entry(void *pDest) /* {{{ */
zval_ptr_dtor(&entry->metadata);
}
entry->metadata_len = 0;
- entry->metadata = 0;
+ ZVAL_UNDEF(&entry->metadata);
}
- if (entry->metadata_str.c) {
+ if (entry->metadata_str.s) {
smart_str_free(&entry->metadata_str);
- entry->metadata_str.c = 0;
+ entry->metadata_str.s = NULL;
}
pefree(entry->filename, entry->is_persistent);
@@ -426,7 +421,15 @@ void destroy_phar_manifest_entry(void *pDest) /* {{{ */
}
/* }}} */
-int phar_entry_delref(phar_entry_data *idata TSRMLS_DC) /* {{{ */
+void destroy_phar_manifest_entry(zval *zv) /* {{{ */
+{
+ phar_entry_info *entry = Z_PTR_P(zv);
+ destroy_phar_manifest_entry_int(entry);
+ pefree(entry, entry->is_persistent);
+}
+/* }}} */
+
+int phar_entry_delref(phar_entry_data *idata) /* {{{ */
{
int ret = 0;
@@ -440,12 +443,12 @@ int phar_entry_delref(phar_entry_data *idata TSRMLS_DC) /* {{{ */
}
/* if phar_get_or_create_entry_data returns a sub-directory, we have to free it */
if (idata->internal_file->is_temp_dir) {
- destroy_phar_manifest_entry((void *)idata->internal_file);
+ destroy_phar_manifest_entry_int(idata->internal_file);
efree(idata->internal_file);
}
}
- phar_archive_delref(idata->phar TSRMLS_CC);
+ phar_archive_delref(idata->phar);
efree(idata);
return ret;
}
@@ -454,7 +457,7 @@ int phar_entry_delref(phar_entry_data *idata TSRMLS_DC) /* {{{ */
/**
* Removes an entry, either by actually removing it or by marking it.
*/
-void phar_entry_remove(phar_entry_data *idata, char **error TSRMLS_DC) /* {{{ */
+void phar_entry_remove(phar_entry_data *idata, char **error) /* {{{ */
{
phar_archive_data *phar;
@@ -464,16 +467,16 @@ void phar_entry_remove(phar_entry_data *idata, char **error TSRMLS_DC) /* {{{ */
if (idata->fp && idata->fp != idata->phar->fp && idata->fp != idata->phar->ufp && idata->fp != idata->internal_file->fp) {
php_stream_close(idata->fp);
}
- zend_hash_del(&idata->phar->manifest, idata->internal_file->filename, idata->internal_file->filename_len);
+ zend_hash_str_del(&idata->phar->manifest, idata->internal_file->filename, idata->internal_file->filename_len);
idata->phar->refcount--;
efree(idata);
} else {
idata->internal_file->is_deleted = 1;
- phar_entry_delref(idata TSRMLS_CC);
+ phar_entry_delref(idata);
}
if (!phar->donotflush) {
- phar_flush(phar, 0, 0, 0, error TSRMLS_CC);
+ phar_flush(phar, 0, 0, 0, error);
}
}
/* }}} */
@@ -490,7 +493,7 @@ void phar_entry_remove(phar_entry_data *idata, char **error TSRMLS_DC) /* {{{ */
#define MAPPHAR_FAIL(msg) \
efree(savebuf);\
if (mydata) {\
- phar_destroy_phar_data(mydata TSRMLS_CC);\
+ phar_destroy_phar_data(mydata);\
}\
if (signature) {\
pefree(signature, PHAR_G(persist));\
@@ -526,7 +529,7 @@ void phar_entry_remove(phar_entry_data *idata, char **error TSRMLS_DC) /* {{{ */
/**
* Open an already loaded phar
*/
-int phar_open_parsed_phar(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC) /* {{{ */
+int phar_open_parsed_phar(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error) /* {{{ */
{
phar_archive_data *phar;
#ifdef PHP_WIN32
@@ -540,14 +543,14 @@ int phar_open_parsed_phar(char *fname, int fname_len, char *alias, int alias_len
unixfname = estrndup(fname, fname_len);
phar_unixify_path_separators(unixfname, fname_len);
- if (SUCCESS == phar_get_archive(&phar, unixfname, fname_len, alias, alias_len, error TSRMLS_CC)
+ if (SUCCESS == phar_get_archive(&phar, unixfname, fname_len, alias, alias_len, error)
&& ((alias && fname_len == phar->fname_len
&& !strncmp(unixfname, phar->fname, fname_len)) || !alias)
) {
phar_entry_info *stub;
efree(unixfname);
#else
- if (SUCCESS == phar_get_archive(&phar, fname, fname_len, alias, alias_len, error TSRMLS_CC)
+ if (SUCCESS == phar_get_archive(&phar, fname, fname_len, alias, alias_len, error)
&& ((alias && fname_len == phar->fname_len
&& !strncmp(fname, phar->fname, fname_len)) || !alias)
) {
@@ -562,7 +565,7 @@ int phar_open_parsed_phar(char *fname, int fname_len, char *alias, int alias_len
if (!is_data) {
/* prevent any ".phar" without a stub getting through */
if (!phar->halt_offset && !phar->is_brandnew && (phar->is_tar || phar->is_zip)) {
- if (PHAR_G(readonly) && FAILURE == zend_hash_find(&(phar->manifest), ".phar/stub.php", sizeof(".phar/stub.php")-1, (void **)&stub)) {
+ if (PHAR_G(readonly) && NULL == (stub = zend_hash_str_find_ptr(&(phar->manifest), ".phar/stub.php", sizeof(".phar/stub.php")-1))) {
if (error) {
spprintf(error, 0, "'%s' is not a phar archive. Use PharData::__construct() for a standard zip or tar archive", fname);
}
@@ -601,7 +604,7 @@ int phar_open_parsed_phar(char *fname, int fname_len, char *alias, int alias_len
*
* data is the serialized zval
*/
-int phar_parse_metadata(char **buffer, zval **metadata, php_uint32 zip_metadata_len TSRMLS_DC) /* {{{ */
+int phar_parse_metadata(char **buffer, zval *metadata, php_uint32 zip_metadata_len) /* {{{ */
{
php_unserialize_data_t var_hash;
@@ -609,15 +612,14 @@ int phar_parse_metadata(char **buffer, zval **metadata, php_uint32 zip_metadata_
const unsigned char *p;
unsigned char *p_buff = (unsigned char *)estrndup(*buffer, zip_metadata_len);
p = p_buff;
- ALLOC_ZVAL(*metadata);
- INIT_ZVAL(**metadata);
+ ZVAL_NULL(metadata);
PHP_VAR_UNSERIALIZE_INIT(var_hash);
- if (!php_var_unserialize(metadata, &p, p + zip_metadata_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(metadata, &p, p + zip_metadata_len, &var_hash)) {
efree(p_buff);
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
zval_ptr_dtor(metadata);
- *metadata = NULL;
+ ZVAL_UNDEF(metadata);
return FAILURE;
}
efree(p_buff);
@@ -626,12 +628,12 @@ int phar_parse_metadata(char **buffer, zval **metadata, php_uint32 zip_metadata_
if (PHAR_G(persist)) {
/* lazy init metadata */
zval_ptr_dtor(metadata);
- *metadata = (zval *) pemalloc(zip_metadata_len, 1);
- memcpy(*metadata, *buffer, zip_metadata_len);
+ Z_PTR_P(metadata) = pemalloc(zip_metadata_len, 1);
+ memcpy(Z_PTR_P(metadata), *buffer, zip_metadata_len);
return SUCCESS;
}
} else {
- *metadata = NULL;
+ ZVAL_UNDEF(metadata);
}
return SUCCESS;
@@ -647,7 +649,7 @@ int phar_parse_metadata(char **buffer, zval **metadata, php_uint32 zip_metadata_
* This is used by phar_open_from_filename to process the manifest, but can be called
* directly.
*/
-static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char *alias, int alias_len, long halt_offset, phar_archive_data** pphar, php_uint32 compression, char **error TSRMLS_DC) /* {{{ */
+static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char *alias, int alias_len, zend_long halt_offset, phar_archive_data** pphar, php_uint32 compression, char **error) /* {{{ */
{
char b32[4], *buffer, *endbuffer, *savebuf;
phar_archive_data *mydata = NULL;
@@ -655,7 +657,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
php_uint32 manifest_len, manifest_count, manifest_flags, manifest_index, tmp_len, sig_flags;
php_uint16 manifest_ver;
php_uint32 len;
- long offset;
+ zend_long offset;
int sig_len, register_alias = 0, temp_alias = 0;
char *signature = NULL;
@@ -757,7 +759,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
/* be ignored on reading because it is being generated anyways. */
if (manifest_flags & PHAR_HDR_SIGNATURE) {
char sig_buf[8], *sig_ptr = sig_buf;
- off_t read_len;
+ zend_off_t read_len;
size_t end_of_phar;
if (-1 == php_stream_seek(fp, -8, SEEK_END)
@@ -778,7 +780,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
case PHAR_SIG_OPENSSL: {
php_uint32 signature_len;
char *sig;
- off_t whence;
+ zend_off_t whence;
/* we store the signature followed by the signature length */
if (-1 == php_stream_seek(fp, -12, SEEK_CUR)
@@ -809,7 +811,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
return FAILURE;
}
- if (FAILURE == phar_verify_signature(fp, end_of_phar, PHAR_SIG_OPENSSL, sig, signature_len, fname, &signature, &sig_len, error TSRMLS_CC)) {
+ if (FAILURE == phar_verify_signature(fp, end_of_phar, PHAR_SIG_OPENSSL, sig, signature_len, fname, &signature, &sig_len, error)) {
efree(savebuf);
efree(sig);
php_stream_close(fp);
@@ -839,7 +841,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
return FAILURE;
}
- if (FAILURE == phar_verify_signature(fp, read_len, PHAR_SIG_SHA512, (char *)digest, 64, fname, &signature, &sig_len, error TSRMLS_CC)) {
+ if (FAILURE == phar_verify_signature(fp, read_len, PHAR_SIG_SHA512, (char *)digest, 64, fname, &signature, &sig_len, error)) {
efree(savebuf);
php_stream_close(fp);
if (error) {
@@ -866,7 +868,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
return FAILURE;
}
- if (FAILURE == phar_verify_signature(fp, read_len, PHAR_SIG_SHA256, (char *)digest, 32, fname, &signature, &sig_len, error TSRMLS_CC)) {
+ if (FAILURE == phar_verify_signature(fp, read_len, PHAR_SIG_SHA256, (char *)digest, 32, fname, &signature, &sig_len, error)) {
efree(savebuf);
php_stream_close(fp);
if (error) {
@@ -904,7 +906,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
return FAILURE;
}
- if (FAILURE == phar_verify_signature(fp, read_len, PHAR_SIG_SHA1, (char *)digest, 20, fname, &signature, &sig_len, error TSRMLS_CC)) {
+ if (FAILURE == phar_verify_signature(fp, read_len, PHAR_SIG_SHA1, (char *)digest, 20, fname, &signature, &sig_len, error)) {
efree(savebuf);
php_stream_close(fp);
if (error) {
@@ -931,7 +933,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
return FAILURE;
}
- if (FAILURE == phar_verify_signature(fp, read_len, PHAR_SIG_MD5, (char *)digest, 16, fname, &signature, &sig_len, error TSRMLS_CC)) {
+ if (FAILURE == phar_verify_signature(fp, read_len, PHAR_SIG_MD5, (char *)digest, 16, fname, &signature, &sig_len, error)) {
efree(savebuf);
php_stream_close(fp);
if (error) {
@@ -1031,7 +1033,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
if(len > endbuffer - buffer) {
MAPPHAR_FAIL("internal corruption of phar \"%s\" (trying to read past buffer end)");
}
- if (phar_parse_metadata(&buffer, &mydata->metadata, len TSRMLS_CC) == FAILURE) {
+ if (phar_parse_metadata(&buffer, &mydata->metadata, len) == FAILURE) {
MAPPHAR_FAIL("unable to read phar metadata in .phar file \"%s\"");
}
buffer += len;
@@ -1079,7 +1081,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
entry.is_dir = 0;
}
- phar_add_virtual_dirs(mydata, buffer, entry.filename_len TSRMLS_CC);
+ phar_add_virtual_dirs(mydata, buffer, entry.filename_len);
entry.filename = pestrndup(buffer, entry.filename_len, entry.is_persistent);
buffer += entry.filename_len;
PHAR_GET_32(buffer, entry.uncompressed_filesize);
@@ -1115,7 +1117,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
pefree(entry.filename, entry.is_persistent);
MAPPHAR_FAIL("internal corruption of phar \"%s\" (truncated manifest entry)");
}
- if (phar_parse_metadata(&buffer, &entry.metadata, len TSRMLS_CC) == FAILURE) {
+ if (phar_parse_metadata(&buffer, &entry.metadata, len) == FAILURE) {
pefree(entry.filename, entry.is_persistent);
MAPPHAR_FAIL("unable to read file metadata in .phar file \"%s\"");
}
@@ -1127,9 +1129,9 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
switch (entry.flags & PHAR_ENT_COMPRESSION_MASK) {
case PHAR_ENT_COMPRESSED_GZ:
if (!PHAR_G(has_zlib)) {
- if (entry.metadata) {
+ if (Z_TYPE(entry.metadata) != IS_UNDEF) {
if (entry.is_persistent) {
- free(entry.metadata);
+ free(Z_PTR(entry.metadata));
} else {
zval_ptr_dtor(&entry.metadata);
}
@@ -1140,9 +1142,9 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
break;
case PHAR_ENT_COMPRESSED_BZ2:
if (!PHAR_G(has_bz2)) {
- if (entry.metadata) {
+ if (Z_TYPE(entry.metadata) != IS_UNDEF) {
if (entry.is_persistent) {
- free(entry.metadata);
+ free(Z_PTR(entry.metadata));
} else {
zval_ptr_dtor(&entry.metadata);
}
@@ -1153,9 +1155,9 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
break;
default:
if (entry.uncompressed_filesize != entry.compressed_filesize) {
- if (entry.metadata) {
+ if (Z_TYPE(entry.metadata) != IS_UNDEF) {
if (entry.is_persistent) {
- free(entry.metadata);
+ free(Z_PTR(entry.metadata));
} else {
zval_ptr_dtor(&entry.metadata);
}
@@ -1169,8 +1171,8 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
manifest_flags |= (entry.flags & PHAR_ENT_COMPRESSION_MASK);
/* if signature matched, no need to check CRC32 for each file */
entry.is_crc_checked = (manifest_flags & PHAR_HDR_SIGNATURE ? 1 : 0);
- phar_set_inode(&entry TSRMLS_CC);
- zend_hash_add(&mydata->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info), NULL);
+ phar_set_inode(&entry);
+ zend_hash_str_add_mem(&mydata->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info));
}
snprintf(mydata->version, sizeof(mydata->version), "%u.%u.%u", manifest_ver >> 12, (manifest_ver >> 8) & 0xF, (manifest_ver >> 4) & 0xF);
@@ -1197,10 +1199,10 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
mydata->fp = fp;
mydata->sig_len = sig_len;
mydata->signature = signature;
- phar_request_initialize(TSRMLS_C);
+ phar_request_initialize();
if (register_alias) {
- phar_archive_data **fd_ptr;
+ phar_archive_data *fd_ptr;
mydata->is_temporary_alias = temp_alias;
@@ -1210,20 +1212,20 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
MAPPHAR_FAIL("Cannot open archive \"%s\", invalid alias");
}
- if (SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void **)&fd_ptr)) {
- if (SUCCESS != phar_free_alias(*fd_ptr, alias, alias_len TSRMLS_CC)) {
+ if (NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len))) {
+ if (SUCCESS != phar_free_alias(fd_ptr, alias, alias_len)) {
signature = NULL;
fp = NULL;
MAPPHAR_FAIL("Cannot open archive \"%s\", alias is already in use by existing archive");
}
}
- zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void*)&mydata, sizeof(phar_archive_data*), NULL);
+ zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len, mydata);
} else {
mydata->is_temporary_alias = 1;
}
- zend_hash_add(&(PHAR_GLOBALS->phar_fname_map), mydata->fname, fname_len, (void*)&mydata, sizeof(phar_archive_data*), NULL);
+ zend_hash_str_add_ptr(&(PHAR_G(phar_fname_map)), mydata->fname, fname_len, mydata);
efree(savebuf);
if (pphar) {
@@ -1237,7 +1239,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
/**
* Create or open a phar for writing
*/
-int phar_open_or_create_filename(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC) /* {{{ */
+int phar_open_or_create_filename(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error) /* {{{ */
{
const char *ext_str, *z;
char *my_error;
@@ -1251,12 +1253,12 @@ int phar_open_or_create_filename(char *fname, int fname_len, char *alias, int al
}
/* first try to open an existing file */
- if (phar_detect_phar_fname_ext(fname, fname_len, &ext_str, &ext_len, !is_data, 0, 1 TSRMLS_CC) == SUCCESS) {
+ if (phar_detect_phar_fname_ext(fname, fname_len, &ext_str, &ext_len, !is_data, 0, 1) == SUCCESS) {
goto check_file;
}
/* next try to create a new file */
- if (FAILURE == phar_detect_phar_fname_ext(fname, fname_len, &ext_str, &ext_len, !is_data, 1, 1 TSRMLS_CC)) {
+ if (FAILURE == phar_detect_phar_fname_ext(fname, fname_len, &ext_str, &ext_len, !is_data, 1, 1)) {
if (error) {
if (ext_len == -2) {
spprintf(error, 0, "Cannot create a phar archive from a URL like \"%s\". Phar objects can only be created from local files", fname);
@@ -1267,7 +1269,7 @@ int phar_open_or_create_filename(char *fname, int fname_len, char *alias, int al
return FAILURE;
}
check_file:
- if (phar_open_parsed_phar(fname, fname_len, alias, alias_len, is_data, options, test, &my_error TSRMLS_CC) == SUCCESS) {
+ if (phar_open_parsed_phar(fname, fname_len, alias, alias_len, is_data, options, test, &my_error) == SUCCESS) {
if (pphar) {
*pphar = *test;
}
@@ -1281,7 +1283,7 @@ check_file:
if (PHAR_G(readonly) && !(*test)->is_data && ((*test)->is_tar || (*test)->is_zip)) {
phar_entry_info *stub;
- if (FAILURE == zend_hash_find(&((*test)->manifest), ".phar/stub.php", sizeof(".phar/stub.php")-1, (void **)&stub)) {
+ if (NULL == (stub = zend_hash_str_find_ptr(&((*test)->manifest), ".phar/stub.php", sizeof(".phar/stub.php")-1))) {
spprintf(error, 0, "'%s' is not a phar archive. Use PharData::__construct() for a standard zip or tar archive", fname);
return FAILURE;
}
@@ -1302,23 +1304,24 @@ check_file:
if (ext_len > 3 && (z = memchr(ext_str, 'z', ext_len)) && ((ext_str + ext_len) - z >= 2) && !memcmp(z + 1, "ip", 2)) {
/* assume zip-based phar */
- return phar_open_or_create_zip(fname, fname_len, alias, alias_len, is_data, options, pphar, error TSRMLS_CC);
+ return phar_open_or_create_zip(fname, fname_len, alias, alias_len, is_data, options, pphar, error);
}
if (ext_len > 3 && (z = memchr(ext_str, 't', ext_len)) && ((ext_str + ext_len) - z >= 2) && !memcmp(z + 1, "ar", 2)) {
/* assume tar-based phar */
- return phar_open_or_create_tar(fname, fname_len, alias, alias_len, is_data, options, pphar, error TSRMLS_CC);
+ return phar_open_or_create_tar(fname, fname_len, alias, alias_len, is_data, options, pphar, error);
}
- return phar_create_or_parse_filename(fname, fname_len, alias, alias_len, is_data, options, pphar, error TSRMLS_CC);
+ return phar_create_or_parse_filename(fname, fname_len, alias, alias_len, is_data, options, pphar, error);
}
/* }}} */
-int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC) /* {{{ */
+int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error) /* {{{ */
{
phar_archive_data *mydata;
php_stream *fp;
- char *actual = NULL, *p;
+ zend_string *actual = NULL;
+ char *p;
if (!pphar) {
pphar = &mydata;
@@ -1328,7 +1331,7 @@ int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int a
return FAILURE;
}
#endif
- if (php_check_open_basedir(fname TSRMLS_CC)) {
+ if (php_check_open_basedir(fname)) {
return FAILURE;
}
@@ -1336,30 +1339,30 @@ int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int a
fp = php_stream_open_wrapper(fname, "rb", IGNORE_URL|STREAM_MUST_SEEK|0, &actual);
if (actual) {
- fname = actual;
- fname_len = strlen(actual);
+ fname = ZSTR_VAL(actual);
+ fname_len = ZSTR_LEN(actual);
}
if (fp) {
- if (phar_open_from_fp(fp, fname, fname_len, alias, alias_len, options, pphar, is_data, error TSRMLS_CC) == SUCCESS) {
+ if (phar_open_from_fp(fp, fname, fname_len, alias, alias_len, options, pphar, is_data, error) == SUCCESS) {
if ((*pphar)->is_data || !PHAR_G(readonly)) {
(*pphar)->is_writeable = 1;
}
if (actual) {
- efree(actual);
+ zend_string_release(actual);
}
return SUCCESS;
} else {
/* file exists, but is either corrupt or not a phar archive */
if (actual) {
- efree(actual);
+ zend_string_release(actual);
}
return FAILURE;
}
}
if (actual) {
- efree(actual);
+ zend_string_release(actual);
}
if (PHAR_G(readonly) && !is_data) {
@@ -1373,7 +1376,7 @@ int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int a
/* set up our manifest */
mydata = ecalloc(1, sizeof(phar_archive_data));
- mydata->fname = expand_filepath(fname, NULL TSRMLS_CC);
+ mydata->fname = expand_filepath(fname, NULL);
fname_len = strlen(mydata->fname);
#ifdef PHP_WIN32
phar_unixify_path_separators(mydata->fname, fname_len);
@@ -1407,8 +1410,8 @@ int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int a
mydata->fp = NULL;
mydata->is_writeable = 1;
mydata->is_brandnew = 1;
- phar_request_initialize(TSRMLS_C);
- zend_hash_add(&(PHAR_GLOBALS->phar_fname_map), mydata->fname, fname_len, (void*)&mydata, sizeof(phar_archive_data*), NULL);
+ phar_request_initialize();
+ zend_hash_str_add_ptr(&(PHAR_G(phar_fname_map)), mydata->fname, fname_len, mydata);
if (is_data) {
alias = NULL;
@@ -1417,15 +1420,15 @@ int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int a
/* assume tar format, PharData can specify other */
mydata->is_tar = 1;
} else {
- phar_archive_data **fd_ptr;
+ phar_archive_data *fd_ptr;
- if (alias && SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void **)&fd_ptr)) {
- if (SUCCESS != phar_free_alias(*fd_ptr, alias, alias_len TSRMLS_CC)) {
+ if (alias && NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len))) {
+ if (SUCCESS != phar_free_alias(fd_ptr, alias, alias_len)) {
if (error) {
spprintf(error, 4096, "phar error: phar \"%s\" cannot set alias \"%s\", already in use by another phar archive", mydata->fname, alias);
}
- zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), mydata->fname, fname_len);
+ zend_hash_str_del(&(PHAR_G(phar_fname_map)), mydata->fname, fname_len);
if (pphar) {
*pphar = NULL;
@@ -1440,14 +1443,14 @@ int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int a
}
if (alias_len && alias) {
- if (FAILURE == zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void*)&mydata, sizeof(phar_archive_data*), NULL)) {
+ if (NULL == zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len, mydata)) {
if (options & REPORT_ERRORS) {
if (error) {
spprintf(error, 0, "archive \"%s\" cannot be associated with alias \"%s\", already in use", fname, alias);
}
}
- zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), mydata->fname, fname_len);
+ zend_hash_str_del(&(PHAR_G(phar_fname_map)), mydata->fname, fname_len);
if (pphar) {
*pphar = NULL;
@@ -1468,10 +1471,10 @@ int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int a
* that the manifest is proper, then pass it to phar_parse_pharfile(). SUCCESS
* or FAILURE is returned and pphar is set to a pointer to the phar's manifest
*/
-int phar_open_from_filename(char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, char **error TSRMLS_DC) /* {{{ */
+int phar_open_from_filename(char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, char **error) /* {{{ */
{
php_stream *fp;
- char *actual;
+ zend_string *actual;
int ret, is_data = 0;
if (error) {
@@ -1482,7 +1485,7 @@ int phar_open_from_filename(char *fname, int fname_len, char *alias, int alias_l
is_data = 1;
}
- if (phar_open_parsed_phar(fname, fname_len, alias, alias_len, is_data, options, pphar, error TSRMLS_CC) == SUCCESS) {
+ if (phar_open_parsed_phar(fname, fname_len, alias, alias_len, is_data, options, pphar, error) == SUCCESS) {
return SUCCESS;
} else if (error && *error) {
return FAILURE;
@@ -1492,7 +1495,7 @@ int phar_open_from_filename(char *fname, int fname_len, char *alias, int alias_l
return FAILURE;
}
#endif
- if (php_check_open_basedir(fname TSRMLS_CC)) {
+ if (php_check_open_basedir(fname)) {
return FAILURE;
}
@@ -1505,20 +1508,20 @@ int phar_open_from_filename(char *fname, int fname_len, char *alias, int alias_l
}
}
if (actual) {
- efree(actual);
+ zend_string_release(actual);
}
return FAILURE;
}
if (actual) {
- fname = actual;
- fname_len = strlen(actual);
+ fname = ZSTR_VAL(actual);
+ fname_len = ZSTR_LEN(actual);
}
- ret = phar_open_from_fp(fp, fname, fname_len, alias, alias_len, options, pphar, is_data, error TSRMLS_CC);
+ ret = phar_open_from_fp(fp, fname, fname_len, alias, alias_len, options, pphar, is_data, error);
if (actual) {
- efree(actual);
+ zend_string_release(actual);
}
return ret;
@@ -1528,7 +1531,7 @@ int phar_open_from_filename(char *fname, int fname_len, char *alias, int alias_l
static inline char *phar_strnstr(const char *buf, int buf_len, const char *search, int search_len) /* {{{ */
{
const char *c;
- int so_far = 0;
+ ptrdiff_t so_far = 0;
if (buf_len < search_len) {
return NULL;
@@ -1559,7 +1562,7 @@ static inline char *phar_strnstr(const char *buf, int buf_len, const char *searc
* that the manifest is proper, then pass it to phar_parse_pharfile(). SUCCESS
* or FAILURE is returned and pphar is set to a pointer to the phar's manifest
*/
-static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, int is_data, char **error TSRMLS_DC) /* {{{ */
+static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, int is_data, char **error) /* {{{ */
{
const char token[] = "__HALT_COMPILER();";
const char zip_magic[] = "PK\x03\x04";
@@ -1568,9 +1571,9 @@ static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char *a
char *pos, test = '\0';
const int window_size = 1024;
char buffer[1024 + sizeof(token)]; /* a 1024 byte window + the size of the halt_compiler token (moving window) */
- const long readsize = sizeof(buffer) - sizeof(token);
- const long tokenlen = sizeof(token) - 1;
- long halt_offset;
+ const zend_long readsize = sizeof(buffer) - sizeof(token);
+ const zend_long tokenlen = sizeof(token) - 1;
+ zend_long halt_offset;
size_t got;
php_uint32 compression = PHAR_FILE_COMPRESSED_NONE;
@@ -1611,7 +1614,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char *a
#ifndef MAX_WBITS
#define MAX_WBITS 15
#endif
- add_assoc_long(&filterparams, "window", MAX_WBITS + 32);
+ add_assoc_long_ex(&filterparams, "window", sizeof("window") - 1, MAX_WBITS + 32);
/* entire file is gzip-compressed, uncompress to temporary file */
if (!(temp = php_stream_fopen_tmpfile())) {
@@ -1619,12 +1622,12 @@ static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char *a
}
php_stream_rewind(fp);
- filter = php_stream_filter_create("zlib.inflate", &filterparams, php_stream_is_persistent(fp) TSRMLS_CC);
+ filter = php_stream_filter_create("zlib.inflate", &filterparams, php_stream_is_persistent(fp));
if (!filter) {
err = 1;
- add_assoc_long(&filterparams, "window", MAX_WBITS);
- filter = php_stream_filter_create("zlib.inflate", &filterparams, php_stream_is_persistent(fp) TSRMLS_CC);
+ add_assoc_long_ex(&filterparams, "window", sizeof("window") - 1, MAX_WBITS);
+ filter = php_stream_filter_create("zlib.inflate", &filterparams, php_stream_is_persistent(fp));
zval_dtor(&filterparams);
if (!filter) {
@@ -1647,7 +1650,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char *a
}
php_stream_filter_flush(filter, 1);
- php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ php_stream_filter_remove(filter, 1);
php_stream_close(fp);
fp = temp;
php_stream_rewind(fp);
@@ -1670,7 +1673,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char *a
}
php_stream_rewind(fp);
- filter = php_stream_filter_create("bzip2.decompress", NULL, php_stream_is_persistent(fp) TSRMLS_CC);
+ filter = php_stream_filter_create("bzip2.decompress", NULL, php_stream_is_persistent(fp));
if (!filter) {
php_stream_close(temp);
@@ -1685,7 +1688,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char *a
}
php_stream_filter_flush(filter, 1);
- php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ php_stream_filter_remove(filter, 1);
php_stream_close(fp);
fp = temp;
php_stream_rewind(fp);
@@ -1698,20 +1701,20 @@ static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char *a
if (!memcmp(pos, zip_magic, 4)) {
php_stream_seek(fp, 0, SEEK_END);
- return phar_parse_zipfile(fp, fname, fname_len, alias, alias_len, pphar, error TSRMLS_CC);
+ return phar_parse_zipfile(fp, fname, fname_len, alias, alias_len, pphar, error);
}
if (got > 512) {
if (phar_is_tar(pos, fname)) {
php_stream_rewind(fp);
- return phar_parse_tarfile(fp, fname, fname_len, alias, alias_len, pphar, is_data, compression, error TSRMLS_CC);
+ return phar_parse_tarfile(fp, fname, fname_len, alias, alias_len, pphar, is_data, compression, error);
}
}
}
if (got > 0 && (pos = phar_strnstr(buffer, got + sizeof(token), token, sizeof(token)-1)) != NULL) {
halt_offset += (pos - buffer); /* no -tokenlen+tokenlen here */
- return phar_parse_pharfile(fp, fname, fname_len, alias, alias_len, halt_offset, pphar, compression, error TSRMLS_CC);
+ return phar_parse_pharfile(fp, fname, fname_len, alias, alias_len, halt_offset, pphar, compression, error);
}
halt_offset += got;
@@ -1731,23 +1734,23 @@ static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char *a
* if not, check to see if its dirname() exists (i.e. "/path/to") and is a directory
* succeed if we are creating the file, otherwise fail.
*/
-static int phar_analyze_path(const char *fname, const char *ext, int ext_len, int for_create TSRMLS_DC) /* {{{ */
+static int phar_analyze_path(const char *fname, const char *ext, int ext_len, int for_create) /* {{{ */
{
php_stream_statbuf ssb;
char *realpath;
char *filename = estrndup(fname, (ext - fname) + ext_len);
- if ((realpath = expand_filepath(filename, NULL TSRMLS_CC))) {
+ if ((realpath = expand_filepath(filename, NULL))) {
#ifdef PHP_WIN32
phar_unixify_path_separators(realpath, strlen(realpath));
#endif
- if (zend_hash_exists(&(PHAR_GLOBALS->phar_fname_map), realpath, strlen(realpath))) {
+ if (zend_hash_str_exists(&(PHAR_G(phar_fname_map)), realpath, strlen(realpath))) {
efree(realpath);
efree(filename);
return SUCCESS;
}
- if (PHAR_G(manifest_cached) && zend_hash_exists(&cached_phars, realpath, strlen(realpath))) {
+ if (PHAR_G(manifest_cached) && zend_hash_str_exists(&cached_phars, realpath, strlen(realpath))) {
efree(realpath);
efree(filename);
return SUCCESS;
@@ -1784,7 +1787,7 @@ static int phar_analyze_path(const char *fname, const char *ext, int ext_len, in
if (SUCCESS != php_stream_stat_path((char *) filename, &ssb)) {
if (!slash) {
- if (!(realpath = expand_filepath(filename, NULL TSRMLS_CC))) {
+ if (!(realpath = expand_filepath(filename, NULL))) {
efree(filename);
return FAILURE;
}
@@ -1836,7 +1839,7 @@ static int phar_analyze_path(const char *fname, const char *ext, int ext_len, in
/* }}} */
/* check for ".phar" in extension */
-static int phar_check_str(const char *fname, const char *ext_str, int ext_len, int executable, int for_create TSRMLS_DC) /* {{{ */
+static int phar_check_str(const char *fname, const char *ext_str, int ext_len, int executable, int for_create) /* {{{ */
{
char test[51];
const char *pos;
@@ -1855,7 +1858,7 @@ static int phar_check_str(const char *fname, const char *ext_str, int ext_len, i
if (pos && (*(pos - 1) != '/')
&& (pos += 5) && (*pos == '\0' || *pos == '/' || *pos == '.')) {
- return phar_analyze_path(fname, ext_str, ext_len, for_create TSRMLS_CC);
+ return phar_analyze_path(fname, ext_str, ext_len, for_create);
} else {
return FAILURE;
}
@@ -1866,11 +1869,11 @@ static int phar_check_str(const char *fname, const char *ext_str, int ext_len, i
pos = strstr(ext_str, ".phar");
if (!(pos && (*(pos - 1) != '/')
&& (pos += 5) && (*pos == '\0' || *pos == '/' || *pos == '.')) && *(ext_str + 1) != '.' && *(ext_str + 1) != '/' && *(ext_str + 1) != '\0') {
- return phar_analyze_path(fname, ext_str, ext_len, for_create TSRMLS_CC);
+ return phar_analyze_path(fname, ext_str, ext_len, for_create);
}
} else {
if (*(ext_str + 1) != '.' && *(ext_str + 1) != '/' && *(ext_str + 1) != '\0') {
- return phar_analyze_path(fname, ext_str, ext_len, for_create TSRMLS_CC);
+ return phar_analyze_path(fname, ext_str, ext_len, for_create);
}
}
@@ -1891,7 +1894,7 @@ static int phar_check_str(const char *fname, const char *ext_str, int ext_len, i
* the last parameter should be set to tell the thing to assume that filename is the full path, and only to check the
* extension rules, not to iterate.
*/
-int phar_detect_phar_fname_ext(const char *filename, int filename_len, const char **ext_str, int *ext_len, int executable, int for_create, int is_complete TSRMLS_DC) /* {{{ */
+int phar_detect_phar_fname_ext(const char *filename, int filename_len, const char **ext_str, int *ext_len, int executable, int for_create, int is_complete) /* {{{ */
{
const char *pos, *slash;
@@ -1902,7 +1905,7 @@ int phar_detect_phar_fname_ext(const char *filename, int filename_len, const cha
return FAILURE;
}
- phar_request_initialize(TSRMLS_C);
+ phar_request_initialize();
/* first check for alias in first segment */
pos = memchr(filename, '/', filename_len);
@@ -1913,85 +1916,84 @@ int phar_detect_phar_fname_ext(const char *filename, int filename_len, const cha
*ext_str = NULL;
return FAILURE;
}
- if (zend_hash_exists(&(PHAR_GLOBALS->phar_alias_map), (char *) filename, pos - filename)) {
+ if (zend_hash_str_exists(&(PHAR_G(phar_alias_map)), (char *) filename, pos - filename)) {
*ext_str = pos;
*ext_len = -1;
return FAILURE;
}
- if (PHAR_G(manifest_cached) && zend_hash_exists(&cached_alias, (char *) filename, pos - filename)) {
+ if (PHAR_G(manifest_cached) && zend_hash_str_exists(&cached_alias, (char *) filename, pos - filename)) {
*ext_str = pos;
*ext_len = -1;
return FAILURE;
}
}
- if (zend_hash_num_elements(&(PHAR_GLOBALS->phar_fname_map)) || PHAR_G(manifest_cached)) {
- phar_archive_data **pphar;
+ if (zend_hash_num_elements(&(PHAR_G(phar_fname_map))) || PHAR_G(manifest_cached)) {
+ phar_archive_data *pphar;
if (is_complete) {
- if (SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), (char *) filename, filename_len, (void **)&pphar)) {
- *ext_str = filename + (filename_len - (*pphar)->ext_len);
+ if (NULL != (pphar = zend_hash_str_find_ptr(&(PHAR_G(phar_fname_map)), (char *) filename, filename_len))) {
+ *ext_str = filename + (filename_len - pphar->ext_len);
woohoo:
- *ext_len = (*pphar)->ext_len;
+ *ext_len = pphar->ext_len;
if (executable == 2) {
return SUCCESS;
}
- if (executable == 1 && !(*pphar)->is_data) {
+ if (executable == 1 && !pphar->is_data) {
return SUCCESS;
}
- if (!executable && (*pphar)->is_data) {
+ if (!executable && pphar->is_data) {
return SUCCESS;
}
return FAILURE;
}
- if (PHAR_G(manifest_cached) && SUCCESS == zend_hash_find(&cached_phars, (char *) filename, filename_len, (void **)&pphar)) {
- *ext_str = filename + (filename_len - (*pphar)->ext_len);
+ if (PHAR_G(manifest_cached) && NULL != (pphar = zend_hash_str_find_ptr(&cached_phars, (char *) filename, filename_len))) {
+ *ext_str = filename + (filename_len - pphar->ext_len);
goto woohoo;
}
} else {
- char *str_key;
- uint keylen;
- ulong unused;
+ zend_string *str_key;
+ zend_ulong unused;
- for (zend_hash_internal_pointer_reset(&(PHAR_GLOBALS->phar_fname_map));
- HASH_KEY_NON_EXISTENT != zend_hash_get_current_key_ex(&(PHAR_GLOBALS->phar_fname_map), &str_key, &keylen, &unused, 0, NULL);
- zend_hash_move_forward(&(PHAR_GLOBALS->phar_fname_map))
+ for (zend_hash_internal_pointer_reset(&(PHAR_G(phar_fname_map)));
+ HASH_KEY_NON_EXISTENT != zend_hash_get_current_key(&(PHAR_G(phar_fname_map)), &str_key, &unused);
+ zend_hash_move_forward(&(PHAR_G(phar_fname_map)))
) {
- if (keylen > (uint) filename_len) {
+ if (ZSTR_LEN(str_key) > (uint) filename_len) {
continue;
}
- if (!memcmp(filename, str_key, keylen) && ((uint)filename_len == keylen
- || filename[keylen] == '/' || filename[keylen] == '\0')) {
- if (FAILURE == zend_hash_get_current_data(&(PHAR_GLOBALS->phar_fname_map), (void **) &pphar)) {
+ if (!memcmp(filename, ZSTR_VAL(str_key), ZSTR_LEN(str_key)) && ((uint)filename_len == ZSTR_LEN(str_key)
+ || filename[ZSTR_LEN(str_key)] == '/' || filename[ZSTR_LEN(str_key)] == '\0')) {
+ if (NULL == (pphar = zend_hash_get_current_data_ptr(&(PHAR_G(phar_fname_map))))) {
break;
}
- *ext_str = filename + (keylen - (*pphar)->ext_len);
+ *ext_str = filename + (ZSTR_LEN(str_key) - pphar->ext_len);
goto woohoo;
}
}
if (PHAR_G(manifest_cached)) {
for (zend_hash_internal_pointer_reset(&cached_phars);
- HASH_KEY_NON_EXISTENT != zend_hash_get_current_key_ex(&cached_phars, &str_key, &keylen, &unused, 0, NULL);
+ HASH_KEY_NON_EXISTENT != zend_hash_get_current_key(&cached_phars, &str_key, &unused);
zend_hash_move_forward(&cached_phars)
) {
- if (keylen > (uint) filename_len) {
+ if (ZSTR_LEN(str_key) > (uint) filename_len) {
continue;
}
- if (!memcmp(filename, str_key, keylen) && ((uint)filename_len == keylen
- || filename[keylen] == '/' || filename[keylen] == '\0')) {
- if (FAILURE == zend_hash_get_current_data(&cached_phars, (void **) &pphar)) {
+ if (!memcmp(filename, ZSTR_VAL(str_key), ZSTR_LEN(str_key)) && ((uint)filename_len == ZSTR_LEN(str_key)
+ || filename[ZSTR_LEN(str_key)] == '/' || filename[ZSTR_LEN(str_key)] == '\0')) {
+ if (NULL == (pphar = zend_hash_get_current_data_ptr(&cached_phars))) {
break;
}
- *ext_str = filename + (keylen - (*pphar)->ext_len);
+ *ext_str = filename + (ZSTR_LEN(str_key) - pphar->ext_len);
goto woohoo;
}
}
@@ -2020,7 +2022,7 @@ next_extension:
*ext_len = strlen(pos);
/* file extension must contain "phar" */
- switch (phar_check_str(filename, *ext_str, *ext_len, executable, for_create TSRMLS_CC)) {
+ switch (phar_check_str(filename, *ext_str, *ext_len, executable, for_create)) {
case SUCCESS:
return SUCCESS;
case FAILURE:
@@ -2033,7 +2035,7 @@ next_extension:
*ext_str = pos;
*ext_len = slash - pos;
- switch (phar_check_str(filename, *ext_str, *ext_len, executable, for_create TSRMLS_CC)) {
+ switch (phar_check_str(filename, *ext_str, *ext_len, executable, for_create)) {
case SUCCESS:
return SUCCESS;
case FAILURE:
@@ -2069,58 +2071,10 @@ static int php_check_dots(const char *element, int n) /* {{{ */
#define IS_BACKSLASH(c) ((c) == '/')
-#ifdef COMPILE_DL_PHAR
-/* stupid-ass non-extern declaration in tsrm_strtok.h breaks dumbass MS compiler */
-static inline int in_character_class(char ch, const char *delim) /* {{{ */
-{
- while (*delim) {
- if (*delim == ch) {
- return 1;
- }
- ++delim;
- }
- return 0;
-}
-/* }}} */
-
-char *tsrm_strtok_r(char *s, const char *delim, char **last) /* {{{ */
-{
- char *token;
-
- if (s == NULL) {
- s = *last;
- }
-
- while (*s && in_character_class(*s, delim)) {
- ++s;
- }
-
- if (!*s) {
- return NULL;
- }
-
- token = s;
-
- while (*s && !in_character_class(*s, delim)) {
- ++s;
- }
-
- if (!*s) {
- *last = s;
- } else {
- *s = '\0';
- *last = s + 1;
- }
-
- return token;
-}
-/* }}} */
-#endif
-
/**
* Remove .. and . references within a phar filename
*/
-char *phar_fix_filepath(char *path, int *new_len, int use_cwd TSRMLS_DC) /* {{{ */
+char *phar_fix_filepath(char *path, int *new_len, int use_cwd) /* {{{ */
{
char *newpath;
int newpath_len;
@@ -2234,7 +2188,7 @@ last_time:
*
* This is used by phar_parse_url()
*/
-int phar_split_fname(const char *filename, int filename_len, char **arch, int *arch_len, char **entry, int *entry_len, int executable, int for_create TSRMLS_DC) /* {{{ */
+int phar_split_fname(const char *filename, int filename_len, char **arch, int *arch_len, char **entry, int *entry_len, int executable, int for_create) /* {{{ */
{
const char *ext_str;
#ifdef PHP_WIN32
@@ -2246,6 +2200,10 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a
return FAILURE;
}
+ if (CHECK_NULL_PATH(filename, filename_len)) {
+ return FAILURE;
+ }
+
if (!strncasecmp(filename, "phar://", 7)) {
filename += 7;
filename_len -= 7;
@@ -2257,14 +2215,14 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a
filename = estrndup(filename, filename_len);
phar_unixify_path_separators(filename, filename_len);
#endif
- if (phar_detect_phar_fname_ext(filename, filename_len, &ext_str, &ext_len, executable, for_create, 0 TSRMLS_CC) == FAILURE) {
+ if (phar_detect_phar_fname_ext(filename, filename_len, &ext_str, &ext_len, executable, for_create, 0) == FAILURE) {
if (ext_len != -1) {
if (!ext_str) {
/* no / detected, restore arch for error message */
#ifdef PHP_WIN32
*arch = save;
#else
- *arch = filename;
+ *arch = (char*)filename;
#endif
}
@@ -2287,7 +2245,7 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a
#ifdef PHP_WIN32
phar_unixify_path_separators(*entry, *entry_len);
#endif
- *entry = phar_fix_filepath(*entry, entry_len, 0 TSRMLS_CC);
+ *entry = phar_fix_filepath(*entry, entry_len, 0);
} else {
*entry_len = 1;
*entry = estrndup("/", 1);
@@ -2305,23 +2263,22 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a
* Invoked when a user calls Phar::mapPhar() from within an executing .phar
* to set up its manifest directly
*/
-int phar_open_executed_filename(char *alias, int alias_len, char **error TSRMLS_DC) /* {{{ */
+int phar_open_executed_filename(char *alias, int alias_len, char **error) /* {{{ */
{
char *fname;
- zval *halt_constant;
php_stream *fp;
int fname_len;
- char *actual = NULL;
+ zend_string *actual = NULL;
int ret;
if (error) {
*error = NULL;
}
- fname = (char*)zend_get_executed_filename(TSRMLS_C);
+ fname = (char*)zend_get_executed_filename();
fname_len = strlen(fname);
- if (phar_open_parsed_phar(fname, fname_len, alias, alias_len, 0, REPORT_ERRORS, NULL, 0 TSRMLS_CC) == SUCCESS) {
+ if (phar_open_parsed_phar(fname, fname_len, alias, alias_len, 0, REPORT_ERRORS, NULL, 0) == SUCCESS) {
return SUCCESS;
}
@@ -2332,17 +2289,13 @@ int phar_open_executed_filename(char *alias, int alias_len, char **error TSRMLS_
return FAILURE;
}
- MAKE_STD_ZVAL(halt_constant);
-
- if (0 == zend_get_constant("__COMPILER_HALT_OFFSET__", 24, halt_constant TSRMLS_CC)) {
- FREE_ZVAL(halt_constant);
+ if (0 == zend_get_constant_str("__COMPILER_HALT_OFFSET__", sizeof("__COMPILER_HALT_OFFSET__")-1)) {
if (error) {
spprintf(error, 0, "__HALT_COMPILER(); must be declared in a phar");
}
return FAILURE;
}
- FREE_ZVAL(halt_constant);
#if PHP_API_VERSION < 20100412
if (PG(safe_mode) && (!php_checkuid(fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) {
@@ -2350,7 +2303,7 @@ int phar_open_executed_filename(char *alias, int alias_len, char **error TSRMLS_
}
#endif
- if (php_check_open_basedir(fname TSRMLS_CC)) {
+ if (php_check_open_basedir(fname)) {
return FAILURE;
}
@@ -2361,20 +2314,20 @@ int phar_open_executed_filename(char *alias, int alias_len, char **error TSRMLS_
spprintf(error, 0, "unable to open phar for reading \"%s\"", fname);
}
if (actual) {
- efree(actual);
+ zend_string_release(actual);
}
return FAILURE;
}
if (actual) {
- fname = actual;
- fname_len = strlen(actual);
+ fname = ZSTR_VAL(actual);
+ fname_len = ZSTR_LEN(actual);
}
- ret = phar_open_from_fp(fp, fname, fname_len, alias, alias_len, REPORT_ERRORS, NULL, 0, error TSRMLS_CC);
+ ret = phar_open_from_fp(fp, fname, fname_len, alias, alias_len, REPORT_ERRORS, NULL, 0, error);
if (actual) {
- efree(actual);
+ zend_string_release(actual);
}
return ret;
@@ -2384,7 +2337,7 @@ int phar_open_executed_filename(char *alias, int alias_len, char **error TSRMLS_
/**
* Validate the CRC32 of a file opened from within the phar
*/
-int phar_postprocess_file(phar_entry_data *idata, php_uint32 crc32, char **error, int process_zip TSRMLS_DC) /* {{{ */
+int phar_postprocess_file(phar_entry_data *idata, php_uint32 crc32, char **error, int process_zip) /* {{{ */
{
php_uint32 crc = ~0;
int len = idata->internal_file->uncompressed_filesize;
@@ -2400,13 +2353,13 @@ int phar_postprocess_file(phar_entry_data *idata, php_uint32 crc32, char **error
phar_zip_file_header local;
phar_zip_data_desc desc;
- if (SUCCESS != phar_open_archive_fp(idata->phar TSRMLS_CC)) {
+ if (SUCCESS != phar_open_archive_fp(idata->phar)) {
spprintf(error, 0, "phar error: unable to open zip-based phar archive \"%s\" to verify local file header for file \"%s\"", idata->phar->fname, entry->filename);
return FAILURE;
}
- php_stream_seek(phar_get_entrypfp(idata->internal_file TSRMLS_CC), entry->header_offset, SEEK_SET);
+ php_stream_seek(phar_get_entrypfp(idata->internal_file), entry->header_offset, SEEK_SET);
- if (sizeof(local) != php_stream_read(phar_get_entrypfp(idata->internal_file TSRMLS_CC), (char *) &local, sizeof(local))) {
+ if (sizeof(local) != php_stream_read(phar_get_entrypfp(idata->internal_file), (char *) &local, sizeof(local))) {
spprintf(error, 0, "phar error: internal corruption of zip-based phar \"%s\" (cannot read local file header for file \"%s\")", idata->phar->fname, entry->filename);
return FAILURE;
@@ -2414,12 +2367,12 @@ int phar_postprocess_file(phar_entry_data *idata, php_uint32 crc32, char **error
/* check for data descriptor */
if (((PHAR_ZIP_16(local.flags)) & 0x8) == 0x8) {
- php_stream_seek(phar_get_entrypfp(idata->internal_file TSRMLS_CC),
+ php_stream_seek(phar_get_entrypfp(idata->internal_file),
entry->header_offset + sizeof(local) +
PHAR_ZIP_16(local.filename_len) +
PHAR_ZIP_16(local.extra_len) +
entry->compressed_filesize, SEEK_SET);
- if (sizeof(desc) != php_stream_read(phar_get_entrypfp(idata->internal_file TSRMLS_CC),
+ if (sizeof(desc) != php_stream_read(phar_get_entrypfp(idata->internal_file),
(char *) &desc, sizeof(desc))) {
spprintf(error, 0, "phar error: internal corruption of zip-based phar \"%s\" (cannot read local data descriptor for file \"%s\")", idata->phar->fname, entry->filename);
return FAILURE;
@@ -2480,9 +2433,9 @@ static inline void phar_set_32(char *buffer, int var) /* {{{ */
#endif
} /* }}} */
-static int phar_flush_clean_deleted_apply(void *data TSRMLS_DC) /* {{{ */
+static int phar_flush_clean_deleted_apply(zval *zv) /* {{{ */
{
- phar_entry_info *entry = (phar_entry_info *)data;
+ phar_entry_info *entry = (phar_entry_info *)Z_PTR_P(zv);
if (entry->fp_refcount <= 0 && entry->is_deleted) {
return ZEND_HASH_APPLY_REMOVE;
@@ -2494,15 +2447,9 @@ static int phar_flush_clean_deleted_apply(void *data TSRMLS_DC) /* {{{ */
#include "stub.h"
-char *phar_create_default_stub(const char *index_php, const char *web_index, size_t *len, char **error TSRMLS_DC) /* {{{ */
+zend_string *phar_create_default_stub(const char *index_php, const char *web_index, char **error) /* {{{ */
{
- char *stub = NULL;
int index_len, web_len;
- size_t dummy;
-
- if (!len) {
- len = &dummy;
- }
if (error) {
*error = NULL;
@@ -2535,8 +2482,7 @@ char *phar_create_default_stub(const char *index_php, const char *web_index, siz
}
}
- phar_get_stub(index_php, web_index, len, &stub, index_len+1, web_len+1 TSRMLS_CC);
- return stub;
+ return phar_get_stub(index_php, web_index, index_len+1, web_len+1);
}
/* }}} */
@@ -2546,16 +2492,17 @@ char *phar_create_default_stub(const char *index_php, const char *web_index, siz
* user_stub contains either a string, or a resource pointer, if len is a negative length.
* user_stub and len should be both 0 if the default or existing stub should be used
*/
-int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert, char **error TSRMLS_DC) /* {{{ */
+int phar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int convert, char **error) /* {{{ */
{
char halt_stub[] = "__HALT_COMPILER();";
- char *newstub, *tmp;
+ zend_string *newstub;
+ char *tmp;
phar_entry_info *entry, *newentry;
int halt_offset, restore_alias_len, global_flags = 0, closeoldfile;
char *pos, has_dirs = 0;
char manifest[18], entry_buffer[24];
- off_t manifest_ftell;
- long offset;
+ zend_off_t manifest_ftell;
+ zend_long offset;
size_t wrote;
php_uint32 manifest_len, mytime, loc, new_manifest_count;
php_uint32 newcrc32;
@@ -2584,11 +2531,11 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
zend_hash_clean(&phar->virtual_dirs);
if (phar->is_zip) {
- return phar_zip_flush(phar, user_stub, len, convert, error TSRMLS_CC);
+ return phar_zip_flush(phar, user_stub, len, convert, error);
}
if (phar->is_tar) {
- return phar_tar_flush(phar, user_stub, len, convert, error TSRMLS_CC);
+ return phar_tar_flush(phar, user_stub, len, convert, error);
}
if (PHAR_G(readonly)) {
@@ -2615,9 +2562,10 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
}
if (user_stub) {
+ zend_string *suser_stub;
if (len < 0) {
/* resource passed in */
- if (!(php_stream_from_zval_no_verify(stubfile, (zval **)user_stub))) {
+ if (!(php_stream_from_zval_no_verify(stubfile, (zval *)user_stub))) {
if (closeoldfile) {
php_stream_close(oldfile);
}
@@ -2634,7 +2582,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
}
user_stub = 0;
- if (!(len = php_stream_copy_to_mem(stubfile, &user_stub, len, 0)) || !user_stub) {
+ if (!(suser_stub = php_stream_copy_to_mem(stubfile, len, 0))) {
if (closeoldfile) {
php_stream_close(oldfile);
}
@@ -2645,6 +2593,8 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
return EOF;
}
free_user_stub = 1;
+ user_stub = ZSTR_VAL(suser_stub);
+ len = ZSTR_LEN(suser_stub);
} else {
free_user_stub = 0;
}
@@ -2659,7 +2609,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
spprintf(error, 0, "illegal stub for phar \"%s\"", phar->fname);
}
if (free_user_stub) {
- efree(user_stub);
+ zend_string_free(suser_stub);
}
return EOF;
}
@@ -2676,13 +2626,13 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
spprintf(error, 0, "unable to create stub from string in new phar \"%s\"", phar->fname);
}
if (free_user_stub) {
- efree(user_stub);
+ zend_string_free(suser_stub);
}
return EOF;
}
phar->halt_offset = len + 5;
if (free_user_stub) {
- efree(user_stub);
+ zend_string_free(suser_stub);
}
} else {
size_t written;
@@ -2692,8 +2642,9 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
newstub = NULL;
} else {
/* this is either a brand new phar or a default stub overwrite */
- newstub = phar_create_default_stub(NULL, NULL, &(phar->halt_offset), NULL TSRMLS_CC);
- written = php_stream_write(newfile, newstub, phar->halt_offset);
+ newstub = phar_create_default_stub(NULL, NULL, NULL);
+ phar->halt_offset = ZSTR_LEN(newstub);
+ written = php_stream_write(newfile, ZSTR_VAL(newstub), phar->halt_offset);
}
if (phar->halt_offset != written) {
if (closeoldfile) {
@@ -2708,12 +2659,12 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
}
}
if (newstub) {
- efree(newstub);
+ zend_string_free(newstub);
}
return EOF;
}
if (newstub) {
- efree(newstub);
+ zend_string_free(newstub);
}
}
manifest_ftell = php_stream_tell(newfile);
@@ -2722,23 +2673,21 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
/* Check whether we can get rid of some of the deleted entries which are
* unused. However some might still be in use so even after this clean-up
* we need to skip entries marked is_deleted. */
- zend_hash_apply(&phar->manifest, phar_flush_clean_deleted_apply TSRMLS_CC);
+ zend_hash_apply(&phar->manifest, phar_flush_clean_deleted_apply);
/* compress as necessary, calculate crcs, serialize meta-data, manifest size, and file sizes */
- main_metadata_str.c = 0;
- if (phar->metadata) {
+ main_metadata_str.s = NULL;
+ if (Z_TYPE(phar->metadata) != IS_UNDEF) {
PHP_VAR_SERIALIZE_INIT(metadata_hash);
- php_var_serialize(&main_metadata_str, &phar->metadata, &metadata_hash TSRMLS_CC);
+ php_var_serialize(&main_metadata_str, &phar->metadata, &metadata_hash);
PHP_VAR_SERIALIZE_DESTROY(metadata_hash);
- } else {
- main_metadata_str.len = 0;
}
new_manifest_count = 0;
offset = 0;
for (zend_hash_internal_pointer_reset(&phar->manifest);
zend_hash_has_more_elements(&phar->manifest) == SUCCESS;
zend_hash_move_forward(&phar->manifest)) {
- if (zend_hash_get_current_data(&phar->manifest, (void **)&entry) == FAILURE) {
+ if ((entry = zend_hash_get_current_data_ptr(&phar->manifest)) == NULL) {
continue;
}
if (entry->cfp) {
@@ -2764,31 +2713,29 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
}
/* after excluding deleted files, calculate manifest size in bytes and number of entries */
++new_manifest_count;
- phar_add_virtual_dirs(phar, entry->filename, entry->filename_len TSRMLS_CC);
+ phar_add_virtual_dirs(phar, entry->filename, entry->filename_len);
if (entry->is_dir) {
/* we use this to calculate API version, 1.1.1 is used for phars with directories */
has_dirs = 1;
}
- if (entry->metadata) {
- if (entry->metadata_str.c) {
+ if (Z_TYPE(entry->metadata) != IS_UNDEF) {
+ if (entry->metadata_str.s) {
smart_str_free(&entry->metadata_str);
}
- entry->metadata_str.c = 0;
- entry->metadata_str.len = 0;
+ entry->metadata_str.s = NULL;
PHP_VAR_SERIALIZE_INIT(metadata_hash);
- php_var_serialize(&entry->metadata_str, &entry->metadata, &metadata_hash TSRMLS_CC);
+ php_var_serialize(&entry->metadata_str, &entry->metadata, &metadata_hash);
PHP_VAR_SERIALIZE_DESTROY(metadata_hash);
} else {
- if (entry->metadata_str.c) {
+ if (entry->metadata_str.s) {
smart_str_free(&entry->metadata_str);
}
- entry->metadata_str.c = 0;
- entry->metadata_str.len = 0;
+ entry->metadata_str.s = NULL;
}
/* 32 bits for filename length, length of filename, manifest + metadata, and add 1 for trailing / if a directory */
- offset += 4 + entry->filename_len + sizeof(entry_buffer) + entry->metadata_str.len + (entry->is_dir ? 1 : 0);
+ offset += 4 + entry->filename_len + sizeof(entry_buffer) + (entry->metadata_str.s ? ZSTR_LEN(entry->metadata_str.s) : 0) + (entry->is_dir ? 1 : 0);
/* compress and rehash as necessary */
if ((oldfile && !entry->is_modified) || entry->is_dir) {
@@ -2798,9 +2745,9 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
}
continue;
}
- if (!phar_get_efp(entry, 0 TSRMLS_CC)) {
+ if (!phar_get_efp(entry, 0)) {
/* re-open internal file pointer just-in-time */
- newentry = phar_open_jit(phar, entry, error TSRMLS_CC);
+ newentry = phar_open_jit(phar, entry, error);
if (!newentry) {
/* major problem re-opening, so we ignore this file and the error */
efree(*error);
@@ -2809,8 +2756,8 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
}
entry = newentry;
}
- file = phar_get_efp(entry, 0 TSRMLS_CC);
- if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 1 TSRMLS_CC)) {
+ file = phar_get_efp(entry, 0);
+ if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 1)) {
if (closeoldfile) {
php_stream_close(oldfile);
}
@@ -2832,7 +2779,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
entry->compressed_filesize = entry->uncompressed_filesize;
continue;
}
- filter = php_stream_filter_create(phar_compress_filter(entry, 0), NULL, 0 TSRMLS_CC);
+ filter = php_stream_filter_create(phar_compress_filter(entry, 0), NULL, 0);
if (!filter) {
if (closeoldfile) {
php_stream_close(oldfile);
@@ -2865,7 +2812,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
return EOF;
}
php_stream_flush(file);
- if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0 TSRMLS_CC)) {
+ if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0)) {
if (closeoldfile) {
php_stream_close(oldfile);
}
@@ -2888,7 +2835,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
}
php_stream_filter_flush(filter, 1);
php_stream_flush(entry->cfp);
- php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ php_stream_filter_remove(filter, 1);
php_stream_seek(entry->cfp, 0, SEEK_END);
entry->compressed_filesize = (php_uint32) php_stream_tell(entry->cfp);
/* generate crc on compressed file */
@@ -2914,7 +2861,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
phar->alias_len = 0;
}
- manifest_len = offset + phar->alias_len + sizeof(manifest) + main_metadata_str.len;
+ manifest_len = offset + phar->alias_len + sizeof(manifest) + (main_metadata_str.s ? ZSTR_LEN(main_metadata_str.s) : 0);
phar_set_32(manifest, manifest_len);
/* Hack - see bug #65028, add padding byte to the end of the manifest */
if(manifest[0] == '\r' || manifest[0] == '\n') {
@@ -2953,9 +2900,9 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
phar->alias_len = restore_alias_len;
- phar_set_32(manifest, main_metadata_str.len);
- if (4 != php_stream_write(newfile, manifest, 4) || (main_metadata_str.len
- && main_metadata_str.len != php_stream_write(newfile, main_metadata_str.c, main_metadata_str.len))) {
+ phar_set_32(manifest, main_metadata_str.s ? ZSTR_LEN(main_metadata_str.s) : 0);
+ if (4 != php_stream_write(newfile, manifest, 4) || ((main_metadata_str.s ? ZSTR_LEN(main_metadata_str.s) : 0)
+ && ZSTR_LEN(main_metadata_str.s) != php_stream_write(newfile, ZSTR_VAL(main_metadata_str.s), ZSTR_LEN(main_metadata_str.s)))) {
smart_str_free(&main_metadata_str);
if (closeoldfile) {
@@ -2981,7 +2928,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
zend_hash_has_more_elements(&phar->manifest) == SUCCESS;
zend_hash_move_forward(&phar->manifest)) {
- if (zend_hash_get_current_data(&phar->manifest, (void **)&entry) == FAILURE) {
+ if ((entry = zend_hash_get_current_data_ptr(&phar->manifest)) == NULL) {
continue;
}
@@ -3029,10 +2976,11 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
phar_set_32(entry_buffer+8, entry->compressed_filesize);
phar_set_32(entry_buffer+12, entry->crc32);
phar_set_32(entry_buffer+16, entry->flags);
- phar_set_32(entry_buffer+20, entry->metadata_str.len);
+ phar_set_32(entry_buffer+20, entry->metadata_str.s ? ZSTR_LEN(entry->metadata_str.s) : 0);
if (sizeof(entry_buffer) != php_stream_write(newfile, entry_buffer, sizeof(entry_buffer))
- || entry->metadata_str.len != php_stream_write(newfile, entry->metadata_str.c, entry->metadata_str.len)) {
+ || (entry->metadata_str.s &&
+ ZSTR_LEN(entry->metadata_str.s) != php_stream_write(newfile, ZSTR_VAL(entry->metadata_str.s), ZSTR_LEN(entry->metadata_str.s)))) {
if (closeoldfile) {
php_stream_close(oldfile);
}
@@ -3069,7 +3017,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
zend_hash_has_more_elements(&phar->manifest) == SUCCESS;
zend_hash_move_forward(&phar->manifest)) {
- if (zend_hash_get_current_data(&phar->manifest, (void **)&entry) == FAILURE) {
+ if ((entry = zend_hash_get_current_data_ptr(&phar->manifest)) == NULL) {
continue;
}
@@ -3081,8 +3029,8 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
file = entry->cfp;
php_stream_rewind(file);
} else {
- file = phar_get_efp(entry, 0 TSRMLS_CC);
- if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0 TSRMLS_CC)) {
+ file = phar_get_efp(entry, 0);
+ if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0)) {
if (closeoldfile) {
php_stream_close(oldfile);
}
@@ -3170,7 +3118,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
char *digest = NULL;
int digest_len;
- if (FAILURE == phar_create_signature(phar, newfile, &digest, &digest_len, error TSRMLS_CC)) {
+ if (FAILURE == phar_create_signature(phar, newfile, &digest, &digest_len, error)) {
if (error) {
char *save = *error;
spprintf(error, 0, "phar error: unable to write signature: %s", save);
@@ -3243,7 +3191,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
array_init(&filterparams);
add_assoc_long(&filterparams, "window", MAX_WBITS+16);
- filter = php_stream_filter_create("zlib.deflate", &filterparams, php_stream_is_persistent(phar->fp) TSRMLS_CC);
+ filter = php_stream_filter_create("zlib.deflate", &filterparams, php_stream_is_persistent(phar->fp));
zval_dtor(&filterparams);
if (!filter) {
@@ -3256,16 +3204,16 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
php_stream_filter_append(&phar->fp->writefilters, filter);
php_stream_copy_to_stream_ex(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL);
php_stream_filter_flush(filter, 1);
- php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ php_stream_filter_remove(filter, 1);
php_stream_close(phar->fp);
/* use the temp stream as our base */
phar->fp = newfile;
} else if (phar->flags & PHAR_FILE_COMPRESSED_BZ2) {
- filter = php_stream_filter_create("bzip2.compress", NULL, php_stream_is_persistent(phar->fp) TSRMLS_CC);
+ filter = php_stream_filter_create("bzip2.compress", NULL, php_stream_is_persistent(phar->fp));
php_stream_filter_append(&phar->fp->writefilters, filter);
php_stream_copy_to_stream_ex(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL);
php_stream_filter_flush(filter, 1);
- php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ php_stream_filter_remove(filter, 1);
php_stream_close(phar->fp);
/* use the temp stream as our base */
phar->fp = newfile;
@@ -3288,6 +3236,9 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
/* }}} */
#ifdef COMPILE_DL_PHAR
+#ifdef ZTS
+ZEND_TSRMLS_CACHE_DEFINE()
+#endif
ZEND_GET_MODULE(phar)
#endif
@@ -3300,26 +3251,26 @@ zend_function_entry phar_functions[] = {
};
/* }}}*/
-static size_t phar_zend_stream_reader(void *handle, char *buf, size_t len TSRMLS_DC) /* {{{ */
+static size_t phar_zend_stream_reader(void *handle, char *buf, size_t len) /* {{{ */
{
- return php_stream_read(phar_get_pharfp((phar_archive_data*)handle TSRMLS_CC), buf, len);
+ return php_stream_read(phar_get_pharfp((phar_archive_data*)handle), buf, len);
}
/* }}} */
-static size_t phar_zend_stream_fsizer(void *handle TSRMLS_DC) /* {{{ */
+static size_t phar_zend_stream_fsizer(void *handle) /* {{{ */
{
return ((phar_archive_data*)handle)->halt_offset + 32;
} /* }}} */
-zend_op_array *(*phar_orig_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC);
+zend_op_array *(*phar_orig_compile_file)(zend_file_handle *file_handle, int type);
#define phar_orig_zend_open zend_stream_open_function
-static char *phar_resolve_path(const char *filename, int filename_len TSRMLS_DC)
+static zend_string *phar_resolve_path(const char *filename, int filename_len)
{
- return phar_find_in_include_path((char *) filename, filename_len, NULL TSRMLS_CC);
+ return phar_find_in_include_path((char *) filename, filename_len, NULL);
}
-static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type TSRMLS_DC) /* {{{ */
+static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type) /* {{{ */
{
zend_op_array *res;
char *name = NULL;
@@ -3327,16 +3278,16 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type
phar_archive_data *phar;
if (!file_handle || !file_handle->filename) {
- return phar_orig_compile_file(file_handle, type TSRMLS_CC);
+ return phar_orig_compile_file(file_handle, type);
}
if (strstr(file_handle->filename, ".phar") && !strstr(file_handle->filename, "://")) {
- if (SUCCESS == phar_open_from_filename((char*)file_handle->filename, strlen(file_handle->filename), NULL, 0, 0, &phar, NULL TSRMLS_CC)) {
+ if (SUCCESS == phar_open_from_filename((char*)file_handle->filename, strlen(file_handle->filename), NULL, 0, 0, &phar, NULL)) {
if (phar->is_zip || phar->is_tar) {
zend_file_handle f = *file_handle;
/* zip or tar-based phar */
spprintf(&name, 4096, "phar://%s/%s", file_handle->filename, ".phar/stub.php");
- if (SUCCESS == phar_orig_zend_open((const char *)name, file_handle TSRMLS_CC)) {
+ if (SUCCESS == phar_orig_zend_open((const char *)name, file_handle)) {
efree(name);
name = NULL;
file_handle->filename = f.filename;
@@ -3358,7 +3309,7 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type
file_handle->handle.stream.fsizer = phar_zend_stream_fsizer;
file_handle->handle.stream.isatty = 0;
phar->is_persistent ?
- php_stream_rewind(PHAR_GLOBALS->cached_fp[phar->phar_pos].fp) :
+ php_stream_rewind(PHAR_G(cached_fp)[phar->phar_pos].fp) :
php_stream_rewind(phar->fp);
memset(&file_handle->handle.stream.mmap, 0, sizeof(file_handle->handle.stream.mmap));
}
@@ -3368,7 +3319,7 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type
zend_try {
failed = 0;
CG(zend_lineno) = 0;
- res = phar_orig_compile_file(file_handle, type TSRMLS_CC);
+ res = phar_orig_compile_file(file_handle, type);
} zend_catch {
failed = 1;
res = NULL;
@@ -3386,23 +3337,31 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type
}
/* }}} */
-typedef zend_op_array* (zend_compile_t)(zend_file_handle*, int TSRMLS_DC);
+typedef zend_op_array* (zend_compile_t)(zend_file_handle*, int);
typedef zend_compile_t* (compile_hook)(zend_compile_t *ptr);
+static void mime_type_dtor(zval *zv)
+{
+ free(Z_PTR_P(zv));
+}
+
PHP_GINIT_FUNCTION(phar) /* {{{ */
{
+#if defined(COMPILE_DL_PHAR) && defined(ZTS)
+ ZEND_TSRMLS_CACHE_UPDATE();
+#endif
phar_mime_type mime;
memset(phar_globals, 0, sizeof(zend_phar_globals));
phar_globals->readonly = 1;
- zend_hash_init(&phar_globals->mime_types, 0, NULL, NULL, 1);
+ zend_hash_init(&phar_globals->mime_types, 0, NULL, mime_type_dtor, 1);
#define PHAR_SET_MIME(mimetype, ret, fileext) \
mime.mime = mimetype; \
mime.len = sizeof((mimetype))+1; \
mime.type = ret; \
- zend_hash_add(&phar_globals->mime_types, fileext, sizeof(fileext)-1, (void *)&mime, sizeof(phar_mime_type), NULL); \
+ zend_hash_str_add_mem(&phar_globals->mime_types, fileext, sizeof(fileext)-1, (void *)&mime, sizeof(phar_mime_type)); \
PHAR_SET_MIME("text/html", PHAR_MIME_PHPS, "phps")
PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "c")
@@ -3445,7 +3404,7 @@ PHP_GINIT_FUNCTION(phar) /* {{{ */
PHAR_SET_MIME("image/xbm", PHAR_MIME_OTHER, "xbm")
PHAR_SET_MIME("text/xml", PHAR_MIME_OTHER, "xml")
- phar_restore_orig_functions(TSRMLS_C);
+ phar_restore_orig_functions();
}
/* }}} */
@@ -3465,20 +3424,20 @@ PHP_MINIT_FUNCTION(phar) /* {{{ */
phar_save_resolve_path = zend_resolve_path;
zend_resolve_path = phar_resolve_path;
- phar_object_init(TSRMLS_C);
+ phar_object_init();
- phar_intercept_functions_init(TSRMLS_C);
- phar_save_orig_functions(TSRMLS_C);
+ phar_intercept_functions_init();
+ phar_save_orig_functions();
- return php_register_url_stream_wrapper("phar", &php_stream_phar_wrapper TSRMLS_CC);
+ return php_register_url_stream_wrapper("phar", &php_stream_phar_wrapper);
}
/* }}} */
PHP_MSHUTDOWN_FUNCTION(phar) /* {{{ */
{
- php_unregister_url_stream_wrapper("phar" TSRMLS_CC);
+ php_unregister_url_stream_wrapper("phar");
- phar_intercept_functions_shutdown(TSRMLS_C);
+ phar_intercept_functions_shutdown();
if (zend_compile_file == phar_compile_file) {
zend_compile_file = phar_orig_compile_file;
@@ -3493,35 +3452,35 @@ PHP_MSHUTDOWN_FUNCTION(phar) /* {{{ */
}
/* }}} */
-void phar_request_initialize(TSRMLS_D) /* {{{ */
+void phar_request_initialize(void) /* {{{ */
{
- if (!PHAR_GLOBALS->request_init)
+ if (!PHAR_G(request_init))
{
PHAR_G(last_phar) = NULL;
PHAR_G(last_phar_name) = PHAR_G(last_alias) = NULL;
- PHAR_G(has_bz2) = zend_hash_exists(&module_registry, "bz2", sizeof("bz2"));
- PHAR_G(has_zlib) = zend_hash_exists(&module_registry, "zlib", sizeof("zlib"));
- PHAR_GLOBALS->request_init = 1;
- PHAR_GLOBALS->request_ends = 0;
- PHAR_GLOBALS->request_done = 0;
- zend_hash_init(&(PHAR_GLOBALS->phar_fname_map), 5, zend_get_hash_value, destroy_phar_data, 0);
- zend_hash_init(&(PHAR_GLOBALS->phar_persist_map), 5, zend_get_hash_value, NULL, 0);
- zend_hash_init(&(PHAR_GLOBALS->phar_alias_map), 5, zend_get_hash_value, NULL, 0);
+ PHAR_G(has_bz2) = zend_hash_str_exists(&module_registry, "bz2", sizeof("bz2")-1);
+ PHAR_G(has_zlib) = zend_hash_str_exists(&module_registry, "zlib", sizeof("zlib")-1);
+ PHAR_G(request_init) = 1;
+ PHAR_G(request_ends) = 0;
+ PHAR_G(request_done) = 0;
+ zend_hash_init(&(PHAR_G(phar_fname_map)), 5, zend_get_hash_value, destroy_phar_data, 0);
+ zend_hash_init(&(PHAR_G(phar_persist_map)), 5, zend_get_hash_value, NULL, 0);
+ zend_hash_init(&(PHAR_G(phar_alias_map)), 5, zend_get_hash_value, NULL, 0);
if (PHAR_G(manifest_cached)) {
- phar_archive_data **pphar;
+ phar_archive_data *pphar;
phar_entry_fp *stuff = (phar_entry_fp *) ecalloc(zend_hash_num_elements(&cached_phars), sizeof(phar_entry_fp));
for (zend_hash_internal_pointer_reset(&cached_phars);
- zend_hash_get_current_data(&cached_phars, (void **)&pphar) == SUCCESS;
+ (pphar = zend_hash_get_current_data_ptr(&cached_phars)) != NULL;
zend_hash_move_forward(&cached_phars)) {
- stuff[pphar[0]->phar_pos].manifest = (phar_entry_fp_info *) ecalloc( zend_hash_num_elements(&(pphar[0]->manifest)), sizeof(phar_entry_fp_info));
+ stuff[pphar->phar_pos].manifest = (phar_entry_fp_info *) ecalloc( zend_hash_num_elements(&(pphar->manifest)), sizeof(phar_entry_fp_info));
}
- PHAR_GLOBALS->cached_fp = stuff;
+ PHAR_G(cached_fp) = stuff;
}
- PHAR_GLOBALS->phar_SERVER_mung_list = 0;
+ PHAR_G(phar_SERVER_mung_list) = 0;
PHAR_G(cwd) = NULL;
PHAR_G(cwd_len) = 0;
PHAR_G(cwd_init) = 0;
@@ -3533,34 +3492,34 @@ PHP_RSHUTDOWN_FUNCTION(phar) /* {{{ */
{
int i;
- PHAR_GLOBALS->request_ends = 1;
+ PHAR_G(request_ends) = 1;
- if (PHAR_GLOBALS->request_init)
+ if (PHAR_G(request_init))
{
- phar_release_functions(TSRMLS_C);
- zend_hash_destroy(&(PHAR_GLOBALS->phar_alias_map));
- PHAR_GLOBALS->phar_alias_map.arBuckets = NULL;
- zend_hash_destroy(&(PHAR_GLOBALS->phar_fname_map));
- PHAR_GLOBALS->phar_fname_map.arBuckets = NULL;
- zend_hash_destroy(&(PHAR_GLOBALS->phar_persist_map));
- PHAR_GLOBALS->phar_persist_map.arBuckets = NULL;
- PHAR_GLOBALS->phar_SERVER_mung_list = 0;
-
- if (PHAR_GLOBALS->cached_fp) {
+ phar_release_functions();
+ zend_hash_destroy(&(PHAR_G(phar_alias_map)));
+ PHAR_G(phar_alias_map.u.flags) = 0;
+ zend_hash_destroy(&(PHAR_G(phar_fname_map)));
+ PHAR_G(phar_fname_map.u.flags) = 0;
+ zend_hash_destroy(&(PHAR_G(phar_persist_map)));
+ PHAR_G(phar_persist_map.u.flags) = 0;
+ PHAR_G(phar_SERVER_mung_list) = 0;
+
+ if (PHAR_G(cached_fp)) {
for (i = 0; i < zend_hash_num_elements(&cached_phars); ++i) {
- if (PHAR_GLOBALS->cached_fp[i].fp) {
- php_stream_close(PHAR_GLOBALS->cached_fp[i].fp);
+ if (PHAR_G(cached_fp)[i].fp) {
+ php_stream_close(PHAR_G(cached_fp)[i].fp);
}
- if (PHAR_GLOBALS->cached_fp[i].ufp) {
- php_stream_close(PHAR_GLOBALS->cached_fp[i].ufp);
+ if (PHAR_G(cached_fp)[i].ufp) {
+ php_stream_close(PHAR_G(cached_fp)[i].ufp);
}
- efree(PHAR_GLOBALS->cached_fp[i].manifest);
+ efree(PHAR_G(cached_fp)[i].manifest);
}
- efree(PHAR_GLOBALS->cached_fp);
- PHAR_GLOBALS->cached_fp = 0;
+ efree(PHAR_G(cached_fp));
+ PHAR_G(cached_fp) = 0;
}
- PHAR_GLOBALS->request_init = 0;
+ PHAR_G(request_init) = 0;
if (PHAR_G(cwd)) {
efree(PHAR_G(cwd));
@@ -3571,14 +3530,14 @@ PHP_RSHUTDOWN_FUNCTION(phar) /* {{{ */
PHAR_G(cwd_init) = 0;
}
- PHAR_GLOBALS->request_done = 1;
+ PHAR_G(request_done) = 1;
return SUCCESS;
}
/* }}} */
PHP_MINFO_FUNCTION(phar) /* {{{ */
{
- phar_request_initialize(TSRMLS_C);
+ phar_request_initialize();
php_info_print_table_start();
php_info_print_table_header(2, "Phar: PHP Archive support", "enabled");
php_info_print_table_row(2, "Phar EXT version", PHP_PHAR_VERSION);
@@ -3602,7 +3561,7 @@ PHP_MINFO_FUNCTION(phar) /* {{{ */
#ifdef PHAR_HAVE_OPENSSL
php_info_print_table_row(2, "Native OpenSSL support", "enabled");
#else
- if (zend_hash_exists(&module_registry, "openssl", sizeof("openssl"))) {
+ if (zend_hash_str_exists(&module_registry, "openssl", sizeof("openssl")-1)) {
php_info_print_table_row(2, "OpenSSL support", "enabled");
} else {
php_info_print_table_row(2, "OpenSSL support", "disabled (install ext/openssl)");
diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h
index 5a9bcbf519..e0ae624dc9 100644
--- a/ext/phar/phar_internal.h
+++ b/ext/phar/phar_internal.h
@@ -33,8 +33,9 @@
#include "zend_hash.h"
#include "zend_interfaces.h"
#include "zend_operators.h"
-#include "zend_qsort.h"
+#include "zend_sort.h"
#include "zend_vm.h"
+#include "zend_smart_str.h"
#include "main/php_streams.h"
#include "main/streams/php_stream_plain_wrapper.h"
#include "main/SAPI.h"
@@ -49,7 +50,6 @@
#include "ext/standard/md5.h"
#include "ext/standard/sha1.h"
#include "ext/standard/php_var.h"
-#include "ext/standard/php_smart_str.h"
#include "ext/standard/php_versioning.h"
#ifndef PHP_WIN32
#include "TSRM/tsrm_strtok_r.h"
@@ -195,14 +195,10 @@ ZEND_BEGIN_MODULE_GLOBALS(phar)
ZEND_END_MODULE_GLOBALS(phar)
ZEND_EXTERN_MODULE_GLOBALS(phar)
+#define PHAR_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(phar, v)
-#ifdef ZTS
-# include "TSRM.h"
-# define PHAR_G(v) TSRMG(phar_globals_id, zend_phar_globals *, v)
-# define PHAR_GLOBALS ((zend_phar_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(phar_globals_id)])
-#else
-# define PHAR_G(v) (phar_globals.v)
-# define PHAR_GLOBALS (&phar_globals)
+#if defined(ZTS) && defined(COMPILE_DL_PHAR)
+ZEND_TSRMLS_CACHE_EXTERN()
#endif
#ifndef php_uint16
@@ -245,17 +241,17 @@ typedef struct _phar_entry_info {
/* remainder */
/* when changing compression, save old flags in case fp is NULL */
php_uint32 old_flags;
- zval *metadata;
+ zval metadata;
int metadata_len; /* only used for cached manifests */
php_uint32 filename_len;
char *filename;
enum phar_fp_type fp_type;
/* offset within original phar file of the file contents */
- long offset_abs;
+ zend_long offset_abs;
/* offset within fp of the file contents */
- long offset;
+ zend_long offset;
/* offset within original phar file of the file header (for zip-based/tar-based) */
- long header_offset;
+ zend_long header_offset;
php_stream *fp;
php_stream *cfp;
int fp_refcount;
@@ -313,7 +309,7 @@ struct _phar_archive_data {
php_uint32 sig_flags;
int sig_len;
char *signature;
- zval *metadata;
+ zval metadata;
int metadata_len; /* only used for cached manifests */
uint phar_pos;
/* if 1, then this alias was manually specified by the user and is not a permanent alias */
@@ -336,7 +332,7 @@ struct _phar_archive_data {
typedef struct _phar_entry_fp_info {
enum phar_fp_type fp_type;
/* offset within fp of the file contents */
- long offset;
+ zend_long offset;
} phar_entry_fp_info;
struct _phar_entry_fp {
@@ -345,79 +341,79 @@ struct _phar_entry_fp {
phar_entry_fp_info *manifest;
};
-static inline php_stream *phar_get_entrypfp(phar_entry_info *entry TSRMLS_DC)
+static inline php_stream *phar_get_entrypfp(phar_entry_info *entry)
{
if (!entry->is_persistent) {
return entry->phar->fp;
}
- return PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].fp;
+ return PHAR_G(cached_fp)[entry->phar->phar_pos].fp;
}
-static inline php_stream *phar_get_entrypufp(phar_entry_info *entry TSRMLS_DC)
+static inline php_stream *phar_get_entrypufp(phar_entry_info *entry)
{
if (!entry->is_persistent) {
return entry->phar->ufp;
}
- return PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].ufp;
+ return PHAR_G(cached_fp)[entry->phar->phar_pos].ufp;
}
-static inline void phar_set_entrypfp(phar_entry_info *entry, php_stream *fp TSRMLS_DC)
+static inline void phar_set_entrypfp(phar_entry_info *entry, php_stream *fp)
{
if (!entry->phar->is_persistent) {
entry->phar->fp = fp;
return;
}
- PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].fp = fp;
+ PHAR_G(cached_fp)[entry->phar->phar_pos].fp = fp;
}
-static inline void phar_set_entrypufp(phar_entry_info *entry, php_stream *fp TSRMLS_DC)
+static inline void phar_set_entrypufp(phar_entry_info *entry, php_stream *fp)
{
if (!entry->phar->is_persistent) {
entry->phar->ufp = fp;
return;
}
- PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].ufp = fp;
+ PHAR_G(cached_fp)[entry->phar->phar_pos].ufp = fp;
}
-static inline php_stream *phar_get_pharfp(phar_archive_data *phar TSRMLS_DC)
+static inline php_stream *phar_get_pharfp(phar_archive_data *phar)
{
if (!phar->is_persistent) {
return phar->fp;
}
- return PHAR_GLOBALS->cached_fp[phar->phar_pos].fp;
+ return PHAR_G(cached_fp)[phar->phar_pos].fp;
}
-static inline php_stream *phar_get_pharufp(phar_archive_data *phar TSRMLS_DC)
+static inline php_stream *phar_get_pharufp(phar_archive_data *phar)
{
if (!phar->is_persistent) {
return phar->ufp;
}
- return PHAR_GLOBALS->cached_fp[phar->phar_pos].ufp;
+ return PHAR_G(cached_fp)[phar->phar_pos].ufp;
}
-static inline void phar_set_pharfp(phar_archive_data *phar, php_stream *fp TSRMLS_DC)
+static inline void phar_set_pharfp(phar_archive_data *phar, php_stream *fp)
{
if (!phar->is_persistent) {
phar->fp = fp;
return;
}
- PHAR_GLOBALS->cached_fp[phar->phar_pos].fp = fp;
+ PHAR_G(cached_fp)[phar->phar_pos].fp = fp;
}
-static inline void phar_set_pharufp(phar_archive_data *phar, php_stream *fp TSRMLS_DC)
+static inline void phar_set_pharufp(phar_archive_data *phar, php_stream *fp)
{
if (!phar->is_persistent) {
phar->ufp = fp;
return;
}
- PHAR_GLOBALS->cached_fp[phar->phar_pos].ufp = fp;
+ PHAR_G(cached_fp)[phar->phar_pos].ufp = fp;
}
-static inline void phar_set_fp_type(phar_entry_info *entry, enum phar_fp_type type, off_t offset TSRMLS_DC)
+static inline void phar_set_fp_type(phar_entry_info *entry, enum phar_fp_type type, zend_off_t offset)
{
phar_entry_fp_info *data;
@@ -426,30 +422,30 @@ static inline void phar_set_fp_type(phar_entry_info *entry, enum phar_fp_type ty
entry->offset = offset;
return;
}
- data = &(PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].manifest[entry->manifest_pos]);
+ data = &(PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos]);
data->fp_type = type;
data->offset = offset;
}
-static inline enum phar_fp_type phar_get_fp_type(phar_entry_info *entry TSRMLS_DC)
+static inline enum phar_fp_type phar_get_fp_type(phar_entry_info *entry)
{
if (!entry->is_persistent) {
return entry->fp_type;
}
- return PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].manifest[entry->manifest_pos].fp_type;
+ return PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos].fp_type;
}
-static inline off_t phar_get_fp_offset(phar_entry_info *entry TSRMLS_DC)
+static inline zend_off_t phar_get_fp_offset(phar_entry_info *entry)
{
if (!entry->is_persistent) {
return entry->offset;
}
- if (PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].manifest[entry->manifest_pos].fp_type == PHAR_FP) {
- if (!PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].manifest[entry->manifest_pos].offset) {
- PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].manifest[entry->manifest_pos].offset = entry->offset;
+ if (PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos].fp_type == PHAR_FP) {
+ if (!PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos].offset) {
+ PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos].offset = entry->offset;
}
}
- return PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].manifest[entry->manifest_pos].offset;
+ return PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos].offset;
}
#define PHAR_MIME_PHP '\0'
@@ -468,9 +464,9 @@ typedef struct _phar_entry_data {
phar_archive_data *phar;
php_stream *fp;
/* stream position proxy, allows multiple open streams referring to the same fp */
- off_t position;
+ zend_off_t position;
/* for copies of the phar fp, defines where 0 is */
- off_t zero;
+ zend_off_t zero;
unsigned int for_write:1;
unsigned int is_zip:1;
unsigned int is_tar:1;
@@ -480,29 +476,21 @@ typedef struct _phar_entry_data {
#if HAVE_SPL
/* archive php object */
union _phar_archive_object {
- zend_object std;
spl_filesystem_object spl;
- struct {
- zend_object std;
- phar_archive_data *archive;
- } arc;
+ phar_archive_data *archive;
};
#endif
#if HAVE_SPL
/* entry php object */
union _phar_entry_object {
- zend_object std;
spl_filesystem_object spl;
- struct {
- zend_object std;
- phar_entry_info *entry;
- } ent;
+ phar_entry_info *entry;
};
#endif
#ifndef PHAR_MAIN
-extern char *(*phar_save_resolve_path)(const char *filename, int filename_len TSRMLS_DC);
+extern zend_string *(*phar_save_resolve_path)(const char *filename, int filename_len);
#endif
BEGIN_EXTERN_C()
@@ -532,7 +520,7 @@ static inline int phar_validate_alias(const char *alias, int alias_len) /* {{{ *
}
/* }}} */
-static inline void phar_set_inode(phar_entry_info *entry TSRMLS_DC) /* {{{ */
+static inline void phar_set_inode(phar_entry_info *entry) /* {{{ */
{
char tmp[MAXPATHLEN];
int tmp_len;
@@ -546,79 +534,79 @@ static inline void phar_set_inode(phar_entry_info *entry TSRMLS_DC) /* {{{ */
len2 = MIN(tmp_len - len1, entry->filename_len);
memcpy(tmp + len1, entry->filename, len2);
- entry->inode = (unsigned short)zend_get_hash_value(tmp, tmp_len);
+ entry->inode = (unsigned short) zend_hash_func(tmp, tmp_len);
}
/* }}} */
-void phar_request_initialize(TSRMLS_D);
+void phar_request_initialize(void);
-void phar_object_init(TSRMLS_D);
-void phar_destroy_phar_data(phar_archive_data *phar TSRMLS_DC);
+void phar_object_init(void);
+void phar_destroy_phar_data(phar_archive_data *phar);
-int phar_open_entry_file(phar_archive_data *phar, phar_entry_info *entry, char **error TSRMLS_DC);
-int phar_postprocess_file(phar_entry_data *idata, php_uint32 crc32, char **error, int process_zip TSRMLS_DC);
-int phar_open_from_filename(char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, char **error TSRMLS_DC);
-int phar_open_or_create_filename(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC);
-int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC);
-int phar_open_executed_filename(char *alias, int alias_len, char **error TSRMLS_DC);
-int phar_free_alias(phar_archive_data *phar, char *alias, int alias_len TSRMLS_DC);
-int phar_get_archive(phar_archive_data **archive, char *fname, int fname_len, char *alias, int alias_len, char **error TSRMLS_DC);
-int phar_open_parsed_phar(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC);
-int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_type, char *sig, int sig_len, char *fname, char **signature, int *signature_len, char **error TSRMLS_DC);
-int phar_create_signature(phar_archive_data *phar, php_stream *fp, char **signature, int *signature_length, char **error TSRMLS_DC);
+int phar_open_entry_file(phar_archive_data *phar, phar_entry_info *entry, char **error);
+int phar_postprocess_file(phar_entry_data *idata, php_uint32 crc32, char **error, int process_zip);
+int phar_open_from_filename(char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, char **error);
+int phar_open_or_create_filename(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error);
+int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error);
+int phar_open_executed_filename(char *alias, int alias_len, char **error);
+int phar_free_alias(phar_archive_data *phar, char *alias, int alias_len);
+int phar_get_archive(phar_archive_data **archive, char *fname, int fname_len, char *alias, int alias_len, char **error);
+int phar_open_parsed_phar(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error);
+int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_type, char *sig, int sig_len, char *fname, char **signature, int *signature_len, char **error);
+int phar_create_signature(phar_archive_data *phar, php_stream *fp, char **signature, int *signature_length, char **error);
/* utility functions */
-char *phar_create_default_stub(const char *index_php, const char *web_index, size_t *len, char **error TSRMLS_DC);
+zend_string *phar_create_default_stub(const char *index_php, const char *web_index, char **error);
char *phar_decompress_filter(phar_entry_info * entry, int return_unknown);
char *phar_compress_filter(phar_entry_info * entry, int return_unknown);
-void phar_remove_virtual_dirs(phar_archive_data *phar, char *filename, int filename_len TSRMLS_DC);
-void phar_add_virtual_dirs(phar_archive_data *phar, char *filename, int filename_len TSRMLS_DC);
-int phar_mount_entry(phar_archive_data *phar, char *filename, int filename_len, char *path, int path_len TSRMLS_DC);
-char *phar_find_in_include_path(char *file, int file_len, phar_archive_data **pphar TSRMLS_DC);
-char *phar_fix_filepath(char *path, int *new_len, int use_cwd TSRMLS_DC);
-phar_entry_info * phar_open_jit(phar_archive_data *phar, phar_entry_info *entry, char **error TSRMLS_DC);
-int phar_parse_metadata(char **buffer, zval **metadata, php_uint32 zip_metadata_len TSRMLS_DC);
-void destroy_phar_manifest_entry(void *pDest);
-int phar_seek_efp(phar_entry_info *entry, off_t offset, int whence, off_t position, int follow_links TSRMLS_DC);
-php_stream *phar_get_efp(phar_entry_info *entry, int follow_links TSRMLS_DC);
-int phar_copy_entry_fp(phar_entry_info *source, phar_entry_info *dest, char **error TSRMLS_DC);
-int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TSRMLS_DC);
-phar_entry_info *phar_get_link_source(phar_entry_info *entry TSRMLS_DC);
-int phar_create_writeable_entry(phar_archive_data *phar, phar_entry_info *entry, char **error TSRMLS_DC);
-int phar_separate_entry_fp(phar_entry_info *entry, char **error TSRMLS_DC);
-int phar_open_archive_fp(phar_archive_data *phar TSRMLS_DC);
-int phar_copy_on_write(phar_archive_data **pphar TSRMLS_DC);
+void phar_remove_virtual_dirs(phar_archive_data *phar, char *filename, int filename_len);
+void phar_add_virtual_dirs(phar_archive_data *phar, char *filename, int filename_len);
+int phar_mount_entry(phar_archive_data *phar, char *filename, int filename_len, char *path, int path_len);
+zend_string *phar_find_in_include_path(char *file, int file_len, phar_archive_data **pphar);
+char *phar_fix_filepath(char *path, int *new_len, int use_cwd);
+phar_entry_info * phar_open_jit(phar_archive_data *phar, phar_entry_info *entry, char **error);
+int phar_parse_metadata(char **buffer, zval *metadata, php_uint32 zip_metadata_len);
+void destroy_phar_manifest_entry(zval *zv);
+int phar_seek_efp(phar_entry_info *entry, zend_off_t offset, int whence, zend_off_t position, int follow_links);
+php_stream *phar_get_efp(phar_entry_info *entry, int follow_links);
+int phar_copy_entry_fp(phar_entry_info *source, phar_entry_info *dest, char **error);
+int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links);
+phar_entry_info *phar_get_link_source(phar_entry_info *entry);
+int phar_create_writeable_entry(phar_archive_data *phar, phar_entry_info *entry, char **error);
+int phar_separate_entry_fp(phar_entry_info *entry, char **error);
+int phar_open_archive_fp(phar_archive_data *phar);
+int phar_copy_on_write(phar_archive_data **pphar);
/* tar functions in tar.c */
int phar_is_tar(char *buf, char *fname);
-int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char *alias, int alias_len, phar_archive_data** pphar, int is_data, php_uint32 compression, char **error TSRMLS_DC);
-int phar_open_or_create_tar(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC);
-int phar_tar_flush(phar_archive_data *phar, char *user_stub, long len, int defaultstub, char **error TSRMLS_DC);
+int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char *alias, int alias_len, phar_archive_data** pphar, int is_data, php_uint32 compression, char **error);
+int phar_open_or_create_tar(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error);
+int phar_tar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int defaultstub, char **error);
/* zip functions in zip.c */
-int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias, int alias_len, phar_archive_data** pphar, char **error TSRMLS_DC);
-int phar_open_or_create_zip(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC);
-int phar_zip_flush(phar_archive_data *archive, char *user_stub, long len, int defaultstub, char **error TSRMLS_DC);
+int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias, int alias_len, phar_archive_data** pphar, char **error);
+int phar_open_or_create_zip(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error);
+int phar_zip_flush(phar_archive_data *archive, char *user_stub, zend_long len, int defaultstub, char **error);
#ifdef PHAR_MAIN
-static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, int is_data, char **error TSRMLS_DC);
+static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, int is_data, char **error);
extern php_stream_wrapper php_stream_phar_wrapper;
#else
extern HashTable cached_phars;
extern HashTable cached_alias;
#endif
-int phar_archive_delref(phar_archive_data *phar TSRMLS_DC);
-int phar_entry_delref(phar_entry_data *idata TSRMLS_DC);
+int phar_archive_delref(phar_archive_data *phar);
+int phar_entry_delref(phar_entry_data *idata);
-phar_entry_info *phar_get_entry_info(phar_archive_data *phar, char *path, int path_len, char **error, int security TSRMLS_DC);
-phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, int path_len, char dir, char **error, int security TSRMLS_DC);
-phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char *path, int path_len, const char *mode, char allow_dir, char **error, int security TSRMLS_DC);
-int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len, char *path, int path_len, const char *mode, char allow_dir, char **error, int security TSRMLS_DC);
-int phar_flush(phar_archive_data *archive, char *user_stub, long len, int convert, char **error TSRMLS_DC);
-int phar_detect_phar_fname_ext(const char *filename, int filename_len, const char **ext_str, int *ext_len, int executable, int for_create, int is_complete TSRMLS_DC);
-int phar_split_fname(const char *filename, int filename_len, char **arch, int *arch_len, char **entry, int *entry_len, int executable, int for_create TSRMLS_DC);
+phar_entry_info *phar_get_entry_info(phar_archive_data *phar, char *path, int path_len, char **error, int security);
+phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, int path_len, char dir, char **error, int security);
+phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char *path, int path_len, const char *mode, char allow_dir, char **error, int security);
+int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len, char *path, int path_len, const char *mode, char allow_dir, char **error, int security);
+int phar_flush(phar_archive_data *archive, char *user_stub, zend_long len, int convert, char **error);
+int phar_detect_phar_fname_ext(const char *filename, int filename_len, const char **ext_str, int *ext_len, int executable, int for_create, int is_complete);
+int phar_split_fname(const char *filename, int filename_len, char **arch, int *arch_len, char **entry, int *entry_len, int executable, int for_create);
typedef enum {
pcr_use_query,
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c
index 08d29831e0..7c9c3351aa 100644
--- a/ext/phar/phar_object.c
+++ b/ext/phar/phar_object.c
@@ -30,13 +30,13 @@ static zend_class_entry *phar_ce_PharException;
static zend_class_entry *phar_ce_entry;
#endif
-#if PHP_MAJOR_VERSION > 5 || ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION >= 3))
+#if PHP_VERSION_ID >= 50300
# define PHAR_ARG_INFO
#else
# define PHAR_ARG_INFO static
#endif
-static int phar_file_type(HashTable *mimes, char *file, char **mime_type TSRMLS_DC) /* {{{ */
+static int phar_file_type(HashTable *mimes, char *file, char **mime_type) /* {{{ */
{
char *ext;
phar_mime_type *mime;
@@ -47,7 +47,7 @@ static int phar_file_type(HashTable *mimes, char *file, char **mime_type TSRMLS_
return PHAR_MIME_OTHER;
}
++ext;
- if (SUCCESS != zend_hash_find(mimes, ext, strlen(ext), (void **) &mime)) {
+ if (NULL == (mime = zend_hash_str_find_ptr(mimes, ext, strlen(ext)))) {
*mime_type = "application/octet-stream";
return PHAR_MIME_OTHER;
}
@@ -56,125 +56,106 @@ static int phar_file_type(HashTable *mimes, char *file, char **mime_type TSRMLS_
}
/* }}} */
-static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char *basename, int request_uri_len TSRMLS_DC) /* {{{ */
+static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char *basename, int request_uri_len) /* {{{ */
{
HashTable *_SERVER;
- zval **stuff;
+ zval *stuff;
char *path_info;
int basename_len = strlen(basename);
int code;
- zval *temp;
+ zval temp;
/* "tweak" $_SERVER variables requested in earlier call to Phar::mungServer() */
- if (!PG(http_globals)[TRACK_VARS_SERVER]) {
+ if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_UNDEF) {
return;
}
- _SERVER = Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]);
+ _SERVER = Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]);
/* PATH_INFO and PATH_TRANSLATED should always be munged */
- if (SUCCESS == zend_hash_find(_SERVER, "PATH_INFO", sizeof("PATH_INFO"), (void **) &stuff)) {
- path_info = Z_STRVAL_PP(stuff);
- code = Z_STRLEN_PP(stuff);
-
- if (Z_STRLEN_PP(stuff) > entry_len && !memcmp(Z_STRVAL_PP(stuff), entry, entry_len)) {
- ZVAL_STRINGL(*stuff, Z_STRVAL_PP(stuff) + entry_len, request_uri_len, 1);
-
- MAKE_STD_ZVAL(temp);
- ZVAL_STRINGL(temp, path_info, code, 0);
-
- zend_hash_update(_SERVER, "PHAR_PATH_INFO", sizeof("PHAR_PATH_INFO"), &temp, sizeof(zval **), NULL);
+ if (NULL != (stuff = zend_hash_str_find(_SERVER, "PATH_INFO", sizeof("PATH_INFO")-1))) {
+ path_info = Z_STRVAL_P(stuff);
+ code = Z_STRLEN_P(stuff);
+ if (code > entry_len && !memcmp(path_info, entry, entry_len)) {
+ ZVAL_STR(&temp, Z_STR_P(stuff));
+ ZVAL_STRINGL(stuff, path_info + entry_len, request_uri_len);
+ zend_hash_str_update(_SERVER, "PHAR_PATH_INFO", sizeof("PHAR_PATH_INFO")-1, &temp);
}
}
- if (SUCCESS == zend_hash_find(_SERVER, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED"), (void **) &stuff)) {
- path_info = Z_STRVAL_PP(stuff);
- code = Z_STRLEN_PP(stuff);
- Z_STRLEN_PP(stuff) = spprintf(&(Z_STRVAL_PP(stuff)), 4096, "phar://%s%s", fname, entry);
+ if (NULL != (stuff = zend_hash_str_find(_SERVER, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED")-1))) {
+ zend_string *str = strpprintf(4096, "phar://%s%s", fname, entry);
- MAKE_STD_ZVAL(temp);
- ZVAL_STRINGL(temp, path_info, code, 0);
+ ZVAL_STR(&temp, Z_STR_P(stuff));
+ ZVAL_NEW_STR(stuff, str);
- zend_hash_update(_SERVER, "PHAR_PATH_TRANSLATED", sizeof("PHAR_PATH_TRANSLATED"), (void *) &temp, sizeof(zval **), NULL);
+ zend_hash_str_update(_SERVER, "PHAR_PATH_TRANSLATED", sizeof("PHAR_PATH_TRANSLATED")-1, &temp);
}
- if (!PHAR_GLOBALS->phar_SERVER_mung_list) {
+ if (!PHAR_G(phar_SERVER_mung_list)) {
return;
}
- if (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_REQUEST_URI) {
- if (SUCCESS == zend_hash_find(_SERVER, "REQUEST_URI", sizeof("REQUEST_URI"), (void **) &stuff)) {
- path_info = Z_STRVAL_PP(stuff);
- code = Z_STRLEN_PP(stuff);
-
- if (Z_STRLEN_PP(stuff) > basename_len && !memcmp(Z_STRVAL_PP(stuff), basename, basename_len)) {
- ZVAL_STRINGL(*stuff, Z_STRVAL_PP(stuff) + basename_len, Z_STRLEN_PP(stuff) - basename_len, 1);
-
- MAKE_STD_ZVAL(temp);
- ZVAL_STRINGL(temp, path_info, code, 0);
-
- zend_hash_update(_SERVER, "PHAR_REQUEST_URI", sizeof("PHAR_REQUEST_URI"), (void *) &temp, sizeof(zval **), NULL);
+ if (PHAR_G(phar_SERVER_mung_list) & PHAR_MUNG_REQUEST_URI) {
+ if (NULL != (stuff = zend_hash_str_find(_SERVER, "REQUEST_URI", sizeof("REQUEST_URI")-1))) {
+ path_info = Z_STRVAL_P(stuff);
+ code = Z_STRLEN_P(stuff);
+ if (code > basename_len && !memcmp(path_info, basename, basename_len)) {
+ ZVAL_STR(&temp, Z_STR_P(stuff));
+ ZVAL_STRINGL(stuff, path_info + basename_len, code - basename_len);
+ zend_hash_str_update(_SERVER, "PHAR_REQUEST_URI", sizeof("PHAR_REQUEST_URI")-1, &temp);
}
}
}
- if (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_PHP_SELF) {
- if (SUCCESS == zend_hash_find(_SERVER, "PHP_SELF", sizeof("PHP_SELF"), (void **) &stuff)) {
- path_info = Z_STRVAL_PP(stuff);
- code = Z_STRLEN_PP(stuff);
-
- if (Z_STRLEN_PP(stuff) > basename_len && !memcmp(Z_STRVAL_PP(stuff), basename, basename_len)) {
- ZVAL_STRINGL(*stuff, Z_STRVAL_PP(stuff) + basename_len, Z_STRLEN_PP(stuff) - basename_len, 1);
+ if (PHAR_G(phar_SERVER_mung_list) & PHAR_MUNG_PHP_SELF) {
+ if (NULL != (stuff = zend_hash_str_find(_SERVER, "PHP_SELF", sizeof("PHP_SELF")-1))) {
+ path_info = Z_STRVAL_P(stuff);
+ code = Z_STRLEN_P(stuff);
- MAKE_STD_ZVAL(temp);
- ZVAL_STRINGL(temp, path_info, code, 0);
-
- zend_hash_update(_SERVER, "PHAR_PHP_SELF", sizeof("PHAR_PHP_SELF"), (void *) &temp, sizeof(zval **), NULL);
+ if (code > basename_len && !memcmp(path_info, basename, basename_len)) {
+ ZVAL_STR(&temp, Z_STR_P(stuff));
+ ZVAL_STRINGL(stuff, path_info + basename_len, code - basename_len);
+ zend_hash_str_update(_SERVER, "PHAR_PHP_SELF", sizeof("PHAR_PHP_SELF")-1, &temp);
}
}
}
- if (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_SCRIPT_NAME) {
- if (SUCCESS == zend_hash_find(_SERVER, "SCRIPT_NAME", sizeof("SCRIPT_NAME"), (void **) &stuff)) {
- path_info = Z_STRVAL_PP(stuff);
- code = Z_STRLEN_PP(stuff);
- ZVAL_STRINGL(*stuff, entry, entry_len, 1);
-
- MAKE_STD_ZVAL(temp);
- ZVAL_STRINGL(temp, path_info, code, 0);
-
- zend_hash_update(_SERVER, "PHAR_SCRIPT_NAME", sizeof("PHAR_SCRIPT_NAME"), (void *) &temp, sizeof(zval **), NULL);
+ if (PHAR_G(phar_SERVER_mung_list) & PHAR_MUNG_SCRIPT_NAME) {
+ if (NULL != (stuff = zend_hash_str_find(_SERVER, "SCRIPT_NAME", sizeof("SCRIPT_NAME")-1))) {
+ ZVAL_STR(&temp, Z_STR_P(stuff));
+ ZVAL_STRINGL(stuff, entry, entry_len);
+ zend_hash_str_update(_SERVER, "PHAR_SCRIPT_NAME", sizeof("PHAR_SCRIPT_NAME")-1, &temp);
}
}
- if (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_SCRIPT_FILENAME) {
- if (SUCCESS == zend_hash_find(_SERVER, "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME"), (void **) &stuff)) {
- path_info = Z_STRVAL_PP(stuff);
- code = Z_STRLEN_PP(stuff);
- Z_STRLEN_PP(stuff) = spprintf(&(Z_STRVAL_PP(stuff)), 4096, "phar://%s%s", fname, entry);
+ if (PHAR_G(phar_SERVER_mung_list) & PHAR_MUNG_SCRIPT_FILENAME) {
+ if (NULL != (stuff = zend_hash_str_find(_SERVER, "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME")-1))) {
+ zend_string *str = strpprintf(4096, "phar://%s%s", fname, entry);
- MAKE_STD_ZVAL(temp);
- ZVAL_STRINGL(temp, path_info, code, 0);
+ ZVAL_STR(&temp, Z_STR_P(stuff));
+ ZVAL_NEW_STR(stuff, str);
- zend_hash_update(_SERVER, "PHAR_SCRIPT_FILENAME", sizeof("PHAR_SCRIPT_FILENAME"), (void *) &temp, sizeof(zval **), NULL);
+ zend_hash_str_update(_SERVER, "PHAR_SCRIPT_FILENAME", sizeof("PHAR_SCRIPT_FILENAME")-1, &temp);
}
}
}
/* }}} */
-static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char *mime_type, int code, char *entry, int entry_len, char *arch, char *basename, char *ru, int ru_len TSRMLS_DC) /* {{{ */
+static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char *mime_type, int code, char *entry, int entry_len, char *arch, char *basename, char *ru, int ru_len) /* {{{ */
{
char *name = NULL, buf[8192];
const char *cwd;
zend_syntax_highlighter_ini syntax_highlighter_ini;
sapi_header_line ctr = {0};
size_t got;
- int dummy = 1, name_len;
+ zval dummy;
+ int name_len;
zend_file_handle file_handle;
zend_op_array *new_op_array;
- zval *result = NULL;
+ zval result;
php_stream *fp;
- off_t position;
+ zend_off_t position;
switch (code) {
case PHAR_MIME_PHPS:
@@ -187,7 +168,7 @@ static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char
}
php_get_highlight_struct(&syntax_highlighter_ini);
- highlight_file(name, &syntax_highlighter_ini TSRMLS_CC);
+ highlight_file(name, &syntax_highlighter_ini);
efree(name);
#ifdef PHP_WIN32
@@ -198,39 +179,39 @@ static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char
/* send headers, output file contents */
efree(basename);
ctr.line_len = spprintf(&(ctr.line), 0, "Content-type: %s", mime_type);
- sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC);
+ sapi_header_op(SAPI_HEADER_REPLACE, &ctr);
efree(ctr.line);
ctr.line_len = spprintf(&(ctr.line), 0, "Content-length: %u", info->uncompressed_filesize);
- sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC);
+ sapi_header_op(SAPI_HEADER_REPLACE, &ctr);
efree(ctr.line);
- if (FAILURE == sapi_send_headers(TSRMLS_C)) {
+ if (FAILURE == sapi_send_headers()) {
zend_bailout();
}
/* prepare to output */
- fp = phar_get_efp(info, 1 TSRMLS_CC);
+ fp = phar_get_efp(info, 1);
if (!fp) {
char *error;
- if (!phar_open_jit(phar, info, &error TSRMLS_CC)) {
+ if (!phar_open_jit(phar, info, &error)) {
if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
return -1;
}
- fp = phar_get_efp(info, 1 TSRMLS_CC);
+ fp = phar_get_efp(info, 1);
}
position = 0;
- phar_seek_efp(info, 0, SEEK_SET, 0, 1 TSRMLS_CC);
+ phar_seek_efp(info, 0, SEEK_SET, 0, 1);
do {
got = php_stream_read(fp, buf, MIN(8192, info->uncompressed_filesize - position));
if (got > 0) {
PHPWRITE(buf, got);
position += got;
- if (position == (off_t) info->uncompressed_filesize) {
+ if (position == (zend_off_t) info->uncompressed_filesize) {
break;
}
}
@@ -239,7 +220,7 @@ static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char
zend_bailout();
case PHAR_MIME_PHP:
if (basename) {
- phar_mung_server_vars(arch, entry, entry_len, basename, ru_len TSRMLS_CC);
+ phar_mung_server_vars(arch, entry, entry_len, basename, ru_len);
efree(basename);
}
@@ -258,7 +239,8 @@ static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char
PHAR_G(cwd) = NULL;
PHAR_G(cwd_len) = 0;
- if (zend_hash_add(&EG(included_files), name, name_len+1, (void *)&dummy, sizeof(int), NULL) == SUCCESS) {
+ ZVAL_NULL(&dummy);
+ if (zend_hash_str_add(&EG(included_files), name, name_len, &dummy) != NULL) {
if ((cwd = zend_memrchr(entry, '/', entry_len))) {
PHAR_G(cwd_init) = 1;
if (entry == cwd) {
@@ -274,13 +256,13 @@ static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char
}
}
- new_op_array = zend_compile_file(&file_handle, ZEND_REQUIRE TSRMLS_CC);
+ new_op_array = zend_compile_file(&file_handle, ZEND_REQUIRE);
if (!new_op_array) {
- zend_hash_del(&EG(included_files), name, name_len+1);
+ zend_hash_str_del(&EG(included_files), name, name_len);
}
- zend_destroy_file_handle(&file_handle TSRMLS_CC);
+ zend_destroy_file_handle(&file_handle);
} else {
efree(name);
@@ -290,11 +272,10 @@ static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char
efree(arch);
#endif
if (new_op_array) {
- EG(return_value_ptr_ptr) = &result;
- EG(active_op_array) = new_op_array;
+ ZVAL_UNDEF(&result);
zend_try {
- zend_execute(new_op_array TSRMLS_CC);
+ zend_execute(new_op_array, &result);
if (PHAR_G(cwd)) {
efree(PHAR_G(cwd));
PHAR_G(cwd) = NULL;
@@ -303,13 +284,9 @@ static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char
PHAR_G(cwd_init) = 0;
efree(name);
- destroy_op_array(new_op_array TSRMLS_CC);
+ destroy_op_array(new_op_array);
efree(new_op_array);
-
-
- if (EG(return_value_ptr_ptr) && *EG(return_value_ptr_ptr)) {
- zval_ptr_dtor(EG(return_value_ptr_ptr));
- }
+ zval_ptr_dtor(&result);
} zend_catch {
if (PHAR_G(cwd)) {
efree(PHAR_G(cwd));
@@ -330,31 +307,31 @@ static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char
}
/* }}} */
-static void phar_do_403(char *entry, int entry_len TSRMLS_DC) /* {{{ */
+static void phar_do_403(char *entry, int entry_len) /* {{{ */
{
sapi_header_line ctr = {0};
ctr.response_code = 403;
ctr.line_len = sizeof("HTTP/1.0 403 Access Denied")-1;
ctr.line = "HTTP/1.0 403 Access Denied";
- sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC);
- sapi_send_headers(TSRMLS_C);
+ sapi_header_op(SAPI_HEADER_REPLACE, &ctr);
+ sapi_send_headers();
PHPWRITE("<html>\n <head>\n <title>Access Denied</title>\n </head>\n <body>\n <h1>403 - File ", sizeof("<html>\n <head>\n <title>Access Denied</title>\n </head>\n <body>\n <h1>403 - File ") - 1);
PHPWRITE(entry, entry_len);
PHPWRITE(" Access Denied</h1>\n </body>\n</html>", sizeof(" Access Denied</h1>\n </body>\n</html>") - 1);
}
/* }}} */
-static void phar_do_404(phar_archive_data *phar, char *fname, int fname_len, char *f404, int f404_len, char *entry, int entry_len TSRMLS_DC) /* {{{ */
+static void phar_do_404(phar_archive_data *phar, char *fname, int fname_len, char *f404, size_t f404_len, char *entry, size_t entry_len) /* {{{ */
{
sapi_header_line ctr = {0};
phar_entry_info *info;
if (phar && f404_len) {
- info = phar_get_entry_info(phar, f404, f404_len, NULL, 1 TSRMLS_CC);
+ info = phar_get_entry_info(phar, f404, f404_len, NULL, 1);
if (info) {
- phar_file_action(phar, info, "text/html", PHAR_MIME_PHP, f404, f404_len, fname, NULL, NULL, 0 TSRMLS_CC);
+ phar_file_action(phar, info, "text/html", PHAR_MIME_PHP, f404, f404_len, fname, NULL, NULL, 0);
return;
}
}
@@ -362,8 +339,8 @@ static void phar_do_404(phar_archive_data *phar, char *fname, int fname_len, cha
ctr.response_code = 404;
ctr.line_len = sizeof("HTTP/1.0 404 Not Found")-1;
ctr.line = "HTTP/1.0 404 Not Found";
- sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC);
- sapi_send_headers(TSRMLS_C);
+ sapi_header_op(SAPI_HEADER_REPLACE, &ctr);
+ sapi_send_headers();
PHPWRITE("<html>\n <head>\n <title>File Not Found</title>\n </head>\n <body>\n <h1>404 - File ", sizeof("<html>\n <head>\n <title>File Not Found</title>\n </head>\n <body>\n <h1>404 - File ") - 1);
PHPWRITE(entry, entry_len);
PHPWRITE(" Not Found</h1>\n </body>\n</html>", sizeof(" Not Found</h1>\n </body>\n</html>") - 1);
@@ -373,21 +350,21 @@ static void phar_do_404(phar_archive_data *phar, char *fname, int fname_len, cha
/* post-process REQUEST_URI and retrieve the actual request URI. This is for
cases like http://localhost/blah.phar/path/to/file.php/extra/stuff
which calls "blah.phar" file "path/to/file.php" with PATH_INFO "/extra/stuff" */
-static void phar_postprocess_ru_web(char *fname, int fname_len, char **entry, int *entry_len, char **ru, int *ru_len TSRMLS_DC) /* {{{ */
+static void phar_postprocess_ru_web(char *fname, int fname_len, char **entry, int *entry_len, char **ru, int *ru_len) /* {{{ */
{
char *e = *entry + 1, *u = NULL, *u1 = NULL, *saveu = NULL;
int e_len = *entry_len - 1, u_len = 0;
- phar_archive_data **pphar = NULL;
+ phar_archive_data *pphar;
/* we already know we can retrieve the phar if we reach here */
- zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), fname, fname_len, (void **) &pphar);
+ pphar = zend_hash_str_find_ptr(&(PHAR_G(phar_fname_map)), fname, fname_len);
if (!pphar && PHAR_G(manifest_cached)) {
- zend_hash_find(&cached_phars, fname, fname_len, (void **) &pphar);
+ pphar = zend_hash_str_find_ptr(&cached_phars, fname, fname_len);
}
do {
- if (zend_hash_exists(&((*pphar)->manifest), e, e_len)) {
+ if (zend_hash_str_exists(&(pphar->manifest), e, e_len)) {
if (u) {
u[0] = '/';
*ru = estrndup(u, u_len+1);
@@ -444,25 +421,28 @@ PHP_METHOD(Phar, running)
int fname_len, arch_len, entry_len;
zend_bool retphar = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &retphar) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &retphar) == FAILURE) {
return;
}
- fname = (char*)zend_get_executed_filename(TSRMLS_C);
+ fname = (char*)zend_get_executed_filename();
fname_len = strlen(fname);
- if (fname_len > 7 && !memcmp(fname, "phar://", 7) && SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0 TSRMLS_CC)) {
+ if (fname_len > 7 && !memcmp(fname, "phar://", 7) && SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0)) {
efree(entry);
if (retphar) {
- RETVAL_STRINGL(fname, arch_len + 7, 1);
+ RETVAL_STRINGL(fname, arch_len + 7);
efree(arch);
return;
} else {
- RETURN_STRINGL(arch, arch_len, 0);
+ // TODO: avoid reallocation ???
+ RETVAL_STRINGL(arch, arch_len);
+ efree(arch);
+ return;
}
}
- RETURN_STRINGL("", 0, 1);
+ RETURN_EMPTY_STRING();
}
/* }}} */
@@ -475,38 +455,39 @@ PHP_METHOD(Phar, running)
PHP_METHOD(Phar, mount)
{
char *fname, *arch = NULL, *entry = NULL, *path, *actual;
- int fname_len, arch_len, entry_len, path_len, actual_len;
- phar_archive_data **pphar;
+ int fname_len, arch_len, entry_len;
+ size_t path_len, actual_len;
+ phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
- fname = (char*)zend_get_executed_filename(TSRMLS_C);
+ fname = (char*)zend_get_executed_filename();
fname_len = strlen(fname);
#ifdef PHP_WIN32
phar_unixify_path_separators(fname, fname_len);
#endif
- if (fname_len > 7 && !memcmp(fname, "phar://", 7) && SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0 TSRMLS_CC)) {
+ if (fname_len > 7 && !memcmp(fname, "phar://", 7) && SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0)) {
efree(entry);
entry = NULL;
if (path_len > 7 && !memcmp(path, "phar://", 7)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Can only mount internal paths within a phar archive, use a relative path instead of \"%s\"", path);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "Can only mount internal paths within a phar archive, use a relative path instead of \"%s\"", path);
efree(arch);
return;
}
carry_on2:
- if (SUCCESS != zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), arch, arch_len, (void **)&pphar)) {
- if (PHAR_G(manifest_cached) && SUCCESS == zend_hash_find(&cached_phars, arch, arch_len, (void **)&pphar)) {
- if (SUCCESS == phar_copy_on_write(pphar TSRMLS_CC)) {
+ if (NULL == (pphar = zend_hash_str_find_ptr(&(PHAR_G(phar_fname_map)), arch, arch_len))) {
+ if (PHAR_G(manifest_cached) && NULL != (pphar = zend_hash_str_find_ptr(&cached_phars, arch, arch_len))) {
+ if (SUCCESS == phar_copy_on_write(&pphar)) {
goto carry_on;
}
}
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s is not a phar archive, cannot mount", arch);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s is not a phar archive, cannot mount", arch);
if (arch) {
efree(arch);
@@ -514,8 +495,8 @@ carry_on2:
return;
}
carry_on:
- if (SUCCESS != phar_mount_entry(*pphar, actual, actual_len, path, path_len TSRMLS_CC)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Mounting of %s to %s within phar %s failed", path, actual, arch);
+ if (SUCCESS != phar_mount_entry(pphar, actual, actual_len, path, path_len)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0, "Mounting of %s to %s within phar %s failed", path, actual, arch);
if (path && path == entry) {
efree(entry);
}
@@ -536,21 +517,21 @@ carry_on:
}
return;
- } else if (PHAR_GLOBALS->phar_fname_map.arBuckets && SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), fname, fname_len, (void **)&pphar)) {
+ } else if (PHAR_G(phar_fname_map.u.flags) && NULL != (pphar = zend_hash_str_find_ptr(&(PHAR_G(phar_fname_map)), fname, fname_len))) {
goto carry_on;
- } else if (PHAR_G(manifest_cached) && SUCCESS == zend_hash_find(&cached_phars, fname, fname_len, (void **)&pphar)) {
- if (SUCCESS == phar_copy_on_write(pphar TSRMLS_CC)) {
+ } else if (PHAR_G(manifest_cached) && NULL != (pphar = zend_hash_str_find_ptr(&cached_phars, fname, fname_len))) {
+ if (SUCCESS == phar_copy_on_write(&pphar)) {
goto carry_on;
}
goto carry_on;
- } else if (SUCCESS == phar_split_fname(path, path_len, &arch, &arch_len, &entry, &entry_len, 2, 0 TSRMLS_CC)) {
+ } else if (SUCCESS == phar_split_fname(path, path_len, &arch, &arch_len, &entry, &entry_len, 2, 0)) {
path = entry;
path_len = entry_len;
goto carry_on2;
}
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Mounting of %s to %s failed", path, actual);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "Mounting of %s to %s failed", path, actual);
}
/* }}} */
@@ -565,24 +546,27 @@ PHP_METHOD(Phar, webPhar)
{
zval *mimeoverride = NULL, *rewrite = NULL;
char *alias = NULL, *error, *index_php = NULL, *f404 = NULL, *ru = NULL;
- int alias_len = 0, ret, f404_len = 0, free_pathinfo = 0, ru_len = 0;
+ size_t alias_len = 0, f404_len = 0, free_pathinfo = 0;
+ int ru_len = 0;
char *fname, *path_info, *mime_type = NULL, *entry, *pt;
const char *basename;
- int fname_len, entry_len, code, index_php_len = 0, not_cgi;
+ size_t fname_len, index_php_len = 0;
+ int entry_len, code, not_cgi;
phar_archive_data *phar = NULL;
phar_entry_info *info = NULL;
+ size_t sapi_mod_name_len = strlen(sapi_module.name);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!saz", &alias, &alias_len, &index_php, &index_php_len, &f404, &f404_len, &mimeoverride, &rewrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!saz", &alias, &alias_len, &index_php, &index_php_len, &f404, &f404_len, &mimeoverride, &rewrite) == FAILURE) {
return;
}
- phar_request_initialize(TSRMLS_C);
- fname = (char*)zend_get_executed_filename(TSRMLS_C);
+ phar_request_initialize();
+ fname = (char*)zend_get_executed_filename();
fname_len = strlen(fname);
- if (phar_open_executed_filename(alias, alias_len, &error TSRMLS_CC) != SUCCESS) {
+ if (phar_open_executed_filename(alias, alias_len, &error) != SUCCESS) {
if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
return;
@@ -605,46 +589,46 @@ PHP_METHOD(Phar, webPhar)
++basename;
}
- if ((strlen(sapi_module.name) == sizeof("cgi-fcgi")-1 && !strncmp(sapi_module.name, "cgi-fcgi", sizeof("cgi-fcgi")-1))
- || (strlen(sapi_module.name) == sizeof("fpm-fcgi")-1 && !strncmp(sapi_module.name, "fpm-fcgi", sizeof("fpm-fcgi")-1))
- || (strlen(sapi_module.name) == sizeof("cgi")-1 && !strncmp(sapi_module.name, "cgi", sizeof("cgi")-1))) {
+ if ((sapi_mod_name_len == sizeof("cgi-fcgi") - 1 && !strncmp(sapi_module.name, "cgi-fcgi", sizeof("cgi-fcgi") - 1))
+ || (sapi_mod_name_len == sizeof("fpm-fcgi") - 1 && !strncmp(sapi_module.name, "fpm-fcgi", sizeof("fpm-fcgi") - 1))
+ || (sapi_mod_name_len == sizeof("cgi") - 1 && !strncmp(sapi_module.name, "cgi", sizeof("cgi") - 1))) {
- if (PG(http_globals)[TRACK_VARS_SERVER]) {
- HashTable *_server = Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]);
- zval **z_script_name, **z_path_info;
+ if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) != IS_UNDEF) {
+ HashTable *_server = Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]);
+ zval *z_script_name, *z_path_info;
- if (SUCCESS != zend_hash_find(_server, "SCRIPT_NAME", sizeof("SCRIPT_NAME"), (void**)&z_script_name) ||
- IS_STRING != Z_TYPE_PP(z_script_name) ||
- !strstr(Z_STRVAL_PP(z_script_name), basename)) {
+ if (NULL == (z_script_name = zend_hash_str_find(_server, "SCRIPT_NAME", sizeof("SCRIPT_NAME")-1)) ||
+ IS_STRING != Z_TYPE_P(z_script_name) ||
+ !strstr(Z_STRVAL_P(z_script_name), basename)) {
return;
}
- if (SUCCESS == zend_hash_find(_server, "PATH_INFO", sizeof("PATH_INFO"), (void**)&z_path_info) &&
- IS_STRING == Z_TYPE_PP(z_path_info)) {
- entry_len = Z_STRLEN_PP(z_path_info);
- entry = estrndup(Z_STRVAL_PP(z_path_info), entry_len);
- path_info = emalloc(Z_STRLEN_PP(z_script_name) + entry_len + 1);
- memcpy(path_info, Z_STRVAL_PP(z_script_name), Z_STRLEN_PP(z_script_name));
- memcpy(path_info + Z_STRLEN_PP(z_script_name), entry, entry_len + 1);
+ if (NULL != (z_path_info = zend_hash_str_find(_server, "PATH_INFO", sizeof("PATH_INFO")-1)) &&
+ IS_STRING == Z_TYPE_P(z_path_info)) {
+ entry_len = Z_STRLEN_P(z_path_info);
+ entry = estrndup(Z_STRVAL_P(z_path_info), entry_len);
+ path_info = emalloc(Z_STRLEN_P(z_script_name) + entry_len + 1);
+ memcpy(path_info, Z_STRVAL_P(z_script_name), Z_STRLEN_P(z_script_name));
+ memcpy(path_info + Z_STRLEN_P(z_script_name), entry, entry_len + 1);
free_pathinfo = 1;
} else {
entry_len = 0;
entry = estrndup("", 0);
- path_info = Z_STRVAL_PP(z_script_name);
+ path_info = Z_STRVAL_P(z_script_name);
}
- pt = estrndup(Z_STRVAL_PP(z_script_name), Z_STRLEN_PP(z_script_name));
+ pt = estrndup(Z_STRVAL_P(z_script_name), Z_STRLEN_P(z_script_name));
} else {
char *testit;
- testit = sapi_getenv("SCRIPT_NAME", sizeof("SCRIPT_NAME")-1 TSRMLS_CC);
+ testit = sapi_getenv("SCRIPT_NAME", sizeof("SCRIPT_NAME")-1);
if (!(pt = strstr(testit, basename))) {
efree(testit);
return;
}
- path_info = sapi_getenv("PATH_INFO", sizeof("PATH_INFO")-1 TSRMLS_CC);
+ path_info = sapi_getenv("PATH_INFO", sizeof("PATH_INFO")-1);
if (path_info) {
entry = path_info;
@@ -680,14 +664,12 @@ PHP_METHOD(Phar, webPhar)
if (rewrite) {
zend_fcall_info fci;
zend_fcall_info_cache fcc;
- zval *params, *retval_ptr, **zp[1];
+ zval params, retval;
- MAKE_STD_ZVAL(params);
- ZVAL_STRINGL(params, entry, entry_len, 1);
- zp[0] = &params;
+ ZVAL_STRINGL(&params, entry, entry_len);
- if (FAILURE == zend_fcall_info_init(rewrite, 0, &fci, &fcc, NULL, NULL TSRMLS_CC)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar error: invalid rewrite callback");
+ if (FAILURE == zend_fcall_info_init(rewrite, 0, &fci, &fcc, NULL, NULL)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: invalid rewrite callback");
if (free_pathinfo) {
efree(path_info);
@@ -697,13 +679,13 @@ PHP_METHOD(Phar, webPhar)
}
fci.param_count = 1;
- fci.params = zp;
- Z_ADDREF_P(params);
- fci.retval_ptr_ptr = &retval_ptr;
+ fci.params = &params;
+ Z_ADDREF(params);
+ fci.retval = &retval;
- if (FAILURE == zend_call_function(&fci, &fcc TSRMLS_CC)) {
+ if (FAILURE == zend_call_function(&fci, &fcc)) {
if (!EG(exception)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar error: failed to call rewrite callback");
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: failed to call rewrite callback");
}
if (free_pathinfo) {
@@ -713,29 +695,23 @@ PHP_METHOD(Phar, webPhar)
return;
}
- if (!fci.retval_ptr_ptr || !retval_ptr) {
+ if (Z_TYPE_P(fci.retval) == IS_UNDEF || Z_TYPE(retval) == IS_UNDEF) {
if (free_pathinfo) {
efree(path_info);
}
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar error: rewrite callback must return a string or false");
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: rewrite callback must return a string or false");
return;
}
- switch (Z_TYPE_P(retval_ptr)) {
+ switch (Z_TYPE(retval)) {
case IS_STRING:
efree(entry);
-
- if (fci.retval_ptr_ptr != &retval_ptr) {
- entry = estrndup(Z_STRVAL_PP(fci.retval_ptr_ptr), Z_STRLEN_PP(fci.retval_ptr_ptr));
- entry_len = Z_STRLEN_PP(fci.retval_ptr_ptr);
- } else {
- entry = Z_STRVAL_P(retval_ptr);
- entry_len = Z_STRLEN_P(retval_ptr);
- }
-
+ entry = estrndup(Z_STRVAL_P(fci.retval), Z_STRLEN_P(fci.retval));
+ entry_len = Z_STRLEN_P(fci.retval);
break;
- case IS_BOOL:
- phar_do_403(entry, entry_len TSRMLS_CC);
+ case IS_TRUE:
+ case IS_FALSE:
+ phar_do_403(entry, entry_len);
if (free_pathinfo) {
efree(path_info);
@@ -744,19 +720,17 @@ PHP_METHOD(Phar, webPhar)
zend_bailout();
return;
default:
- efree(retval_ptr);
-
if (free_pathinfo) {
efree(path_info);
}
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar error: rewrite callback must return a string or false");
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: rewrite callback must return a string or false");
return;
}
}
if (entry_len) {
- phar_postprocess_ru_web(fname, fname_len, &entry, &entry_len, &ru, &ru_len TSRMLS_CC);
+ phar_postprocess_ru_web(fname, fname_len, &entry, &entry_len, &ru, &ru_len);
}
if (!entry_len || (entry_len == 1 && entry[0] == '/')) {
@@ -775,9 +749,9 @@ PHP_METHOD(Phar, webPhar)
entry_len = sizeof("/index.php")-1;
}
- if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, NULL TSRMLS_CC) ||
- (info = phar_get_entry_info(phar, entry, entry_len, NULL, 0 TSRMLS_CC)) == NULL) {
- phar_do_404(phar, fname, fname_len, f404, f404_len, entry, entry_len TSRMLS_CC);
+ if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, NULL) ||
+ (info = phar_get_entry_info(phar, entry, entry_len, NULL, 0)) == NULL) {
+ phar_do_404(phar, fname, fname_len, f404, f404_len, entry, entry_len);
if (free_pathinfo) {
efree(path_info);
@@ -790,7 +764,7 @@ PHP_METHOD(Phar, webPhar)
ctr.response_code = 301;
ctr.line_len = sizeof("HTTP/1.1 301 Moved Permanently")-1;
ctr.line = "HTTP/1.1 301 Moved Permanently";
- sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC);
+ sapi_header_op(SAPI_HEADER_REPLACE, &ctr);
if (not_cgi) {
tmp = strstr(path_info, basename) + fname_len;
@@ -814,16 +788,16 @@ PHP_METHOD(Phar, webPhar)
efree(path_info);
}
- sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC);
- sapi_send_headers(TSRMLS_C);
+ sapi_header_op(SAPI_HEADER_REPLACE, &ctr);
+ sapi_send_headers();
efree(ctr.line);
zend_bailout();
}
}
- if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, NULL TSRMLS_CC) ||
- (info = phar_get_entry_info(phar, entry, entry_len, NULL, 0 TSRMLS_CC)) == NULL) {
- phar_do_404(phar, fname, fname_len, f404, f404_len, entry, entry_len TSRMLS_CC);
+ if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, NULL) ||
+ (info = phar_get_entry_info(phar, entry, entry_len, NULL, 0)) == NULL) {
+ phar_do_404(phar, fname, fname_len, f404, f404_len, entry, entry_len);
#ifdef PHP_WIN32
efree(fname);
#endif
@@ -832,19 +806,24 @@ PHP_METHOD(Phar, webPhar)
if (mimeoverride && zend_hash_num_elements(Z_ARRVAL_P(mimeoverride))) {
const char *ext = zend_memrchr(entry, '.', entry_len);
- zval **val;
+ zval *val;
if (ext) {
++ext;
- if (SUCCESS == zend_hash_find(Z_ARRVAL_P(mimeoverride), ext, strlen(ext)+1, (void **) &val)) {
- switch (Z_TYPE_PP(val)) {
+ if (NULL != (val = zend_hash_str_find(Z_ARRVAL_P(mimeoverride), ext, strlen(ext)))) {
+ switch (Z_TYPE_P(val)) {
case IS_LONG:
- if (Z_LVAL_PP(val) == PHAR_MIME_PHP || Z_LVAL_PP(val) == PHAR_MIME_PHPS) {
+ if (Z_LVAL_P(val) == PHAR_MIME_PHP || Z_LVAL_P(val) == PHAR_MIME_PHPS) {
mime_type = "";
- code = Z_LVAL_PP(val);
+ code = Z_LVAL_P(val);
} else {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed");
+ zend_throw_exception_ex(phar_ce_PharException, 0, "Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed");
+ if (free_pathinfo) {
+ efree(path_info);
+ }
+ efree(pt);
+ efree(entry);
#ifdef PHP_WIN32
efree(fname);
#endif
@@ -852,11 +831,16 @@ PHP_METHOD(Phar, webPhar)
}
break;
case IS_STRING:
- mime_type = Z_STRVAL_PP(val);
+ mime_type = Z_STRVAL_P(val);
code = PHAR_MIME_OTHER;
break;
default:
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed");
+ zend_throw_exception_ex(phar_ce_PharException, 0, "Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed");
+ if (free_pathinfo) {
+ efree(path_info);
+ }
+ efree(pt);
+ efree(entry);
#ifdef PHP_WIN32
efree(fname);
#endif
@@ -867,9 +851,9 @@ PHP_METHOD(Phar, webPhar)
}
if (!mime_type) {
- code = phar_file_type(&PHAR_G(mime_types), entry, &mime_type TSRMLS_CC);
+ code = phar_file_type(&PHAR_G(mime_types), entry, &mime_type);
}
- ret = phar_file_action(phar, info, mime_type, code, entry, entry_len, fname, pt, ru, ru_len TSRMLS_CC);
+ phar_file_action(phar, info, mime_type, code, entry, entry_len, fname, pt, ru, ru_len);
}
/* }}} */
@@ -881,54 +865,48 @@ PHP_METHOD(Phar, webPhar)
*/
PHP_METHOD(Phar, mungServer)
{
- zval *mungvalues;
+ zval *mungvalues, *data;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &mungvalues) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "a", &mungvalues) == FAILURE) {
return;
}
if (!zend_hash_num_elements(Z_ARRVAL_P(mungvalues))) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "No values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME");
+ zend_throw_exception_ex(phar_ce_PharException, 0, "No values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME");
return;
}
if (zend_hash_num_elements(Z_ARRVAL_P(mungvalues)) > 4) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Too many values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME");
+ zend_throw_exception_ex(phar_ce_PharException, 0, "Too many values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME");
return;
}
- phar_request_initialize(TSRMLS_C);
+ phar_request_initialize();
- for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(mungvalues)); SUCCESS == zend_hash_has_more_elements(Z_ARRVAL_P(mungvalues)); zend_hash_move_forward(Z_ARRVAL_P(mungvalues))) {
- zval **data = NULL;
+ ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(mungvalues), data) {
- if (SUCCESS != zend_hash_get_current_data(Z_ARRVAL_P(mungvalues), (void **) &data)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "unable to retrieve array value in Phar::mungServer()");
+ if (Z_TYPE_P(data) != IS_STRING) {
+ zend_throw_exception_ex(phar_ce_PharException, 0, "Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME");
return;
}
- if (Z_TYPE_PP(data) != IS_STRING) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME");
- return;
+ if (Z_STRLEN_P(data) == sizeof("PHP_SELF")-1 && !strncmp(Z_STRVAL_P(data), "PHP_SELF", sizeof("PHP_SELF")-1)) {
+ PHAR_G(phar_SERVER_mung_list) |= PHAR_MUNG_PHP_SELF;
}
- if (Z_STRLEN_PP(data) == sizeof("PHP_SELF")-1 && !strncmp(Z_STRVAL_PP(data), "PHP_SELF", sizeof("PHP_SELF")-1)) {
- PHAR_GLOBALS->phar_SERVER_mung_list |= PHAR_MUNG_PHP_SELF;
- }
-
- if (Z_STRLEN_PP(data) == sizeof("REQUEST_URI")-1) {
- if (!strncmp(Z_STRVAL_PP(data), "REQUEST_URI", sizeof("REQUEST_URI")-1)) {
- PHAR_GLOBALS->phar_SERVER_mung_list |= PHAR_MUNG_REQUEST_URI;
+ if (Z_STRLEN_P(data) == sizeof("REQUEST_URI")-1) {
+ if (!strncmp(Z_STRVAL_P(data), "REQUEST_URI", sizeof("REQUEST_URI")-1)) {
+ PHAR_G(phar_SERVER_mung_list) |= PHAR_MUNG_REQUEST_URI;
}
- if (!strncmp(Z_STRVAL_PP(data), "SCRIPT_NAME", sizeof("SCRIPT_NAME")-1)) {
- PHAR_GLOBALS->phar_SERVER_mung_list |= PHAR_MUNG_SCRIPT_NAME;
+ if (!strncmp(Z_STRVAL_P(data), "SCRIPT_NAME", sizeof("SCRIPT_NAME")-1)) {
+ PHAR_G(phar_SERVER_mung_list) |= PHAR_MUNG_SCRIPT_NAME;
}
}
- if (Z_STRLEN_PP(data) == sizeof("SCRIPT_FILENAME")-1 && !strncmp(Z_STRVAL_PP(data), "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME")-1)) {
- PHAR_GLOBALS->phar_SERVER_mung_list |= PHAR_MUNG_SCRIPT_FILENAME;
+ if (Z_STRLEN_P(data) == sizeof("SCRIPT_FILENAME")-1 && !strncmp(Z_STRVAL_P(data), "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME")-1)) {
+ PHAR_G(phar_SERVER_mung_list) |= PHAR_MUNG_SCRIPT_FILENAME;
}
- }
+ } ZEND_HASH_FOREACH_END();
}
/* }}} */
@@ -945,7 +923,7 @@ PHP_METHOD(Phar, interceptFileFuncs)
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- phar_intercept_functions(TSRMLS_C);
+ phar_intercept_functions();
}
/* }}} */
@@ -956,22 +934,22 @@ PHP_METHOD(Phar, interceptFileFuncs)
*/
PHP_METHOD(Phar, createDefaultStub)
{
- char *index = NULL, *webindex = NULL, *stub, *error;
- int index_len = 0, webindex_len = 0;
- size_t stub_len;
+ char *index = NULL, *webindex = NULL, *error;
+ zend_string *stub;
+ size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
- stub = phar_create_default_stub(index, webindex, &stub_len, &error TSRMLS_CC);
+ stub = phar_create_default_stub(index, webindex, &error);
if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
return;
}
- RETURN_STRINGL(stub, stub_len, 0);
+ RETURN_NEW_STR(stub);
}
/* }}} */
@@ -980,19 +958,19 @@ PHP_METHOD(Phar, createDefaultStub)
PHP_METHOD(Phar, mapPhar)
{
char *alias = NULL, *error;
- int alias_len = 0;
- long dataoffset = 0;
+ size_t alias_len = 0;
+ zend_long dataoffset = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!l", &alias, &alias_len, &dataoffset) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!l", &alias, &alias_len, &dataoffset) == FAILURE) {
return;
}
- phar_request_initialize(TSRMLS_C);
+ phar_request_initialize();
- RETVAL_BOOL(phar_open_executed_filename(alias, alias_len, &error TSRMLS_CC) == SUCCESS);
+ RETVAL_BOOL(phar_open_executed_filename(alias, alias_len, &error) == SUCCESS);
if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
} /* }}} */
@@ -1002,18 +980,18 @@ PHP_METHOD(Phar, mapPhar)
PHP_METHOD(Phar, loadPhar)
{
char *fname, *alias = NULL, *error;
- int fname_len, alias_len = 0;
+ size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
- phar_request_initialize(TSRMLS_C);
+ phar_request_initialize();
- RETVAL_BOOL(phar_open_from_filename(fname, fname_len, alias, alias_len, REPORT_ERRORS, NULL, &error TSRMLS_CC) == SUCCESS);
+ RETVAL_BOOL(phar_open_from_filename(fname, fname_len, alias, alias_len, REPORT_ERRORS, NULL, &error) == SUCCESS);
if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
} /* }}} */
@@ -1025,7 +1003,7 @@ PHP_METHOD(Phar, apiVersion)
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- RETURN_STRINGL(PHP_PHAR_API_VERSION, sizeof(PHP_PHAR_API_VERSION)-1, 1);
+ RETURN_STRINGL(PHP_PHAR_API_VERSION, sizeof(PHP_PHAR_API_VERSION)-1);
}
/* }}}*/
@@ -1033,13 +1011,13 @@ PHP_METHOD(Phar, apiVersion)
* Returns whether phar extension supports compression using zlib/bzip2 */
PHP_METHOD(Phar, canCompress)
{
- long method = 0;
+ zend_long method = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &method) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &method) == FAILURE) {
return;
}
- phar_request_initialize(TSRMLS_C);
+ phar_request_initialize();
switch (method) {
case PHAR_ENT_COMPRESSED_GZ:
if (PHAR_G(has_zlib)) {
@@ -1080,15 +1058,16 @@ PHP_METHOD(Phar, isValidPharFilename)
{
char *fname;
const char *ext_str;
- int fname_len, ext_len, is_executable;
+ size_t fname_len;
+ int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
is_executable = executable;
- RETVAL_BOOL(phar_detect_phar_fname_ext(fname, fname_len, &ext_str, &ext_len, is_executable, 2, 1 TSRMLS_CC) == SUCCESS);
+ RETVAL_BOOL(phar_detect_phar_fname_ext(fname, fname_len, &ext_str, &ext_len, is_executable, 2, 1) == SUCCESS);
}
/* }}} */
@@ -1096,12 +1075,12 @@ PHP_METHOD(Phar, isValidPharFilename)
/**
* from spl_directory
*/
-static void phar_spl_foreign_dtor(spl_filesystem_object *object TSRMLS_DC) /* {{{ */
+static void phar_spl_foreign_dtor(spl_filesystem_object *object) /* {{{ */
{
phar_archive_data *phar = (phar_archive_data *) object->oth;
if (!phar->is_persistent) {
- phar_archive_delref(phar TSRMLS_CC);
+ phar_archive_delref(phar);
}
object->oth = NULL;
@@ -1111,7 +1090,7 @@ static void phar_spl_foreign_dtor(spl_filesystem_object *object TSRMLS_DC) /* {{
/**
* from spl_directory
*/
-static void phar_spl_foreign_clone(spl_filesystem_object *src, spl_filesystem_object *dst TSRMLS_DC) /* {{{ */
+static void phar_spl_foreign_clone(spl_filesystem_object *src, spl_filesystem_object *dst) /* {{{ */
{
phar_archive_data *phar_data = (phar_archive_data *) dst->oth;
@@ -1139,37 +1118,38 @@ static spl_other_handler phar_spl_foreign_handler = {
PHP_METHOD(Phar, __construct)
{
#if !HAVE_SPL
- zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "Cannot instantiate Phar object without SPL extension");
+ zend_throw_exception_ex(zend_ce_exception, 0, "Cannot instantiate Phar object without SPL extension");
#else
char *fname, *alias = NULL, *error, *arch = NULL, *entry = NULL, *save_fname;
- int fname_len, alias_len = 0, arch_len, entry_len, is_data;
- long flags = SPL_FILE_DIR_SKIPDOTS|SPL_FILE_DIR_UNIXPATHS;
- long format = 0;
+ size_t fname_len, alias_len = 0;
+ int arch_len, entry_len, is_data;
+ zend_long flags = SPL_FILE_DIR_SKIPDOTS|SPL_FILE_DIR_UNIXPATHS;
+ zend_long format = 0;
phar_archive_object *phar_obj;
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1, arg2;
- phar_obj = (phar_archive_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+ phar_obj = (phar_archive_object*)((char*)Z_OBJ_P(zobj) - Z_OBJ_P(zobj)->handlers->offset);
- is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data TSRMLS_CC);
+ is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
- if (phar_obj->arc.archive) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot call constructor twice");
+ if (phar_obj->archive) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot call constructor twice");
return;
}
save_fname = fname;
- if (SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, !is_data, 2 TSRMLS_CC)) {
+ if (SUCCESS == phar_split_fname(fname, (int)fname_len, &arch, &arch_len, &entry, &entry_len, !is_data, 2)) {
/* use arch (the basename for the archive) for fname instead of fname */
/* this allows support for RecursiveDirectoryIterator of subdirectories */
#ifdef PHP_WIN32
@@ -1186,7 +1166,7 @@ PHP_METHOD(Phar, __construct)
#endif
}
- if (phar_open_or_create_filename(fname, fname_len, alias, alias_len, is_data, REPORT_ERRORS, &phar_data, &error TSRMLS_CC) == FAILURE) {
+ if (phar_open_or_create_filename(fname, fname_len, alias, alias_len, is_data, REPORT_ERRORS, &phar_data, &error) == FAILURE) {
if (fname == arch && fname != save_fname) {
efree(arch);
@@ -1198,11 +1178,11 @@ PHP_METHOD(Phar, __construct)
}
if (error) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"%s", error);
efree(error);
} else {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Phar creation or opening failed");
}
@@ -1221,10 +1201,10 @@ PHP_METHOD(Phar, __construct)
if ((is_data && !phar_data->is_data) || (!is_data && phar_data->is_data)) {
if (is_data) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"PharData class can only be used for non-executable tar and zip archives");
} else {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Phar class can only be used for executable tar and zip archives");
}
efree(entry);
@@ -1237,7 +1217,7 @@ PHP_METHOD(Phar, __construct)
++(phar_data->refcount);
}
- phar_obj->arc.archive = phar_data;
+ phar_obj->archive = phar_data;
phar_obj->spl.oth_handler = &phar_spl_foreign_handler;
if (entry) {
@@ -1247,19 +1227,19 @@ PHP_METHOD(Phar, __construct)
fname_len = spprintf(&fname, 0, "phar://%s", phar_data->fname);
}
- INIT_PZVAL(&arg1);
- ZVAL_STRINGL(&arg1, fname, fname_len, 0);
- INIT_PZVAL(&arg2);
+ ZVAL_STRINGL(&arg1, fname, fname_len);
ZVAL_LONG(&arg2, flags);
- zend_call_method_with_2_params(&zobj, Z_OBJCE_P(zobj),
+ zend_call_method_with_2_params(zobj, Z_OBJCE_P(zobj),
&spl_ce_RecursiveDirectoryIterator->constructor, "__construct", NULL, &arg1, &arg2);
+ zval_ptr_dtor(&arg1);
+
if (!phar_data->is_persistent) {
- phar_obj->arc.archive->is_data = is_data;
+ phar_obj->archive->is_data = is_data;
} else if (!EG(exception)) {
/* register this guy so we can modify if necessary */
- zend_hash_add(&PHAR_GLOBALS->phar_persist_map, (const char *) phar_obj->arc.archive, sizeof(phar_obj->arc.archive), (void *) &phar_obj, sizeof(phar_archive_object **), NULL);
+ zend_hash_str_add_ptr(&PHAR_G(phar_persist_map), (const char *) phar_obj->archive, sizeof(phar_obj->archive), phar_obj);
}
phar_obj->spl.info_class = phar_ce_entry;
@@ -1279,17 +1259,17 @@ PHP_METHOD(Phar, getSupportedSignatures)
array_init(return_value);
- add_next_index_stringl(return_value, "MD5", 3, 1);
- add_next_index_stringl(return_value, "SHA-1", 5, 1);
+ add_next_index_stringl(return_value, "MD5", 3);
+ add_next_index_stringl(return_value, "SHA-1", 5);
#ifdef PHAR_HASH_OK
- add_next_index_stringl(return_value, "SHA-256", 7, 1);
- add_next_index_stringl(return_value, "SHA-512", 7, 1);
+ add_next_index_stringl(return_value, "SHA-256", 7);
+ add_next_index_stringl(return_value, "SHA-512", 7);
#endif
#if PHAR_HAVE_OPENSSL
- add_next_index_stringl(return_value, "OpenSSL", 7, 1);
+ add_next_index_stringl(return_value, "OpenSSL", 7);
#else
- if (zend_hash_exists(&module_registry, "openssl", sizeof("openssl"))) {
- add_next_index_stringl(return_value, "OpenSSL", 7, 1);
+ if (zend_hash_str_exists(&module_registry, "openssl", sizeof("openssl")-1)) {
+ add_next_index_stringl(return_value, "OpenSSL", 7);
}
#endif
}
@@ -1305,14 +1285,14 @@ PHP_METHOD(Phar, getSupportedCompression)
}
array_init(return_value);
- phar_request_initialize(TSRMLS_C);
+ phar_request_initialize();
if (PHAR_G(has_zlib)) {
- add_next_index_stringl(return_value, "GZ", 2, 1);
+ add_next_index_stringl(return_value, "GZ", 2);
}
if (PHAR_G(has_bz2)) {
- add_next_index_stringl(return_value, "BZIP2", 5, 1);
+ add_next_index_stringl(return_value, "BZIP2", 5);
}
}
/* }}} */
@@ -1323,34 +1303,35 @@ PHP_METHOD(Phar, getSupportedCompression)
PHP_METHOD(Phar, unlinkArchive)
{
char *fname, *error, *zname, *arch, *entry;
- int fname_len, zname_len, arch_len, entry_len;
+ size_t fname_len;
+ int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
if (!fname_len) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Unknown phar archive \"\"");
+ zend_throw_exception_ex(phar_ce_PharException, 0, "Unknown phar archive \"\"");
return;
}
- if (FAILURE == phar_open_from_filename(fname, fname_len, NULL, 0, REPORT_ERRORS, &phar, &error TSRMLS_CC)) {
+ if (FAILURE == phar_open_from_filename(fname, fname_len, NULL, 0, REPORT_ERRORS, &phar, &error)) {
if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Unknown phar archive \"%s\": %s", fname, error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "Unknown phar archive \"%s\": %s", fname, error);
efree(error);
} else {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Unknown phar archive \"%s\"", fname);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "Unknown phar archive \"%s\"", fname);
}
return;
}
- zname = (char*)zend_get_executed_filename(TSRMLS_C);
+ zname = (char*)zend_get_executed_filename();
zname_len = strlen(zname);
- if (zname_len > 7 && !memcmp(zname, "phar://", 7) && SUCCESS == phar_split_fname(zname, zname_len, &arch, &arch_len, &entry, &entry_len, 2, 0 TSRMLS_CC)) {
+ if (zname_len > 7 && !memcmp(zname, "phar://", 7) && SUCCESS == phar_split_fname(zname, zname_len, &arch, &arch_len, &entry, &entry_len, 2, 0)) {
if (arch_len == fname_len && !memcmp(arch, fname, arch_len)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar archive \"%s\" cannot be unlinked from within itself", fname);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar archive \"%s\" cannot be unlinked from within itself", fname);
efree(arch);
efree(entry);
return;
@@ -1360,12 +1341,12 @@ PHP_METHOD(Phar, unlinkArchive)
}
if (phar->is_persistent) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar archive \"%s\" is in phar.cache_list, cannot unlinkArchive()", fname);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar archive \"%s\" is in phar.cache_list, cannot unlinkArchive()", fname);
return;
}
if (phar->refcount) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar archive \"%s\" has open file handles or objects. fclose() all file handles, and unset() all objects prior to calling unlinkArchive()", fname);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar archive \"%s\" has open file handles or objects. fclose() all file handles, and unset() all objects prior to calling unlinkArchive()", fname);
return;
}
@@ -1375,7 +1356,7 @@ PHP_METHOD(Phar, unlinkArchive)
PHAR_G(last_phar) = NULL;
PHAR_G(last_phar_name) = PHAR_G(last_alias) = NULL;
- phar_archive_delref(phar TSRMLS_CC);
+ phar_archive_delref(phar);
unlink(fname);
efree(fname);
RETURN_TRUE;
@@ -1385,9 +1366,10 @@ PHP_METHOD(Phar, unlinkArchive)
#if HAVE_SPL
#define PHAR_ARCHIVE_OBJECT() \
- phar_archive_object *phar_obj = (phar_archive_object*)zend_object_store_get_object(getThis() TSRMLS_CC); \
- if (!phar_obj->arc.archive) { \
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
+ zval *zobj = getThis(); \
+ phar_archive_object *phar_obj = (phar_archive_object*)((char*)Z_OBJ_P(zobj) - Z_OBJ_P(zobj)->handlers->offset); \
+ if (!phar_obj->archive) { \
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \
"Cannot call method on an uninitialized Phar object"); \
return; \
}
@@ -1397,10 +1379,11 @@ PHP_METHOD(Phar, unlinkArchive)
*/
PHP_METHOD(Phar, __destruct)
{
- phar_archive_object *phar_obj = (phar_archive_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+ zval *zobj = getThis();
+ phar_archive_object *phar_obj = (phar_archive_object*)((char*)Z_OBJ_P(zobj) - Z_OBJ_P(zobj)->handlers->offset);
- if (phar_obj->arc.archive && phar_obj->arc.archive->is_persistent) {
- zend_hash_del(&PHAR_GLOBALS->phar_persist_map, (const char *) phar_obj->arc.archive, sizeof(phar_obj->arc.archive));
+ if (phar_obj->archive && phar_obj->archive->is_persistent) {
+ zend_hash_str_del(&PHAR_G(phar_persist_map), (const char *) phar_obj->archive, sizeof(phar_obj->archive));
}
}
/* }}} */
@@ -1409,28 +1392,28 @@ struct _phar_t {
phar_archive_object *p;
zend_class_entry *c;
char *b;
- uint l;
zval *ret;
- int count;
php_stream *fp;
+ uint l;
+ int count;
};
-static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{ */
+static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */
{
- zval **value;
+ zval *value;
zend_bool close_fp = 1;
struct _phar_t *p_obj = (struct _phar_t*) puser;
uint str_key_len, base_len = p_obj->l, fname_len;
phar_entry_data *data;
php_stream *fp;
size_t contents_len;
- char *fname, *error = NULL, *base = p_obj->b, *opened, *save = NULL, *temp = NULL;
+ char *fname, *error = NULL, *base = p_obj->b, *save = NULL, *temp = NULL;
+ zend_string *opened;
char *str_key;
zend_class_entry *ce = p_obj->c;
phar_archive_object *phar_obj = p_obj->p;
- char *str = "[stream]";
- iter->funcs->get_current_data(iter, &value TSRMLS_CC);
+ value = iter->funcs->get_current_data(iter);
if (EG(exception)) {
return ZEND_HASH_APPLY_STOP;
@@ -1438,24 +1421,24 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{
if (!value) {
/* failure in get_current_data */
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %v returned no value", ce->name);
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned no value", ZSTR_VAL(ce->name));
return ZEND_HASH_APPLY_STOP;
}
- switch (Z_TYPE_PP(value)) {
+ switch (Z_TYPE_P(value)) {
case IS_STRING:
break;
case IS_RESOURCE:
php_stream_from_zval_no_verify(fp, value);
if (!fp) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Iterator %v returned an invalid stream handle", ce->name);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Iterator %v returned an invalid stream handle", ZSTR_VAL(ce->name));
return ZEND_HASH_APPLY_STOP;
}
if (iter->funcs->get_current_key) {
zval key;
- iter->funcs->get_current_key(iter, &key TSRMLS_CC);
+ iter->funcs->get_current_key(iter, &key);
if (EG(exception)) {
return ZEND_HASH_APPLY_STOP;
@@ -1463,7 +1446,7 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{
if (Z_TYPE(key) != IS_STRING) {
zval_dtor(&key);
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %v returned an invalid key (must return a string)", ce->name);
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned an invalid key (must return a string)", ZSTR_VAL(ce->name));
return ZEND_HASH_APPLY_STOP;
}
@@ -1473,44 +1456,44 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{
save = str_key;
zval_dtor(&key);
} else {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %v returned an invalid key (must return a string)", ce->name);
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned an invalid key (must return a string)", ZSTR_VAL(ce->name));
return ZEND_HASH_APPLY_STOP;
}
close_fp = 0;
- opened = (char *) estrndup(str, sizeof("[stream]") - 1);
+ opened = zend_string_init("[stream]", sizeof("[stream]") - 1, 0);
goto after_open_fp;
case IS_OBJECT:
- if (instanceof_function(Z_OBJCE_PP(value), spl_ce_SplFileInfo TSRMLS_CC)) {
+ if (instanceof_function(Z_OBJCE_P(value), spl_ce_SplFileInfo)) {
char *test = NULL;
zval dummy;
- spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(*value TSRMLS_CC);
+ spl_filesystem_object *intern = (spl_filesystem_object*)((char*)Z_OBJ_P(value) - Z_OBJ_P(value)->handlers->offset);
if (!base_len) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Iterator %v returns an SplFileInfo object, so base directory must be specified", ce->name);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Iterator %v returns an SplFileInfo object, so base directory must be specified", ZSTR_VAL(ce->name));
return ZEND_HASH_APPLY_STOP;
}
switch (intern->type) {
case SPL_FS_DIR:
- test = spl_filesystem_object_get_path(intern, NULL TSRMLS_CC);
+ test = spl_filesystem_object_get_path(intern, NULL);
fname_len = spprintf(&fname, 0, "%s%c%s", test, DEFAULT_SLASH, intern->u.dir.entry.d_name);
- php_stat(fname, fname_len, FS_IS_DIR, &dummy TSRMLS_CC);
+ php_stat(fname, fname_len, FS_IS_DIR, &dummy);
- if (Z_BVAL(dummy)) {
+ if (Z_TYPE(dummy) == IS_TRUE) {
/* ignore directories */
efree(fname);
return ZEND_HASH_APPLY_KEEP;
}
- test = expand_filepath(fname, NULL TSRMLS_CC);
+ test = expand_filepath(fname, NULL);
efree(fname);
if (test) {
fname = test;
fname_len = strlen(fname);
} else {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Could not resolve file path");
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Could not resolve file path");
return ZEND_HASH_APPLY_STOP;
}
@@ -1518,9 +1501,9 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{
goto phar_spl_fileinfo;
case SPL_FS_INFO:
case SPL_FS_FILE:
- fname = expand_filepath(intern->file_name, NULL TSRMLS_CC);
+ fname = expand_filepath(intern->file_name, NULL);
if (!fname) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Could not resolve file path");
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Could not resolve file path");
return ZEND_HASH_APPLY_STOP;
}
@@ -1531,18 +1514,18 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{
}
/* fall-through */
default:
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %v returned an invalid value (must return a string)", ce->name);
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned an invalid value (must return a string)", ZSTR_VAL(ce->name));
return ZEND_HASH_APPLY_STOP;
}
- fname = Z_STRVAL_PP(value);
- fname_len = Z_STRLEN_PP(value);
+ fname = Z_STRVAL_P(value);
+ fname_len = Z_STRLEN_P(value);
phar_spl_fileinfo:
if (base_len) {
- temp = expand_filepath(base, NULL TSRMLS_CC);
+ temp = expand_filepath(base, NULL);
if (!temp) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Could not resolve file path");
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Could not resolve file path");
if (save) {
efree(save);
}
@@ -1571,7 +1554,7 @@ phar_spl_fileinfo:
}
} else {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %v returned a path \"%s\" that is not in the base directory \"%s\"", ce->name, fname, base);
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned a path \"%s\" that is not in the base directory \"%s\"", ZSTR_VAL(ce->name), fname, base);
if (save) {
efree(save);
@@ -1583,7 +1566,7 @@ phar_spl_fileinfo:
} else {
if (iter->funcs->get_current_key) {
zval key;
- iter->funcs->get_current_key(iter, &key TSRMLS_CC);
+ iter->funcs->get_current_key(iter, &key);
if (EG(exception)) {
return ZEND_HASH_APPLY_STOP;
@@ -1591,7 +1574,7 @@ phar_spl_fileinfo:
if (Z_TYPE(key) != IS_STRING) {
zval_dtor(&key);
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %v returned an invalid key (must return a string)", ce->name);
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned an invalid key (must return a string)", ZSTR_VAL(ce->name));
return ZEND_HASH_APPLY_STOP;
}
@@ -1601,13 +1584,13 @@ phar_spl_fileinfo:
save = str_key;
zval_dtor(&key);
} else {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %v returned an invalid key (must return a string)", ce->name);
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned an invalid key (must return a string)", ZSTR_VAL(ce->name));
return ZEND_HASH_APPLY_STOP;
}
}
#if PHP_API_VERSION < 20100412
if (PG(safe_mode) && (!php_checkuid(fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %v returned a path \"%s\" that safe mode prevents opening", ce->name, fname);
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned a path \"%s\" that safe mode prevents opening", ZSTR_VAL(ce->name), fname);
if (save) {
efree(save);
@@ -1621,8 +1604,8 @@ phar_spl_fileinfo:
}
#endif
- if (php_check_open_basedir(fname TSRMLS_CC)) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %v returned a path \"%s\" that open_basedir prevents opening", ce->name, fname);
+ if (php_check_open_basedir(fname)) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned a path \"%s\" that open_basedir prevents opening", ZSTR_VAL(ce->name), fname);
if (save) {
efree(save);
@@ -1639,7 +1622,7 @@ phar_spl_fileinfo:
fp = php_stream_open_wrapper(fname, "rb", STREAM_MUST_SEEK|0, &opened);
if (!fp) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %v returned a file that could not be opened \"%s\"", ce->name, fname);
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned a file that could not be opened \"%s\"", ZSTR_VAL(ce->name), fname);
if (save) {
efree(save);
@@ -1663,7 +1646,7 @@ after_open_fp:
}
if (opened) {
- efree(opened);
+ zend_string_release(opened);
}
if (close_fp) {
@@ -1673,8 +1656,8 @@ after_open_fp:
return ZEND_HASH_APPLY_KEEP;
}
- if (!(data = phar_get_or_create_entry_data(phar_obj->arc.archive->fname, phar_obj->arc.archive->fname_len, str_key, str_key_len, "w+b", 0, &error, 1 TSRMLS_CC))) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s cannot be created: %s", str_key, error);
+ if (!(data = phar_get_or_create_entry_data(phar_obj->archive->fname, phar_obj->archive->fname_len, str_key, str_key_len, "w+b", 0, &error, 1))) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %s cannot be created: %s", str_key, error);
efree(error);
if (save) {
@@ -1682,7 +1665,7 @@ after_open_fp:
}
if (opened) {
- efree(opened);
+ zend_string_release(opened);
}
if (temp) {
@@ -1717,7 +1700,7 @@ after_open_fp:
php_stream_close(fp);
}
- add_assoc_string(p_obj->ret, str_key, opened, 0);
+ add_assoc_str(p_obj->ret, str_key, opened);
if (save) {
efree(save);
@@ -1728,7 +1711,7 @@ after_open_fp:
}
data->internal_file->compressed_filesize = data->internal_file->uncompressed_filesize = contents_len;
- phar_entry_delref(data TSRMLS_CC);
+ phar_entry_delref(data);
return ZEND_HASH_APPLY_KEEP;
}
@@ -1743,55 +1726,50 @@ after_open_fp:
PHP_METHOD(Phar, buildFromDirectory)
{
char *dir, *error, *regex = NULL;
- int dir_len, regex_len = 0;
+ size_t dir_len, regex_len = 0;
zend_bool apply_reg = 0;
- zval arg, arg2, *iter, *iteriter, *regexiter = NULL;
+ zval arg, arg2, iter, iteriter, regexiter;
struct _phar_t pass;
PHAR_ARCHIVE_OBJECT();
- if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot write to archive - write operations restricted by INI setting");
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) {
RETURN_FALSE;
}
- MAKE_STD_ZVAL(iter);
-
- if (SUCCESS != object_init_ex(iter, spl_ce_RecursiveDirectoryIterator)) {
+ if (SUCCESS != object_init_ex(&iter, spl_ce_RecursiveDirectoryIterator)) {
zval_ptr_dtor(&iter);
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Unable to instantiate directory iterator for %s", phar_obj->arc.archive->fname);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to instantiate directory iterator for %s", phar_obj->archive->fname);
RETURN_FALSE;
}
- INIT_PZVAL(&arg);
- ZVAL_STRINGL(&arg, dir, dir_len, 0);
- INIT_PZVAL(&arg2);
+ ZVAL_STRINGL(&arg, dir, dir_len);
ZVAL_LONG(&arg2, SPL_FILE_DIR_SKIPDOTS|SPL_FILE_DIR_UNIXPATHS);
zend_call_method_with_2_params(&iter, spl_ce_RecursiveDirectoryIterator,
&spl_ce_RecursiveDirectoryIterator->constructor, "__construct", NULL, &arg, &arg2);
+ zval_ptr_dtor(&arg);
if (EG(exception)) {
zval_ptr_dtor(&iter);
RETURN_FALSE;
}
- MAKE_STD_ZVAL(iteriter);
-
- if (SUCCESS != object_init_ex(iteriter, spl_ce_RecursiveIteratorIterator)) {
+ if (SUCCESS != object_init_ex(&iteriter, spl_ce_RecursiveIteratorIterator)) {
zval_ptr_dtor(&iter);
zval_ptr_dtor(&iteriter);
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Unable to instantiate directory iterator for %s", phar_obj->arc.archive->fname);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to instantiate directory iterator for %s", phar_obj->archive->fname);
RETURN_FALSE;
}
zend_call_method_with_1_params(&iteriter, spl_ce_RecursiveIteratorIterator,
- &spl_ce_RecursiveIteratorIterator->constructor, "__construct", NULL, iter);
+ &spl_ce_RecursiveIteratorIterator->constructor, "__construct", NULL, &iter);
if (EG(exception)) {
zval_ptr_dtor(&iter);
@@ -1803,25 +1781,24 @@ PHP_METHOD(Phar, buildFromDirectory)
if (regex_len > 0) {
apply_reg = 1;
- MAKE_STD_ZVAL(regexiter);
- if (SUCCESS != object_init_ex(regexiter, spl_ce_RegexIterator)) {
+ if (SUCCESS != object_init_ex(&regexiter, spl_ce_RegexIterator)) {
zval_ptr_dtor(&iteriter);
- zval_dtor(regexiter);
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Unable to instantiate regex iterator for %s", phar_obj->arc.archive->fname);
+ zval_dtor(&regexiter);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to instantiate regex iterator for %s", phar_obj->archive->fname);
RETURN_FALSE;
}
- INIT_PZVAL(&arg2);
- ZVAL_STRINGL(&arg2, regex, regex_len, 0);
+ ZVAL_STRINGL(&arg2, regex, regex_len);
zend_call_method_with_2_params(&regexiter, spl_ce_RegexIterator,
- &spl_ce_RegexIterator->constructor, "__construct", NULL, iteriter, &arg2);
+ &spl_ce_RegexIterator->constructor, "__construct", NULL, &iteriter, &arg2);
+ zval_ptr_dtor(&arg2);
}
array_init(return_value);
- pass.c = apply_reg ? Z_OBJCE_P(regexiter) : Z_OBJCE_P(iteriter);
+ pass.c = apply_reg ? Z_OBJCE(regexiter) : Z_OBJCE(iteriter);
pass.p = phar_obj;
pass.b = dir;
pass.l = dir_len;
@@ -1829,32 +1806,32 @@ PHP_METHOD(Phar, buildFromDirectory)
pass.ret = return_value;
pass.fp = php_stream_fopen_tmpfile();
if (pass.fp == NULL) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" unable to create temporary file", phar_obj->arc.archive->fname);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" unable to create temporary file", phar_obj->archive->fname);
return;
}
- if (phar_obj->arc.archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
+ if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) {
zval_ptr_dtor(&iteriter);
if (apply_reg) {
zval_ptr_dtor(&regexiter);
}
php_stream_close(pass.fp);
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname);
return;
}
- if (SUCCESS == spl_iterator_apply((apply_reg ? regexiter : iteriter), (spl_iterator_apply_func_t) phar_build, (void *) &pass TSRMLS_CC)) {
+ if (SUCCESS == spl_iterator_apply((apply_reg ? &regexiter : &iteriter), (spl_iterator_apply_func_t) phar_build, (void *) &pass)) {
zval_ptr_dtor(&iteriter);
if (apply_reg) {
zval_ptr_dtor(&regexiter);
}
- phar_obj->arc.archive->ufp = pass.fp;
- phar_flush(phar_obj->arc.archive, 0, 0, 0, &error TSRMLS_CC);
+ phar_obj->archive->ufp = pass.fp;
+ phar_flush(phar_obj->archive, 0, 0, 0, &error);
if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
@@ -1882,24 +1859,24 @@ PHP_METHOD(Phar, buildFromIterator)
{
zval *obj;
char *error;
- uint base_len = 0;
+ size_t base_len = 0;
char *base = NULL;
struct _phar_t pass;
PHAR_ARCHIVE_OBJECT();
- if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot write out phar archive, phar is read-only");
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|s", &obj, zend_ce_traversable, &base, &base_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|s", &obj, zend_ce_traversable, &base, &base_len) == FAILURE) {
RETURN_FALSE;
}
- if (phar_obj->arc.archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) {
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname);
return;
}
@@ -1913,15 +1890,15 @@ PHP_METHOD(Phar, buildFromIterator)
pass.count = 0;
pass.fp = php_stream_fopen_tmpfile();
if (pass.fp == NULL) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\": unable to create temporary file", phar_obj->arc.archive->fname);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\": unable to create temporary file", phar_obj->archive->fname);
return;
}
- if (SUCCESS == spl_iterator_apply(obj, (spl_iterator_apply_func_t) phar_build, (void *) &pass TSRMLS_CC)) {
- phar_obj->arc.archive->ufp = pass.fp;
- phar_flush(phar_obj->arc.archive, 0, 0, 0, &error TSRMLS_CC);
+ if (SUCCESS == spl_iterator_apply(obj, (spl_iterator_apply_func_t) phar_build, (void *) &pass)) {
+ phar_obj->archive->ufp = pass.fp;
+ phar_flush(phar_obj->archive, 0, 0, 0, &error);
if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
} else {
@@ -1936,14 +1913,14 @@ PHP_METHOD(Phar, buildFromIterator)
PHP_METHOD(Phar, count)
{
/* mode can be ignored, maximum depth is 1 */
- long mode;
+ zend_long mode;
PHAR_ARCHIVE_OBJECT();
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &mode) == FAILURE) {
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &mode) == FAILURE) {
RETURN_FALSE;
}
- RETURN_LONG(zend_hash_num_elements(&phar_obj->arc.archive->manifest));
+ RETURN_LONG(zend_hash_num_elements(&phar_obj->archive->manifest));
}
/* }}} */
@@ -1953,55 +1930,55 @@ PHP_METHOD(Phar, count)
*/
PHP_METHOD(Phar, isFileFormat)
{
- long type;
+ zend_long type;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &type) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &type) == FAILURE) {
RETURN_FALSE;
}
switch (type) {
case PHAR_FORMAT_TAR:
- RETURN_BOOL(phar_obj->arc.archive->is_tar);
+ RETURN_BOOL(phar_obj->archive->is_tar);
case PHAR_FORMAT_ZIP:
- RETURN_BOOL(phar_obj->arc.archive->is_zip);
+ RETURN_BOOL(phar_obj->archive->is_zip);
case PHAR_FORMAT_PHAR:
- RETURN_BOOL(!phar_obj->arc.archive->is_tar && !phar_obj->arc.archive->is_zip);
+ RETURN_BOOL(!phar_obj->archive->is_tar && !phar_obj->archive->is_zip);
default:
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Unknown file format specified");
+ zend_throw_exception_ex(phar_ce_PharException, 0, "Unknown file format specified");
}
}
/* }}} */
-static int phar_copy_file_contents(phar_entry_info *entry, php_stream *fp TSRMLS_DC) /* {{{ */
+static int phar_copy_file_contents(phar_entry_info *entry, php_stream *fp) /* {{{ */
{
char *error;
- off_t offset;
+ zend_off_t offset;
phar_entry_info *link;
- if (FAILURE == phar_open_entry_fp(entry, &error, 1 TSRMLS_CC)) {
+ if (FAILURE == phar_open_entry_fp(entry, &error, 1)) {
if (error) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot convert phar archive \"%s\", unable to open entry \"%s\" contents: %s", entry->phar->fname, entry->filename, error);
efree(error);
} else {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot convert phar archive \"%s\", unable to open entry \"%s\" contents", entry->phar->fname, entry->filename);
}
return FAILURE;
}
/* copy old contents in entirety */
- phar_seek_efp(entry, 0, SEEK_SET, 0, 1 TSRMLS_CC);
+ phar_seek_efp(entry, 0, SEEK_SET, 0, 1);
offset = php_stream_tell(fp);
- link = phar_get_link_source(entry TSRMLS_CC);
+ link = phar_get_link_source(entry);
if (!link) {
link = entry;
}
- if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(link, 0 TSRMLS_CC), fp, link->uncompressed_filesize, NULL)) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(link, 0), fp, link->uncompressed_filesize, NULL)) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot convert phar archive \"%s\", unable to copy entry \"%s\" contents", entry->phar->fname, entry->filename);
return FAILURE;
}
@@ -2019,20 +1996,20 @@ static int phar_copy_file_contents(phar_entry_info *entry, php_stream *fp TSRMLS
}
/* }}} */
-static zval *phar_rename_archive(phar_archive_data **sphar, char *ext, zend_bool compress TSRMLS_DC) /* {{{ */
+static zend_object *phar_rename_archive(phar_archive_data **sphar, char *ext, zend_bool compress) /* {{{ */
{
const char *oldname = NULL;
phar_archive_data *phar = *sphar;
char *oldpath = NULL;
char *basename = NULL, *basepath = NULL;
char *newname = NULL, *newpath = NULL;
- zval *ret, arg1;
+ zval ret, arg1;
zend_class_entry *ce;
char *error;
const char *pcr_error;
int ext_len = ext ? strlen(ext) : 0;
int oldname_len;
- phar_archive_data **pphar = NULL;
+ phar_archive_data *pphar = NULL;
php_stream_statbuf ssb;
if (!ext) {
@@ -2084,9 +2061,9 @@ static zval *phar_rename_archive(phar_archive_data **sphar, char *ext, zend_bool
} else if (phar_path_check(&ext, &ext_len, &pcr_error) > pcr_is_ok) {
if (phar->is_data) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "data phar converted from \"%s\" has invalid extension %s", phar->fname, ext);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "data phar converted from \"%s\" has invalid extension %s", phar->fname, ext);
} else {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "phar converted from \"%s\" has invalid extension %s", phar->fname, ext);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "phar converted from \"%s\" has invalid extension %s", phar->fname, ext);
}
return NULL;
}
@@ -2096,8 +2073,11 @@ static zval *phar_rename_archive(phar_archive_data **sphar, char *ext, zend_bool
}
oldpath = estrndup(phar->fname, phar->fname_len);
- oldname = zend_memrchr(phar->fname, '/', phar->fname_len);
- ++oldname;
+ if ((oldname = zend_memrchr(phar->fname, '/', phar->fname_len))) {
+ ++oldname;
+ } else {
+ oldname = phar->fname;
+ }
oldname_len = strlen(oldname);
basename = estrndup(oldname, oldname_len);
@@ -2113,25 +2093,24 @@ static zval *phar_rename_archive(phar_archive_data **sphar, char *ext, zend_bool
efree(basepath);
efree(newname);
- if (PHAR_G(manifest_cached) && SUCCESS == zend_hash_find(&cached_phars, newpath, phar->fname_len, (void **) &pphar)) {
+ if (PHAR_G(manifest_cached) && NULL != (pphar = zend_hash_str_find_ptr(&cached_phars, newpath, phar->fname_len))) {
efree(oldpath);
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Unable to add newly converted phar \"%s\" to the list of phars, new phar name is in phar.cache_list", phar->fname);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to add newly converted phar \"%s\" to the list of phars, new phar name is in phar.cache_list", phar->fname);
return NULL;
}
- if (SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), newpath, phar->fname_len, (void **) &pphar)) {
- if ((*pphar)->fname_len == phar->fname_len && !memcmp((*pphar)->fname, phar->fname, phar->fname_len)) {
+ if (NULL != (pphar = zend_hash_str_find_ptr(&(PHAR_G(phar_fname_map)), newpath, phar->fname_len))) {
+ if (pphar->fname_len == phar->fname_len && !memcmp(pphar->fname, phar->fname, phar->fname_len)) {
if (!zend_hash_num_elements(&phar->manifest)) {
- (*pphar)->is_tar = phar->is_tar;
- (*pphar)->is_zip = phar->is_zip;
- (*pphar)->is_data = phar->is_data;
- (*pphar)->flags = phar->flags;
- (*pphar)->fp = phar->fp;
+ pphar->is_tar = phar->is_tar;
+ pphar->is_zip = phar->is_zip;
+ pphar->is_data = phar->is_data;
+ pphar->flags = phar->flags;
+ pphar->fp = phar->fp;
phar->fp = NULL;
- phar_destroy_phar_data(phar TSRMLS_CC);
- *sphar = NULL;
- phar = *pphar;
+ phar_destroy_phar_data(phar);
*sphar = NULL;
+ phar = pphar;
phar->refcount++;
newpath = oldpath;
goto its_ok;
@@ -2139,19 +2118,19 @@ static zval *phar_rename_archive(phar_archive_data **sphar, char *ext, zend_bool
}
efree(oldpath);
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Unable to add newly converted phar \"%s\" to the list of phars, a phar with that name already exists", phar->fname);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to add newly converted phar \"%s\" to the list of phars, a phar with that name already exists", phar->fname);
return NULL;
}
its_ok:
if (SUCCESS == php_stream_stat_path(newpath, &ssb)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "phar \"%s\" exists and must be unlinked prior to conversion", newpath);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "phar \"%s\" exists and must be unlinked prior to conversion", newpath);
efree(oldpath);
return NULL;
}
if (!phar->is_data) {
- if (SUCCESS != phar_detect_phar_fname_ext(newpath, phar->fname_len, (const char **) &(phar->ext), &(phar->ext_len), 1, 1, 1 TSRMLS_CC)) {
+ if (SUCCESS != phar_detect_phar_fname_ext(newpath, phar->fname_len, (const char **) &(phar->ext), &(phar->ext_len), 1, 1, 1)) {
efree(oldpath);
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "phar \"%s\" has invalid extension %s", phar->fname, ext);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "phar \"%s\" has invalid extension %s", phar->fname, ext);
return NULL;
}
@@ -2163,15 +2142,15 @@ its_ok:
phar->alias = estrndup(newpath, strlen(newpath));
phar->alias_len = strlen(newpath);
phar->is_temporary_alias = 1;
- zend_hash_update(&(PHAR_GLOBALS->phar_alias_map), newpath, phar->fname_len, (void*)&phar, sizeof(phar_archive_data*), NULL);
+ zend_hash_str_update_ptr(&(PHAR_G(phar_alias_map)), newpath, phar->fname_len, phar);
}
}
} else {
- if (SUCCESS != phar_detect_phar_fname_ext(newpath, phar->fname_len, (const char **) &(phar->ext), &(phar->ext_len), 0, 1, 1 TSRMLS_CC)) {
+ if (SUCCESS != phar_detect_phar_fname_ext(newpath, phar->fname_len, (const char **) &(phar->ext), &(phar->ext_len), 0, 1, 1)) {
efree(oldpath);
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "data phar \"%s\" has invalid extension %s", phar->fname, ext);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "data phar \"%s\" has invalid extension %s", phar->fname, ext);
return NULL;
}
@@ -2179,16 +2158,16 @@ its_ok:
phar->alias_len = 0;
}
- if ((!pphar || phar == *pphar) && SUCCESS != zend_hash_update(&(PHAR_GLOBALS->phar_fname_map), newpath, phar->fname_len, (void*)&phar, sizeof(phar_archive_data*), NULL)) {
+ if ((!pphar || phar == pphar) && NULL == zend_hash_str_update_ptr(&(PHAR_G(phar_fname_map)), newpath, phar->fname_len, phar)) {
efree(oldpath);
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Unable to add newly converted phar \"%s\" to the list of phars", phar->fname);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to add newly converted phar \"%s\" to the list of phars", phar->fname);
return NULL;
}
- phar_flush(phar, 0, 0, 1, &error TSRMLS_CC);
+ phar_flush(phar, 0, 0, 1, &error);
if (error) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s", error);
efree(error);
efree(oldpath);
return NULL;
@@ -2202,27 +2181,26 @@ its_ok:
ce = phar_ce_archive;
}
- MAKE_STD_ZVAL(ret);
-
- if (SUCCESS != object_init_ex(ret, ce)) {
- zval_dtor(ret);
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Unable to instantiate phar object when converting archive \"%s\"", phar->fname);
+ ZVAL_NULL(&ret);
+ if (SUCCESS != object_init_ex(&ret, ce)) {
+ zval_dtor(&ret);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to instantiate phar object when converting archive \"%s\"", phar->fname);
return NULL;
}
- INIT_PZVAL(&arg1);
- ZVAL_STRINGL(&arg1, phar->fname, phar->fname_len, 0);
+ ZVAL_STRINGL(&arg1, phar->fname, phar->fname_len);
zend_call_method_with_1_params(&ret, ce, &ce->constructor, "__construct", NULL, &arg1);
- return ret;
+ zval_ptr_dtor(&arg1);
+ return Z_OBJ(ret);
}
/* }}} */
-static zval *phar_convert_to_other(phar_archive_data *source, int convert, char *ext, php_uint32 flags TSRMLS_DC) /* {{{ */
+static zend_object *phar_convert_to_other(phar_archive_data *source, int convert, char *ext, php_uint32 flags) /* {{{ */
{
phar_archive_data *phar;
phar_entry_info *entry, newentry;
- zval *ret;
+ zend_object *ret;
/* invalidate phar cache */
PHAR_G(last_phar) = NULL;
@@ -2254,7 +2232,7 @@ static zval *phar_convert_to_other(phar_archive_data *source, int convert, char
phar->fp = php_stream_fopen_tmpfile();
if (phar->fp == NULL) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "unable to create temporary file");
+ zend_throw_exception_ex(phar_ce_PharException, 0, "unable to create temporary file");
return NULL;
}
phar->fname = source->fname;
@@ -2262,29 +2240,13 @@ static zval *phar_convert_to_other(phar_archive_data *source, int convert, char
phar->is_temporary_alias = source->is_temporary_alias;
phar->alias = source->alias;
- if (source->metadata) {
- zval *t;
-
- t = source->metadata;
- ALLOC_ZVAL(phar->metadata);
- *phar->metadata = *t;
- zval_copy_ctor(phar->metadata);
- Z_SET_REFCOUNT_P(phar->metadata, 1);
-
+ if (Z_TYPE(source->metadata) != IS_UNDEF) {
+ ZVAL_DUP(&phar->metadata, &source->metadata);
phar->metadata_len = 0;
}
/* first copy each file's uncompressed contents to a temporary file and set per-file flags */
- for (zend_hash_internal_pointer_reset(&source->manifest); SUCCESS == zend_hash_has_more_elements(&source->manifest); zend_hash_move_forward(&source->manifest)) {
-
- if (FAILURE == zend_hash_get_current_data(&source->manifest, (void **) &entry)) {
- zend_hash_destroy(&(phar->manifest));
- php_stream_close(phar->fp);
- efree(phar);
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
- "Cannot convert phar archive \"%s\"", source->fname);
- return NULL;
- }
+ ZEND_HASH_FOREACH_PTR(&source->manifest, entry) {
newentry = *entry;
@@ -2298,9 +2260,9 @@ static zval *phar_convert_to_other(phar_archive_data *source, int convert, char
goto no_copy;
}
- newentry.metadata_str.c = 0;
+ newentry.metadata_str.s = NULL;
- if (FAILURE == phar_copy_file_contents(&newentry, phar->fp TSRMLS_CC)) {
+ if (FAILURE == phar_copy_file_contents(&newentry, phar->fp)) {
zend_hash_destroy(&(phar->manifest));
php_stream_close(phar->fp);
efree(phar);
@@ -2310,17 +2272,9 @@ static zval *phar_convert_to_other(phar_archive_data *source, int convert, char
no_copy:
newentry.filename = estrndup(newentry.filename, newentry.filename_len);
- if (newentry.metadata) {
- zval *t;
-
- t = newentry.metadata;
- ALLOC_ZVAL(newentry.metadata);
- *newentry.metadata = *t;
- zval_copy_ctor(newentry.metadata);
- Z_SET_REFCOUNT_P(newentry.metadata, 1);
-
- newentry.metadata_str.c = NULL;
- newentry.metadata_str.len = 0;
+ if (Z_TYPE(newentry.metadata) != IS_UNDEF) {
+ zval_copy_ctor(&newentry.metadata);
+ newentry.metadata_str.s = NULL;
}
newentry.is_zip = phar->is_zip;
@@ -2333,12 +2287,12 @@ no_copy:
newentry.is_modified = 1;
newentry.phar = phar;
newentry.old_flags = newentry.flags & ~PHAR_ENT_COMPRESSION_MASK; /* remove compression from old_flags */
- phar_set_inode(&newentry TSRMLS_CC);
- zend_hash_add(&(phar->manifest), newentry.filename, newentry.filename_len, (void*)&newentry, sizeof(phar_entry_info), NULL);
- phar_add_virtual_dirs(phar, newentry.filename, newentry.filename_len TSRMLS_CC);
- }
+ phar_set_inode(&newentry);
+ zend_hash_str_add_mem(&(phar->manifest), newentry.filename, newentry.filename_len, (void*)&newentry, sizeof(phar_entry_info));
+ phar_add_virtual_dirs(phar, newentry.filename, newentry.filename_len);
+ } ZEND_HASH_FOREACH_END();
- if ((ret = phar_rename_archive(&phar, ext, 0 TSRMLS_CC))) {
+ if ((ret = phar_rename_archive(&phar, ext, 0))) {
return ret;
} else {
if(phar != NULL) {
@@ -2364,19 +2318,20 @@ no_copy:
PHP_METHOD(Phar, convertToExecutable)
{
char *ext = NULL;
- int is_data, ext_len = 0;
+ int is_data;
+ size_t ext_len = 0;
php_uint32 flags;
- zval *ret;
+ zend_object *ret;
/* a number that is not 0, 1 or 2 (Which is also Greg's birthday, so there) */
- long format = 9021976, method = 9021976;
+ zend_long format = 9021976, method = 9021976;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lls", &format, &method, &ext, &ext_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|lls", &format, &method, &ext, &ext_len) == FAILURE) {
return;
}
if (PHAR_G(readonly)) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot write out executable phar archive, phar is read-only");
return;
}
@@ -2385,9 +2340,9 @@ PHP_METHOD(Phar, convertToExecutable)
case 9021976:
case PHAR_FORMAT_SAME: /* null is converted to 0 */
/* by default, use the existing format */
- if (phar_obj->arc.archive->is_tar) {
+ if (phar_obj->archive->is_tar) {
format = PHAR_FORMAT_TAR;
- } else if (phar_obj->arc.archive->is_zip) {
+ } else if (phar_obj->archive->is_zip) {
format = PHAR_FORMAT_ZIP;
} else {
format = PHAR_FORMAT_PHAR;
@@ -2398,27 +2353,27 @@ PHP_METHOD(Phar, convertToExecutable)
case PHAR_FORMAT_ZIP:
break;
default:
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Unknown file format specified, please pass one of Phar::PHAR, Phar::TAR or Phar::ZIP");
return;
}
switch (method) {
case 9021976:
- flags = phar_obj->arc.archive->flags & PHAR_FILE_COMPRESSION_MASK;
+ flags = phar_obj->archive->flags & PHAR_FILE_COMPRESSION_MASK;
break;
case 0:
flags = PHAR_FILE_COMPRESSED_NONE;
break;
case PHAR_ENT_COMPRESSED_GZ:
if (format == PHAR_FORMAT_ZIP) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress entire archive with gzip, zip archives do not support whole-archive compression");
return;
}
if (!PHAR_G(has_zlib)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress entire archive with gzip, enable ext/zlib in php.ini");
return;
}
@@ -2427,13 +2382,13 @@ PHP_METHOD(Phar, convertToExecutable)
break;
case PHAR_ENT_COMPRESSED_BZ2:
if (format == PHAR_FORMAT_ZIP) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress entire archive with bz2, zip archives do not support whole-archive compression");
return;
}
if (!PHAR_G(has_bz2)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress entire archive with bz2, enable ext/bz2 in php.ini");
return;
}
@@ -2441,18 +2396,18 @@ PHP_METHOD(Phar, convertToExecutable)
flags = PHAR_FILE_COMPRESSED_BZ2;
break;
default:
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2");
return;
}
- is_data = phar_obj->arc.archive->is_data;
- phar_obj->arc.archive->is_data = 0;
- ret = phar_convert_to_other(phar_obj->arc.archive, format, ext, flags TSRMLS_CC);
- phar_obj->arc.archive->is_data = is_data;
+ is_data = phar_obj->archive->is_data;
+ phar_obj->archive->is_data = 0;
+ ret = phar_convert_to_other(phar_obj->archive, format, ext, flags);
+ phar_obj->archive->is_data = is_data;
if (ret) {
- RETURN_ZVAL(ret, 1, 1);
+ ZVAL_OBJ(return_value, ret);
} else {
RETURN_NULL();
}
@@ -2467,14 +2422,15 @@ PHP_METHOD(Phar, convertToExecutable)
PHP_METHOD(Phar, convertToData)
{
char *ext = NULL;
- int is_data, ext_len = 0;
+ int is_data;
+ size_t ext_len = 0;
php_uint32 flags;
- zval *ret;
+ zend_object *ret;
/* a number that is not 0, 1 or 2 (Which is also Greg's birthday so there) */
- long format = 9021976, method = 9021976;
+ zend_long format = 9021976, method = 9021976;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lls", &format, &method, &ext, &ext_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|lls", &format, &method, &ext, &ext_len) == FAILURE) {
return;
}
@@ -2482,45 +2438,45 @@ PHP_METHOD(Phar, convertToData)
case 9021976:
case PHAR_FORMAT_SAME: /* null is converted to 0 */
/* by default, use the existing format */
- if (phar_obj->arc.archive->is_tar) {
+ if (phar_obj->archive->is_tar) {
format = PHAR_FORMAT_TAR;
- } else if (phar_obj->arc.archive->is_zip) {
+ } else if (phar_obj->archive->is_zip) {
format = PHAR_FORMAT_ZIP;
} else {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot write out data phar archive, use Phar::TAR or Phar::ZIP");
return;
}
break;
case PHAR_FORMAT_PHAR:
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot write out data phar archive, use Phar::TAR or Phar::ZIP");
return;
case PHAR_FORMAT_TAR:
case PHAR_FORMAT_ZIP:
break;
default:
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Unknown file format specified, please pass one of Phar::TAR or Phar::ZIP");
return;
}
switch (method) {
case 9021976:
- flags = phar_obj->arc.archive->flags & PHAR_FILE_COMPRESSION_MASK;
+ flags = phar_obj->archive->flags & PHAR_FILE_COMPRESSION_MASK;
break;
case 0:
flags = PHAR_FILE_COMPRESSED_NONE;
break;
case PHAR_ENT_COMPRESSED_GZ:
if (format == PHAR_FORMAT_ZIP) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress entire archive with gzip, zip archives do not support whole-archive compression");
return;
}
if (!PHAR_G(has_zlib)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress entire archive with gzip, enable ext/zlib in php.ini");
return;
}
@@ -2529,13 +2485,13 @@ PHP_METHOD(Phar, convertToData)
break;
case PHAR_ENT_COMPRESSED_BZ2:
if (format == PHAR_FORMAT_ZIP) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress entire archive with bz2, zip archives do not support whole-archive compression");
return;
}
if (!PHAR_G(has_bz2)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress entire archive with bz2, enable ext/bz2 in php.ini");
return;
}
@@ -2543,18 +2499,18 @@ PHP_METHOD(Phar, convertToData)
flags = PHAR_FILE_COMPRESSED_BZ2;
break;
default:
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2");
return;
}
- is_data = phar_obj->arc.archive->is_data;
- phar_obj->arc.archive->is_data = 1;
- ret = phar_convert_to_other(phar_obj->arc.archive, format, ext, flags TSRMLS_CC);
- phar_obj->arc.archive->is_data = is_data;
+ is_data = phar_obj->archive->is_data;
+ phar_obj->archive->is_data = 1;
+ ret = phar_convert_to_other(phar_obj->archive, format, ext, flags);
+ phar_obj->archive->is_data = is_data;
if (ret) {
- RETURN_ZVAL(ret, 1, 1);
+ ZVAL_OBJ(return_value, ret);
} else {
RETURN_NULL();
}
@@ -2573,11 +2529,11 @@ PHP_METHOD(Phar, isCompressed)
return;
}
- if (phar_obj->arc.archive->flags & PHAR_FILE_COMPRESSED_GZ) {
+ if (phar_obj->archive->flags & PHAR_FILE_COMPRESSED_GZ) {
RETURN_LONG(PHAR_ENT_COMPRESSED_GZ);
}
- if (phar_obj->arc.archive->flags & PHAR_FILE_COMPRESSED_BZ2) {
+ if (phar_obj->archive->flags & PHAR_FILE_COMPRESSED_BZ2) {
RETURN_LONG(PHAR_ENT_COMPRESSED_BZ2);
}
@@ -2597,12 +2553,12 @@ PHP_METHOD(Phar, isWritable)
return;
}
- if (!phar_obj->arc.archive->is_writeable) {
+ if (!phar_obj->archive->is_writeable) {
RETURN_FALSE;
}
- if (SUCCESS != php_stream_stat_path(phar_obj->arc.archive->fname, &ssb)) {
- if (phar_obj->arc.archive->is_brandnew) {
+ if (SUCCESS != php_stream_stat_path(phar_obj->archive->fname, &ssb)) {
+ if (phar_obj->archive->is_brandnew) {
/* assume it works if the file doesn't exist yet */
RETURN_TRUE;
}
@@ -2619,44 +2575,44 @@ PHP_METHOD(Phar, isWritable)
PHP_METHOD(Phar, delete)
{
char *fname;
- int fname_len;
+ size_t fname_len;
char *error;
phar_entry_info *entry;
PHAR_ARCHIVE_OBJECT();
- if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot write out phar archive, phar is read-only");
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
- if (phar_obj->arc.archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) {
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname);
return;
}
- if (zend_hash_exists(&phar_obj->arc.archive->manifest, fname, (uint) fname_len)) {
- if (SUCCESS == zend_hash_find(&phar_obj->arc.archive->manifest, fname, (uint) fname_len, (void**)&entry)) {
+ if (zend_hash_str_exists(&phar_obj->archive->manifest, fname, (uint) fname_len)) {
+ if (NULL != (entry = zend_hash_str_find_ptr(&phar_obj->archive->manifest, fname, (uint) fname_len))) {
if (entry->is_deleted) {
/* entry is deleted, but has not been flushed to disk yet */
RETURN_TRUE;
} else {
entry->is_deleted = 1;
entry->is_modified = 1;
- phar_obj->arc.archive->is_modified = 1;
+ phar_obj->archive->is_modified = 1;
}
}
} else {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s does not exist and cannot be deleted", fname);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %s does not exist and cannot be deleted", fname);
RETURN_FALSE;
}
- phar_flush(phar_obj->arc.archive, NULL, 0, 0, &error TSRMLS_CC);
+ phar_flush(phar_obj->archive, NULL, 0, 0, &error);
if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
@@ -2675,8 +2631,8 @@ PHP_METHOD(Phar, getAlias)
return;
}
- if (phar_obj->arc.archive->alias && phar_obj->arc.archive->alias != phar_obj->arc.archive->fname) {
- RETURN_STRINGL(phar_obj->arc.archive->alias, phar_obj->arc.archive->alias_len, 1);
+ if (phar_obj->archive->alias && phar_obj->archive->alias != phar_obj->archive->fname) {
+ RETURN_STRINGL(phar_obj->archive->alias, phar_obj->archive->alias_len);
}
}
/* }}} */
@@ -2692,7 +2648,7 @@ PHP_METHOD(Phar, getPath)
return;
}
- RETURN_STRINGL(phar_obj->arc.archive->fname, phar_obj->arc.archive->fname_len, 1);
+ RETURN_STRINGL(phar_obj->archive->fname, phar_obj->archive->fname_len);
}
/* }}} */
@@ -2703,13 +2659,14 @@ PHP_METHOD(Phar, getPath)
PHP_METHOD(Phar, setAlias)
{
char *alias, *error, *oldalias;
- phar_archive_data **fd_ptr;
- int alias_len, oldalias_len, old_temp, readd = 0;
+ phar_archive_data *fd_ptr;
+ size_t alias_len, oldalias_len;
+ int old_temp, readd = 0;
PHAR_ARCHIVE_OBJECT();
- if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot write out phar archive, phar is read-only");
RETURN_FALSE;
}
@@ -2718,73 +2675,73 @@ PHP_METHOD(Phar, setAlias)
PHAR_G(last_phar) = NULL;
PHAR_G(last_phar_name) = PHAR_G(last_alias) = NULL;
- if (phar_obj->arc.archive->is_data) {
- if (phar_obj->arc.archive->is_tar) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ if (phar_obj->archive->is_data) {
+ if (phar_obj->archive->is_tar) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"A Phar alias cannot be set in a plain tar archive");
} else {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"A Phar alias cannot be set in a plain zip archive");
}
RETURN_FALSE;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &alias, &alias_len) == SUCCESS) {
- if (alias_len == phar_obj->arc.archive->alias_len && memcmp(phar_obj->arc.archive->alias, alias, alias_len) == 0) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &alias, &alias_len) == SUCCESS) {
+ if (alias_len == phar_obj->archive->alias_len && memcmp(phar_obj->archive->alias, alias, alias_len) == 0) {
RETURN_TRUE;
}
- if (alias_len && SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void**)&fd_ptr)) {
- spprintf(&error, 0, "alias \"%s\" is already used for archive \"%s\" and cannot be used for other archives", alias, (*fd_ptr)->fname);
- if (SUCCESS == phar_free_alias(*fd_ptr, alias, alias_len TSRMLS_CC)) {
+ if (alias_len && NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len))) {
+ spprintf(&error, 0, "alias \"%s\" is already used for archive \"%s\" and cannot be used for other archives", alias, fd_ptr->fname);
+ if (SUCCESS == phar_free_alias(fd_ptr, alias, alias_len)) {
efree(error);
goto valid_alias;
}
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
RETURN_FALSE;
}
if (!phar_validate_alias(alias, alias_len)) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
- "Invalid alias \"%s\" specified for phar \"%s\"", alias, phar_obj->arc.archive->fname);
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
+ "Invalid alias \"%s\" specified for phar \"%s\"", alias, phar_obj->archive->fname);
RETURN_FALSE;
}
valid_alias:
- if (phar_obj->arc.archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) {
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname);
return;
}
- if (phar_obj->arc.archive->alias_len && SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), phar_obj->arc.archive->alias, phar_obj->arc.archive->alias_len, (void**)&fd_ptr)) {
- zend_hash_del(&(PHAR_GLOBALS->phar_alias_map), phar_obj->arc.archive->alias, phar_obj->arc.archive->alias_len);
+ if (phar_obj->archive->alias_len && NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), phar_obj->archive->alias, phar_obj->archive->alias_len))) {
+ zend_hash_str_del(&(PHAR_G(phar_alias_map)), phar_obj->archive->alias, phar_obj->archive->alias_len);
readd = 1;
}
- oldalias = phar_obj->arc.archive->alias;
- oldalias_len = phar_obj->arc.archive->alias_len;
- old_temp = phar_obj->arc.archive->is_temporary_alias;
+ oldalias = phar_obj->archive->alias;
+ oldalias_len = phar_obj->archive->alias_len;
+ old_temp = phar_obj->archive->is_temporary_alias;
if (alias_len) {
- phar_obj->arc.archive->alias = estrndup(alias, alias_len);
+ phar_obj->archive->alias = estrndup(alias, alias_len);
} else {
- phar_obj->arc.archive->alias = NULL;
+ phar_obj->archive->alias = NULL;
}
- phar_obj->arc.archive->alias_len = alias_len;
- phar_obj->arc.archive->is_temporary_alias = 0;
- phar_flush(phar_obj->arc.archive, NULL, 0, 0, &error TSRMLS_CC);
+ phar_obj->archive->alias_len = alias_len;
+ phar_obj->archive->is_temporary_alias = 0;
+ phar_flush(phar_obj->archive, NULL, 0, 0, &error);
if (error) {
- phar_obj->arc.archive->alias = oldalias;
- phar_obj->arc.archive->alias_len = oldalias_len;
- phar_obj->arc.archive->is_temporary_alias = old_temp;
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ phar_obj->archive->alias = oldalias;
+ phar_obj->archive->alias_len = oldalias_len;
+ phar_obj->archive->is_temporary_alias = old_temp;
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
if (readd) {
- zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), oldalias, oldalias_len, (void*)&(phar_obj->arc.archive), sizeof(phar_archive_data*), NULL);
+ zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), oldalias, oldalias_len, phar_obj->archive);
}
efree(error);
RETURN_FALSE;
}
- zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void*)&(phar_obj->arc.archive), sizeof(phar_archive_data*), NULL);
+ zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len, phar_obj->archive);
if (oldalias) {
efree(oldalias);
@@ -2808,7 +2765,7 @@ PHP_METHOD(Phar, getVersion)
return;
}
- RETURN_STRING(phar_obj->arc.archive->version, 1);
+ RETURN_STRING(phar_obj->archive->version);
}
/* }}} */
@@ -2823,7 +2780,7 @@ PHP_METHOD(Phar, startBuffering)
return;
}
- phar_obj->arc.archive->donotflush = 1;
+ phar_obj->archive->donotflush = 1;
}
/* }}} */
@@ -2838,7 +2795,7 @@ PHP_METHOD(Phar, isBuffering)
return;
}
- RETURN_BOOL(phar_obj->arc.archive->donotflush);
+ RETURN_BOOL(phar_obj->archive->donotflush);
}
/* }}} */
@@ -2855,17 +2812,17 @@ PHP_METHOD(Phar, stopBuffering)
return;
}
- if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot write out phar archive, phar is read-only");
return;
}
- phar_obj->arc.archive->donotflush = 0;
- phar_flush(phar_obj->arc.archive, 0, 0, 0, &error TSRMLS_CC);
+ phar_obj->archive->donotflush = 0;
+ phar_flush(phar_obj->archive, 0, 0, 0, &error);
if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
}
@@ -2879,58 +2836,58 @@ PHP_METHOD(Phar, setStub)
{
zval *zstub;
char *stub, *error;
- int stub_len;
- long len = -1;
+ size_t stub_len;
+ zend_long len = -1;
php_stream *stream;
PHAR_ARCHIVE_OBJECT();
- if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot change stub, phar is read-only");
return;
}
- if (phar_obj->arc.archive->is_data) {
- if (phar_obj->arc.archive->is_tar) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ if (phar_obj->archive->is_data) {
+ if (phar_obj->archive->is_tar) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"A Phar stub cannot be set in a plain tar archive");
} else {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"A Phar stub cannot be set in a plain zip archive");
}
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &zstub, &len) == SUCCESS) {
- if ((php_stream_from_zval_no_verify(stream, &zstub)) != NULL) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "r|l", &zstub, &len) == SUCCESS) {
+ if ((php_stream_from_zval_no_verify(stream, zstub)) != NULL) {
if (len > 0) {
len = -len;
} else {
len = -1;
}
- if (phar_obj->arc.archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) {
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname);
return;
}
- phar_flush(phar_obj->arc.archive, (char *) &zstub, len, 0, &error TSRMLS_CC);
+ phar_flush(phar_obj->archive, (char *) zstub, len, 0, &error);
if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
RETURN_TRUE;
} else {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot change stub, unable to read from input stream");
}
- } else if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &stub, &stub_len) == SUCCESS) {
- if (phar_obj->arc.archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ } else if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &stub, &stub_len) == SUCCESS) {
+ if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) {
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname);
return;
}
- phar_flush(phar_obj->arc.archive, stub, stub_len, 0, &error TSRMLS_CC);
+ phar_flush(phar_obj->archive, stub, stub_len, 0, &error);
if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
@@ -2956,45 +2913,46 @@ PHP_METHOD(Phar, setStub)
*/
PHP_METHOD(Phar, setDefaultStub)
{
- char *index = NULL, *webindex = NULL, *error = NULL, *stub = NULL;
- int index_len = 0, webindex_len = 0, created_stub = 0;
- size_t stub_len = 0;
+ char *index = NULL, *webindex = NULL, *error = NULL;
+ zend_string *stub = NULL;
+ size_t index_len = 0, webindex_len = 0;
+ int created_stub = 0;
PHAR_ARCHIVE_OBJECT();
- if (phar_obj->arc.archive->is_data) {
- if (phar_obj->arc.archive->is_tar) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ if (phar_obj->archive->is_data) {
+ if (phar_obj->archive->is_tar) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"A Phar stub cannot be set in a plain tar archive");
} else {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"A Phar stub cannot be set in a plain zip archive");
}
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
RETURN_FALSE;
}
- if (ZEND_NUM_ARGS() > 0 && (phar_obj->arc.archive->is_tar || phar_obj->arc.archive->is_zip)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "method accepts no arguments for a tar- or zip-based phar stub, %d given", ZEND_NUM_ARGS());
+ if (ZEND_NUM_ARGS() > 0 && (phar_obj->archive->is_tar || phar_obj->archive->is_zip)) {
+ php_error_docref(NULL, E_WARNING, "method accepts no arguments for a tar- or zip-based phar stub, %d given", ZEND_NUM_ARGS());
RETURN_FALSE;
}
if (PHAR_G(readonly)) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot change stub: phar.readonly=1");
RETURN_FALSE;
}
- if (!phar_obj->arc.archive->is_tar && !phar_obj->arc.archive->is_zip) {
- stub = phar_create_default_stub(index, webindex, &stub_len, &error TSRMLS_CC);
+ if (!phar_obj->archive->is_tar && !phar_obj->archive->is_zip) {
+ stub = phar_create_default_stub(index, webindex, &error);
if (error) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "%s", error);
efree(error);
if (stub) {
- efree(stub);
+ zend_string_free(stub);
}
RETURN_FALSE;
}
@@ -3002,18 +2960,18 @@ PHP_METHOD(Phar, setDefaultStub)
created_stub = 1;
}
- if (phar_obj->arc.archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) {
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname);
return;
}
- phar_flush(phar_obj->arc.archive, stub, stub_len, 1, &error TSRMLS_CC);
+ phar_flush(phar_obj->archive, stub ? ZSTR_VAL(stub) : 0, stub ? ZSTR_LEN(stub) : 0, 1, &error);
if (created_stub) {
- efree(stub);
+ zend_string_free(stub);
}
if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
RETURN_FALSE;
}
@@ -3030,19 +2988,19 @@ PHP_METHOD(Phar, setDefaultStub)
*/
PHP_METHOD(Phar, setSignatureAlgorithm)
{
- long algo;
+ zend_long algo;
char *error, *key = NULL;
- int key_len = 0;
+ size_t key_len = 0;
PHAR_ARCHIVE_OBJECT();
- if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot set signature algorithm, phar is read-only");
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "l|s", &algo, &key, &key_len) != SUCCESS) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "l|s", &algo, &key, &key_len) != SUCCESS) {
return;
}
@@ -3050,30 +3008,30 @@ PHP_METHOD(Phar, setSignatureAlgorithm)
case PHAR_SIG_SHA256:
case PHAR_SIG_SHA512:
#ifndef PHAR_HASH_OK
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"SHA-256 and SHA-512 signatures are only supported if the hash extension is enabled and built non-shared");
return;
#endif
case PHAR_SIG_MD5:
case PHAR_SIG_SHA1:
case PHAR_SIG_OPENSSL:
- if (phar_obj->arc.archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) {
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname);
return;
}
- phar_obj->arc.archive->sig_flags = algo;
- phar_obj->arc.archive->is_modified = 1;
+ phar_obj->archive->sig_flags = algo;
+ phar_obj->archive->is_modified = 1;
PHAR_G(openssl_privatekey) = key;
PHAR_G(openssl_privatekey_len) = key_len;
- phar_flush(phar_obj->arc.archive, 0, 0, 0, &error TSRMLS_CC);
+ phar_flush(phar_obj->archive, 0, 0, 0, &error);
if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
break;
default:
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Unknown signature algorithm specified");
}
}
@@ -3090,31 +3048,30 @@ PHP_METHOD(Phar, getSignature)
return;
}
- if (phar_obj->arc.archive->signature) {
- char *unknown;
- int unknown_len;
+ if (phar_obj->archive->signature) {
+ zend_string *unknown;
array_init(return_value);
- add_assoc_stringl(return_value, "hash", phar_obj->arc.archive->signature, phar_obj->arc.archive->sig_len, 1);
- switch(phar_obj->arc.archive->sig_flags) {
+ add_assoc_stringl(return_value, "hash", phar_obj->archive->signature, phar_obj->archive->sig_len);
+ switch(phar_obj->archive->sig_flags) {
case PHAR_SIG_MD5:
- add_assoc_stringl(return_value, "hash_type", "MD5", 3, 1);
+ add_assoc_stringl(return_value, "hash_type", "MD5", 3);
break;
case PHAR_SIG_SHA1:
- add_assoc_stringl(return_value, "hash_type", "SHA-1", 5, 1);
+ add_assoc_stringl(return_value, "hash_type", "SHA-1", 5);
break;
case PHAR_SIG_SHA256:
- add_assoc_stringl(return_value, "hash_type", "SHA-256", 7, 1);
+ add_assoc_stringl(return_value, "hash_type", "SHA-256", 7);
break;
case PHAR_SIG_SHA512:
- add_assoc_stringl(return_value, "hash_type", "SHA-512", 7, 1);
+ add_assoc_stringl(return_value, "hash_type", "SHA-512", 7);
break;
case PHAR_SIG_OPENSSL:
- add_assoc_stringl(return_value, "hash_type", "OpenSSL", 7, 1);
+ add_assoc_stringl(return_value, "hash_type", "OpenSSL", 7);
break;
default:
- unknown_len = spprintf(&unknown, 0, "Unknown (%u)", phar_obj->arc.archive->sig_flags);
- add_assoc_stringl(return_value, "hash_type", unknown, unknown_len, 0);
+ unknown = strpprintf(0, "Unknown (%u)", phar_obj->archive->sig_flags);
+ add_assoc_str(return_value, "hash_type", unknown);
break;
}
} else {
@@ -3134,13 +3091,13 @@ PHP_METHOD(Phar, getModified)
return;
}
- RETURN_BOOL(phar_obj->arc.archive->is_modified);
+ RETURN_BOOL(phar_obj->archive->is_modified);
}
/* }}} */
-static int phar_set_compression(void *pDest, void *argument TSRMLS_DC) /* {{{ */
+static int phar_set_compression(zval *zv, void *argument) /* {{{ */
{
- phar_entry_info *entry = (phar_entry_info *)pDest;
+ phar_entry_info *entry = (phar_entry_info *)Z_PTR_P(zv);
php_uint32 compress = *(php_uint32 *)argument;
if (entry->is_deleted) {
@@ -3155,9 +3112,9 @@ static int phar_set_compression(void *pDest, void *argument TSRMLS_DC) /* {{{ */
}
/* }}} */
-static int phar_test_compression(void *pDest, void *argument TSRMLS_DC) /* {{{ */
+static int phar_test_compression(zval *zv, void *argument) /* {{{ */
{
- phar_entry_info *entry = (phar_entry_info *)pDest;
+ phar_entry_info *entry = (phar_entry_info *)Z_PTR_P(zv);
if (entry->is_deleted) {
return ZEND_HASH_APPLY_KEEP;
@@ -3179,18 +3136,18 @@ static int phar_test_compression(void *pDest, void *argument TSRMLS_DC) /* {{{ *
}
/* }}} */
-static void pharobj_set_compression(HashTable *manifest, php_uint32 compress TSRMLS_DC) /* {{{ */
+static void pharobj_set_compression(HashTable *manifest, php_uint32 compress) /* {{{ */
{
- zend_hash_apply_with_argument(manifest, phar_set_compression, &compress TSRMLS_CC);
+ zend_hash_apply_with_argument(manifest, phar_set_compression, &compress);
}
/* }}} */
-static int pharobj_cancompress(HashTable *manifest TSRMLS_DC) /* {{{ */
+static int pharobj_cancompress(HashTable *manifest) /* {{{ */
{
int test;
test = 1;
- zend_hash_apply_with_argument(manifest, phar_test_compression, &test TSRMLS_CC);
+ zend_hash_apply_with_argument(manifest, phar_test_compression, &test);
return test;
}
/* }}} */
@@ -3202,25 +3159,25 @@ static int pharobj_cancompress(HashTable *manifest TSRMLS_DC) /* {{{ */
*/
PHP_METHOD(Phar, compress)
{
- long method;
+ zend_long method;
char *ext = NULL;
- int ext_len = 0;
+ size_t ext_len = 0;
php_uint32 flags;
- zval *ret;
+ zend_object *ret;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|s", &method, &ext, &ext_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|s", &method, &ext, &ext_len) == FAILURE) {
return;
}
- if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot compress phar archive, phar is read-only");
return;
}
- if (phar_obj->arc.archive->is_zip) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ if (phar_obj->archive->is_zip) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot compress zip-based archives with whole-archive compression");
return;
}
@@ -3231,7 +3188,7 @@ PHP_METHOD(Phar, compress)
break;
case PHAR_ENT_COMPRESSED_GZ:
if (!PHAR_G(has_zlib)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress entire archive with gzip, enable ext/zlib in php.ini");
return;
}
@@ -3240,26 +3197,26 @@ PHP_METHOD(Phar, compress)
case PHAR_ENT_COMPRESSED_BZ2:
if (!PHAR_G(has_bz2)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress entire archive with bz2, enable ext/bz2 in php.ini");
return;
}
flags = PHAR_FILE_COMPRESSED_BZ2;
break;
default:
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2");
return;
}
- if (phar_obj->arc.archive->is_tar) {
- ret = phar_convert_to_other(phar_obj->arc.archive, PHAR_FORMAT_TAR, ext, flags TSRMLS_CC);
+ if (phar_obj->archive->is_tar) {
+ ret = phar_convert_to_other(phar_obj->archive, PHAR_FORMAT_TAR, ext, flags);
} else {
- ret = phar_convert_to_other(phar_obj->arc.archive, PHAR_FORMAT_PHAR, ext, flags TSRMLS_CC);
+ ret = phar_convert_to_other(phar_obj->archive, PHAR_FORMAT_PHAR, ext, flags);
}
if (ret) {
- RETURN_ZVAL(ret, 1, 1);
+ ZVAL_OBJ(return_value, ret);
} else {
RETURN_NULL();
}
@@ -3272,34 +3229,34 @@ PHP_METHOD(Phar, compress)
PHP_METHOD(Phar, decompress)
{
char *ext = NULL;
- int ext_len = 0;
- zval *ret;
+ size_t ext_len = 0;
+ zend_object *ret;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &ext, &ext_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &ext, &ext_len) == FAILURE) {
return;
}
- if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot decompress phar archive, phar is read-only");
return;
}
- if (phar_obj->arc.archive->is_zip) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ if (phar_obj->archive->is_zip) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot decompress zip-based archives with whole-archive compression");
return;
}
- if (phar_obj->arc.archive->is_tar) {
- ret = phar_convert_to_other(phar_obj->arc.archive, PHAR_FORMAT_TAR, ext, PHAR_FILE_COMPRESSED_NONE TSRMLS_CC);
+ if (phar_obj->archive->is_tar) {
+ ret = phar_convert_to_other(phar_obj->archive, PHAR_FORMAT_TAR, ext, PHAR_FILE_COMPRESSED_NONE);
} else {
- ret = phar_convert_to_other(phar_obj->arc.archive, PHAR_FORMAT_PHAR, ext, PHAR_FILE_COMPRESSED_NONE TSRMLS_CC);
+ ret = phar_convert_to_other(phar_obj->archive, PHAR_FORMAT_PHAR, ext, PHAR_FILE_COMPRESSED_NONE);
}
if (ret) {
- RETURN_ZVAL(ret, 1, 1);
+ ZVAL_OBJ(return_value, ret);
} else {
RETURN_NULL();
}
@@ -3315,15 +3272,15 @@ PHP_METHOD(Phar, compressFiles)
{
char *error;
php_uint32 flags;
- long method;
+ zend_long method;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &method) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &method) == FAILURE) {
return;
}
- if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Phar is readonly, cannot change compression");
return;
}
@@ -3331,7 +3288,7 @@ PHP_METHOD(Phar, compressFiles)
switch (method) {
case PHAR_ENT_COMPRESSED_GZ:
if (!PHAR_G(has_zlib)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress files within archive with gzip, enable ext/zlib in php.ini");
return;
}
@@ -3340,45 +3297,45 @@ PHP_METHOD(Phar, compressFiles)
case PHAR_ENT_COMPRESSED_BZ2:
if (!PHAR_G(has_bz2)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress files within archive with bz2, enable ext/bz2 in php.ini");
return;
}
flags = PHAR_ENT_COMPRESSED_BZ2;
break;
default:
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2");
return;
}
- if (phar_obj->arc.archive->is_tar) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ if (phar_obj->archive->is_tar) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress with Gzip compression, tar archives cannot compress individual files, use compress() to compress the whole archive");
return;
}
- if (!pharobj_cancompress(&phar_obj->arc.archive->manifest TSRMLS_CC)) {
+ if (!pharobj_cancompress(&phar_obj->archive->manifest)) {
if (flags == PHAR_FILE_COMPRESSED_GZ) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress all files as Gzip, some are compressed as bzip2 and cannot be decompressed");
} else {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress all files as Bzip2, some are compressed as gzip and cannot be decompressed");
}
return;
}
- if (phar_obj->arc.archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) {
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname);
return;
}
- pharobj_set_compression(&phar_obj->arc.archive->manifest, flags TSRMLS_CC);
- phar_obj->arc.archive->is_modified = 1;
- phar_flush(phar_obj->arc.archive, 0, 0, 0, &error TSRMLS_CC);
+ pharobj_set_compression(&phar_obj->archive->manifest, flags);
+ phar_obj->archive->is_modified = 1;
+ phar_flush(phar_obj->archive, 0, 0, 0, &error);
if (error) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s", error);
efree(error);
}
}
@@ -3396,33 +3353,33 @@ PHP_METHOD(Phar, decompressFiles)
return;
}
- if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Phar is readonly, cannot change compression");
return;
}
- if (!pharobj_cancompress(&phar_obj->arc.archive->manifest TSRMLS_CC)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ if (!pharobj_cancompress(&phar_obj->archive->manifest)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot decompress all files, some are compressed as bzip2 or gzip and cannot be decompressed");
return;
}
- if (phar_obj->arc.archive->is_tar) {
+ if (phar_obj->archive->is_tar) {
RETURN_TRUE;
} else {
- if (phar_obj->arc.archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) {
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname);
return;
}
- pharobj_set_compression(&phar_obj->arc.archive->manifest, PHAR_ENT_COMPRESSED_NONE TSRMLS_CC);
+ pharobj_set_compression(&phar_obj->archive->manifest, PHAR_ENT_COMPRESSED_NONE);
}
- phar_obj->arc.archive->is_modified = 1;
- phar_flush(phar_obj->arc.archive, 0, 0, 0, &error TSRMLS_CC);
+ phar_obj->archive->is_modified = 1;
+ phar_flush(phar_obj->archive, 0, 0, 0, &error);
if (error) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s", error);
efree(error);
}
@@ -3437,77 +3394,72 @@ PHP_METHOD(Phar, copy)
{
char *oldfile, *newfile, *error;
const char *pcr_error;
- int oldfile_len, newfile_len;
+ size_t oldfile_len, newfile_len;
phar_entry_info *oldentry, newentry = {0}, *temp;
+ int tmp_len = 0;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
- if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot copy \"%s\" to \"%s\", phar is read-only", oldfile, newfile);
RETURN_FALSE;
}
if (oldfile_len >= sizeof(".phar")-1 && !memcmp(oldfile, ".phar", sizeof(".phar")-1)) {
/* can't copy a meta file */
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
- "file \"%s\" cannot be copied to file \"%s\", cannot copy Phar meta-file in %s", oldfile, newfile, phar_obj->arc.archive->fname);
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
+ "file \"%s\" cannot be copied to file \"%s\", cannot copy Phar meta-file in %s", oldfile, newfile, phar_obj->archive->fname);
RETURN_FALSE;
}
if (newfile_len >= sizeof(".phar")-1 && !memcmp(newfile, ".phar", sizeof(".phar")-1)) {
/* can't copy a meta file */
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
- "file \"%s\" cannot be copied to file \"%s\", cannot copy to Phar meta-file in %s", oldfile, newfile, phar_obj->arc.archive->fname);
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
+ "file \"%s\" cannot be copied to file \"%s\", cannot copy to Phar meta-file in %s", oldfile, newfile, phar_obj->archive->fname);
RETURN_FALSE;
}
- if (!zend_hash_exists(&phar_obj->arc.archive->manifest, oldfile, (uint) oldfile_len) || SUCCESS != zend_hash_find(&phar_obj->arc.archive->manifest, oldfile, (uint) oldfile_len, (void**)&oldentry) || oldentry->is_deleted) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
- "file \"%s\" cannot be copied to file \"%s\", file does not exist in %s", oldfile, newfile, phar_obj->arc.archive->fname);
+ if (!zend_hash_str_exists(&phar_obj->archive->manifest, oldfile, (uint) oldfile_len) || NULL == (oldentry = zend_hash_str_find_ptr(&phar_obj->archive->manifest, oldfile, (uint) oldfile_len)) || oldentry->is_deleted) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
+ "file \"%s\" cannot be copied to file \"%s\", file does not exist in %s", oldfile, newfile, phar_obj->archive->fname);
RETURN_FALSE;
}
- if (zend_hash_exists(&phar_obj->arc.archive->manifest, newfile, (uint) newfile_len)) {
- if (SUCCESS == zend_hash_find(&phar_obj->arc.archive->manifest, newfile, (uint) newfile_len, (void**)&temp) || !temp->is_deleted) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
- "file \"%s\" cannot be copied to file \"%s\", file must not already exist in phar %s", oldfile, newfile, phar_obj->arc.archive->fname);
+ if (zend_hash_str_exists(&phar_obj->archive->manifest, newfile, (uint) newfile_len)) {
+ if (NULL != (temp = zend_hash_str_find_ptr(&phar_obj->archive->manifest, newfile, (uint) newfile_len)) || !temp->is_deleted) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
+ "file \"%s\" cannot be copied to file \"%s\", file must not already exist in phar %s", oldfile, newfile, phar_obj->archive->fname);
RETURN_FALSE;
}
}
- if (phar_path_check(&newfile, &newfile_len, &pcr_error) > pcr_is_ok) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
- "file \"%s\" contains invalid characters %s, cannot be copied from \"%s\" in phar %s", newfile, pcr_error, oldfile, phar_obj->arc.archive->fname);
+ tmp_len = (int)newfile_len;
+ if (phar_path_check(&newfile, &tmp_len, &pcr_error) > pcr_is_ok) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
+ "file \"%s\" contains invalid characters %s, cannot be copied from \"%s\" in phar %s", newfile, pcr_error, oldfile, phar_obj->archive->fname);
RETURN_FALSE;
}
+ newfile_len = tmp_len;
- if (phar_obj->arc.archive->is_persistent) {
- if (FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ if (phar_obj->archive->is_persistent) {
+ if (FAILURE == phar_copy_on_write(&(phar_obj->archive))) {
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname);
return;
}
/* re-populate with copied-on-write entry */
- zend_hash_find(&phar_obj->arc.archive->manifest, oldfile, (uint) oldfile_len, (void**)&oldentry);
+ oldentry = zend_hash_str_find_ptr(&phar_obj->archive->manifest, oldfile, (uint) oldfile_len);
}
memcpy((void *) &newentry, oldentry, sizeof(phar_entry_info));
- if (newentry.metadata) {
- zval *t;
-
- t = newentry.metadata;
- ALLOC_ZVAL(newentry.metadata);
- *newentry.metadata = *t;
- zval_copy_ctor(newentry.metadata);
- Z_SET_REFCOUNT_P(newentry.metadata, 1);
-
- newentry.metadata_str.c = NULL;
- newentry.metadata_str.len = 0;
+ if (Z_TYPE(newentry.metadata) != IS_UNDEF) {
+ zval_copy_ctor(&newentry.metadata);
+ newentry.metadata_str.s = NULL;
}
newentry.filename = estrndup(newfile, newfile_len);
@@ -3515,21 +3467,21 @@ PHP_METHOD(Phar, copy)
newentry.fp_refcount = 0;
if (oldentry->fp_type != PHAR_FP) {
- if (FAILURE == phar_copy_entry_fp(oldentry, &newentry, &error TSRMLS_CC)) {
+ if (FAILURE == phar_copy_entry_fp(oldentry, &newentry, &error)) {
efree(newentry.filename);
php_stream_close(newentry.fp);
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
return;
}
}
- zend_hash_add(&oldentry->phar->manifest, newfile, newfile_len, (void*)&newentry, sizeof(phar_entry_info), NULL);
- phar_obj->arc.archive->is_modified = 1;
- phar_flush(phar_obj->arc.archive, 0, 0, 0, &error TSRMLS_CC);
+ zend_hash_str_add_mem(&oldentry->phar->manifest, newfile, newfile_len, &newentry, sizeof(phar_entry_info));
+ phar_obj->archive->is_modified = 1;
+ phar_flush(phar_obj->archive, 0, 0, 0, &error);
if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
@@ -3543,17 +3495,17 @@ PHP_METHOD(Phar, copy)
PHP_METHOD(Phar, offsetExists)
{
char *fname;
- int fname_len;
+ size_t fname_len;
phar_entry_info *entry;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
- if (zend_hash_exists(&phar_obj->arc.archive->manifest, fname, (uint) fname_len)) {
- if (SUCCESS == zend_hash_find(&phar_obj->arc.archive->manifest, fname, (uint) fname_len, (void**)&entry)) {
+ if (zend_hash_str_exists(&phar_obj->archive->manifest, fname, (uint) fname_len)) {
+ if (NULL != (entry = zend_hash_str_find_ptr(&phar_obj->archive->manifest, fname, (uint) fname_len))) {
if (entry->is_deleted) {
/* entry is deleted, but has not been flushed to disk yet */
RETURN_FALSE;
@@ -3566,7 +3518,7 @@ PHP_METHOD(Phar, offsetExists)
}
RETURN_TRUE;
} else {
- if (zend_hash_exists(&phar_obj->arc.archive->virtual_dirs, fname, (uint) fname_len)) {
+ if (zend_hash_str_exists(&phar_obj->archive->virtual_dirs, fname, (uint) fname_len)) {
RETURN_TRUE;
}
RETURN_FALSE;
@@ -3580,31 +3532,32 @@ PHP_METHOD(Phar, offsetExists)
PHP_METHOD(Phar, offsetGet)
{
char *fname, *error;
- int fname_len;
- zval *zfname;
+ size_t fname_len;
+ zval zfname;
phar_entry_info *entry;
+ zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
/* security is 0 here so that we can get a better error message than "entry doesn't exist" */
- if (!(entry = phar_get_entry_info_dir(phar_obj->arc.archive, fname, fname_len, 1, &error, 0 TSRMLS_CC))) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s does not exist%s%s", fname, error?", ":"", error?error:"");
+ if (!(entry = phar_get_entry_info_dir(phar_obj->archive, fname, fname_len, 1, &error, 0))) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %s does not exist%s%s", fname, error?", ":"", error?error:"");
} else {
if (fname_len == sizeof(".phar/stub.php")-1 && !memcmp(fname, ".phar/stub.php", sizeof(".phar/stub.php")-1)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot get stub \".phar/stub.php\" directly in phar \"%s\", use getStub", phar_obj->arc.archive->fname);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot get stub \".phar/stub.php\" directly in phar \"%s\", use getStub", phar_obj->archive->fname);
return;
}
if (fname_len == sizeof(".phar/alias.txt")-1 && !memcmp(fname, ".phar/alias.txt", sizeof(".phar/alias.txt")-1)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot get alias \".phar/alias.txt\" directly in phar \"%s\", use getAlias", phar_obj->arc.archive->fname);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot get alias \".phar/alias.txt\" directly in phar \"%s\", use getAlias", phar_obj->archive->fname);
return;
}
if (fname_len >= sizeof(".phar")-1 && !memcmp(fname, ".phar", sizeof(".phar")-1)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot directly get any files or directories in magic \".phar\" directory", phar_obj->arc.archive->fname);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot directly get any files or directories in magic \".phar\" directory", phar_obj->archive->fname);
return;
}
@@ -3613,10 +3566,9 @@ PHP_METHOD(Phar, offsetGet)
efree(entry);
}
- fname_len = spprintf(&fname, 0, "phar://%s/%s", phar_obj->arc.archive->fname, fname);
- MAKE_STD_ZVAL(zfname);
- ZVAL_STRINGL(zfname, fname, fname_len, 0);
- spl_instantiate_arg_ex1(phar_obj->spl.info_class, &return_value, 0, zfname TSRMLS_CC);
+ sfname = strpprintf(0, "phar://%s/%s", phar_obj->archive->fname, fname);
+ ZVAL_NEW_STR(&zfname, sfname);
+ spl_instantiate_arg_ex1(phar_obj->spl.info_class, return_value, &zfname);
zval_ptr_dtor(&zfname);
}
}
@@ -3624,7 +3576,7 @@ PHP_METHOD(Phar, offsetGet)
/* {{{ add a file within the phar archive from a string or resource
*/
-static void phar_add_file(phar_archive_data **pphar, char *filename, int filename_len, char *cont_str, int cont_len, zval *zresource TSRMLS_DC)
+static void phar_add_file(phar_archive_data **pphar, char *filename, int filename_len, char *cont_str, size_t cont_len, zval *zresource)
{
char *error;
size_t contents_len;
@@ -3632,16 +3584,16 @@ static void phar_add_file(phar_archive_data **pphar, char *filename, int filenam
php_stream *contents_file;
if (filename_len >= sizeof(".phar")-1 && !memcmp(filename, ".phar", sizeof(".phar")-1) && (filename[5] == '/' || filename[5] == '\\' || filename[5] == '\0')) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot create any files in magic \".phar\" directory", (*pphar)->fname);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot create any files in magic \".phar\" directory", (*pphar)->fname);
return;
}
- if (!(data = phar_get_or_create_entry_data((*pphar)->fname, (*pphar)->fname_len, filename, filename_len, "w+b", 0, &error, 1 TSRMLS_CC))) {
+ if (!(data = phar_get_or_create_entry_data((*pphar)->fname, (*pphar)->fname_len, filename, filename_len, "w+b", 0, &error, 1))) {
if (error) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s does not exist and cannot be created: %s", filename, error);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %s does not exist and cannot be created: %s", filename, error);
efree(error);
} else {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s does not exist and cannot be created", filename);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %s does not exist and cannot be created", filename);
}
return;
} else {
@@ -3653,12 +3605,12 @@ static void phar_add_file(phar_archive_data **pphar, char *filename, int filenam
if (cont_str) {
contents_len = php_stream_write(data->fp, cont_str, cont_len);
if (contents_len != cont_len) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s could not be written to", filename);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %s could not be written to", filename);
return;
}
} else {
- if (!(php_stream_from_zval_no_verify(contents_file, &zresource))) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s could not be written to", filename);
+ if (!(php_stream_from_zval_no_verify(contents_file, zresource))) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %s could not be written to", filename);
return;
}
php_stream_copy_to_stream_ex(contents_file, data->fp, PHP_STREAM_COPY_ALL, &contents_len);
@@ -3671,11 +3623,11 @@ static void phar_add_file(phar_archive_data **pphar, char *filename, int filenam
if (pphar[0] != data->phar) {
*pphar = data->phar;
}
- phar_entry_delref(data TSRMLS_CC);
- phar_flush(*pphar, 0, 0, 0, &error TSRMLS_CC);
+ phar_entry_delref(data);
+ phar_flush(*pphar, 0, 0, 0, &error);
if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
}
@@ -3684,17 +3636,17 @@ static void phar_add_file(phar_archive_data **pphar, char *filename, int filenam
/* {{{ create a directory within the phar archive
*/
-static void phar_mkdir(phar_archive_data **pphar, char *dirname, int dirname_len TSRMLS_DC)
+static void phar_mkdir(phar_archive_data **pphar, char *dirname, int dirname_len)
{
char *error;
phar_entry_data *data;
- if (!(data = phar_get_or_create_entry_data((*pphar)->fname, (*pphar)->fname_len, dirname, dirname_len, "w+b", 2, &error, 1 TSRMLS_CC))) {
+ if (!(data = phar_get_or_create_entry_data((*pphar)->fname, (*pphar)->fname_len, dirname, dirname_len, "w+b", 2, &error, 1))) {
if (error) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Directory %s does not exist and cannot be created: %s", dirname, error);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Directory %s does not exist and cannot be created: %s", dirname, error);
efree(error);
} else {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Directory %s does not exist and cannot be created", dirname);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Directory %s does not exist and cannot be created", dirname);
}
return;
@@ -3707,11 +3659,11 @@ static void phar_mkdir(phar_archive_data **pphar, char *dirname, int dirname_len
if (data->phar != *pphar) {
*pphar = data->phar;
}
- phar_entry_delref(data TSRMLS_CC);
- phar_flush(*pphar, 0, 0, 0, &error TSRMLS_CC);
+ phar_entry_delref(data);
+ phar_flush(*pphar, 0, 0, 0, &error);
if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
}
@@ -3724,36 +3676,36 @@ static void phar_mkdir(phar_archive_data **pphar, char *dirname, int dirname_len
PHP_METHOD(Phar, offsetSet)
{
char *fname, *cont_str = NULL;
- int fname_len, cont_len;
+ size_t fname_len, cont_len;
zval *zresource;
PHAR_ARCHIVE_OBJECT();
- if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Write operations disabled by the php.ini setting phar.readonly");
+ if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Write operations disabled by the php.ini setting phar.readonly");
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "pr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
if (fname_len == sizeof(".phar/stub.php")-1 && !memcmp(fname, ".phar/stub.php", sizeof(".phar/stub.php")-1)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot set stub \".phar/stub.php\" directly in phar \"%s\", use setStub", phar_obj->arc.archive->fname);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot set stub \".phar/stub.php\" directly in phar \"%s\", use setStub", phar_obj->archive->fname);
return;
}
if (fname_len == sizeof(".phar/alias.txt")-1 && !memcmp(fname, ".phar/alias.txt", sizeof(".phar/alias.txt")-1)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot set alias \".phar/alias.txt\" directly in phar \"%s\", use setAlias", phar_obj->arc.archive->fname);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot set alias \".phar/alias.txt\" directly in phar \"%s\", use setAlias", phar_obj->archive->fname);
return;
}
if (fname_len >= sizeof(".phar")-1 && !memcmp(fname, ".phar", sizeof(".phar")-1)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot set any files or directories in magic \".phar\" directory", phar_obj->arc.archive->fname);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot set any files or directories in magic \".phar\" directory", phar_obj->archive->fname);
return;
}
- phar_add_file(&(phar_obj->arc.archive), fname, fname_len, cont_str, cont_len, zresource TSRMLS_CC);
+ phar_add_file(&(phar_obj->archive), fname, fname_len, cont_str, cont_len, zresource);
}
/* }}} */
@@ -3763,41 +3715,41 @@ PHP_METHOD(Phar, offsetSet)
PHP_METHOD(Phar, offsetUnset)
{
char *fname, *error;
- int fname_len;
+ size_t fname_len;
phar_entry_info *entry;
PHAR_ARCHIVE_OBJECT();
- if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Write operations disabled by the php.ini setting phar.readonly");
+ if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Write operations disabled by the php.ini setting phar.readonly");
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
- if (zend_hash_exists(&phar_obj->arc.archive->manifest, fname, (uint) fname_len)) {
- if (SUCCESS == zend_hash_find(&phar_obj->arc.archive->manifest, fname, (uint) fname_len, (void**)&entry)) {
+ if (zend_hash_str_exists(&phar_obj->archive->manifest, fname, (uint) fname_len)) {
+ if (NULL != (entry = zend_hash_str_find_ptr(&phar_obj->archive->manifest, fname, (uint) fname_len))) {
if (entry->is_deleted) {
/* entry is deleted, but has not been flushed to disk yet */
return;
}
- if (phar_obj->arc.archive->is_persistent) {
- if (FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ if (phar_obj->archive->is_persistent) {
+ if (FAILURE == phar_copy_on_write(&(phar_obj->archive))) {
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname);
return;
}
/* re-populate entry after copy on write */
- zend_hash_find(&phar_obj->arc.archive->manifest, fname, (uint) fname_len, (void **)&entry);
+ entry = zend_hash_str_find_ptr(&phar_obj->archive->manifest, fname, (uint) fname_len);
}
entry->is_modified = 0;
entry->is_deleted = 1;
/* we need to "flush" the stream to save the newly deleted file on disk */
- phar_flush(phar_obj->arc.archive, 0, 0, 0, &error TSRMLS_CC);
+ phar_flush(phar_obj->archive, 0, 0, 0, &error);
if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
@@ -3815,20 +3767,20 @@ PHP_METHOD(Phar, offsetUnset)
PHP_METHOD(Phar, addEmptyDir)
{
char *dirname;
- int dirname_len;
+ size_t dirname_len;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
if (dirname_len >= sizeof(".phar")-1 && !memcmp(dirname, ".phar", sizeof(".phar")-1)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot create a directory in magic \".phar\" directory");
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot create a directory in magic \".phar\" directory");
return;
}
- phar_mkdir(&phar_obj->arc.archive, dirname, dirname_len TSRMLS_CC);
+ phar_mkdir(&phar_obj->archive, dirname, dirname_len);
}
/* }}} */
@@ -3838,30 +3790,30 @@ PHP_METHOD(Phar, addEmptyDir)
PHP_METHOD(Phar, addFile)
{
char *fname, *localname = NULL;
- int fname_len, localname_len = 0;
+ size_t fname_len, localname_len = 0;
php_stream *resource;
- zval *zresource;
+ zval zresource;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
#if PHP_API_VERSION < 20100412
if (PG(safe_mode) && (!php_checkuid(fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) {
- zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, "phar error: unable to open file \"%s\" to add to phar archive, safe_mode restrictions prevent this", fname);
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0, "phar error: unable to open file \"%s\" to add to phar archive, safe_mode restrictions prevent this", fname);
return;
}
#endif
- if (!strstr(fname, "://") && php_check_open_basedir(fname TSRMLS_CC)) {
- zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, "phar error: unable to open file \"%s\" to add to phar archive, open_basedir restrictions prevent this", fname);
+ if (!strstr(fname, "://") && php_check_open_basedir(fname)) {
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0, "phar error: unable to open file \"%s\" to add to phar archive, open_basedir restrictions prevent this", fname);
return;
}
if (!(resource = php_stream_open_wrapper(fname, "rb", 0, NULL))) {
- zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, "phar error: unable to open file \"%s\" to add to phar archive", fname);
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0, "phar error: unable to open file \"%s\" to add to phar archive", fname);
return;
}
@@ -3870,11 +3822,9 @@ PHP_METHOD(Phar, addFile)
fname_len = localname_len;
}
- MAKE_STD_ZVAL(zresource);
- php_stream_to_zval(resource, zresource);
- phar_add_file(&(phar_obj->arc.archive), fname, fname_len, NULL, 0, zresource TSRMLS_CC);
- efree(zresource);
- php_stream_close(resource);
+ php_stream_to_zval(resource, &zresource);
+ phar_add_file(&(phar_obj->archive), fname, fname_len, NULL, 0, &zresource);
+ zval_ptr_dtor(&zresource);
}
/* }}} */
@@ -3884,15 +3834,15 @@ PHP_METHOD(Phar, addFile)
PHP_METHOD(Phar, addFromString)
{
char *localname, *cont_str;
- int localname_len, cont_len;
+ size_t localname_len, cont_len;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
- phar_add_file(&(phar_obj->arc.archive), localname, localname_len, cont_str, cont_len, NULL TSRMLS_CC);
+ phar_add_file(&(phar_obj->archive), localname, localname_len, cont_str, cont_len, NULL);
}
/* }}} */
@@ -3902,7 +3852,7 @@ PHP_METHOD(Phar, addFromString)
PHP_METHOD(Phar, getStub)
{
size_t len;
- char *buf;
+ zend_string *buf;
php_stream *fp;
php_stream_filter *filter = NULL;
phar_entry_info *stub;
@@ -3913,26 +3863,26 @@ PHP_METHOD(Phar, getStub)
return;
}
- if (phar_obj->arc.archive->is_tar || phar_obj->arc.archive->is_zip) {
+ if (phar_obj->archive->is_tar || phar_obj->archive->is_zip) {
- if (SUCCESS == zend_hash_find(&(phar_obj->arc.archive->manifest), ".phar/stub.php", sizeof(".phar/stub.php")-1, (void **)&stub)) {
- if (phar_obj->arc.archive->fp && !phar_obj->arc.archive->is_brandnew && !(stub->flags & PHAR_ENT_COMPRESSION_MASK)) {
- fp = phar_obj->arc.archive->fp;
+ if (NULL != (stub = zend_hash_str_find_ptr(&(phar_obj->archive->manifest), ".phar/stub.php", sizeof(".phar/stub.php")-1))) {
+ if (phar_obj->archive->fp && !phar_obj->archive->is_brandnew && !(stub->flags & PHAR_ENT_COMPRESSION_MASK)) {
+ fp = phar_obj->archive->fp;
} else {
- if (!(fp = php_stream_open_wrapper(phar_obj->arc.archive->fname, "rb", 0, NULL))) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "phar error: unable to open phar \"%s\"", phar_obj->arc.archive->fname);
+ if (!(fp = php_stream_open_wrapper(phar_obj->archive->fname, "rb", 0, NULL))) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "phar error: unable to open phar \"%s\"", phar_obj->archive->fname);
return;
}
if (stub->flags & PHAR_ENT_COMPRESSION_MASK) {
char *filter_name;
if ((filter_name = phar_decompress_filter(stub, 0)) != NULL) {
- filter = php_stream_filter_create(filter_name, NULL, php_stream_is_persistent(fp) TSRMLS_CC);
+ filter = php_stream_filter_create(filter_name, NULL, php_stream_is_persistent(fp));
} else {
filter = NULL;
}
if (!filter) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "phar error: unable to read stub of phar \"%s\" (cannot create %s filter)", phar_obj->arc.archive->fname, phar_decompress_filter(stub, 1));
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "phar error: unable to read stub of phar \"%s\" (cannot create %s filter)", phar_obj->archive->fname, phar_decompress_filter(stub, 1));
return;
}
php_stream_filter_append(&fp->readfilters, filter);
@@ -3940,7 +3890,7 @@ PHP_METHOD(Phar, getStub)
}
if (!fp) {
- zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0,
"Unable to read stub");
return;
}
@@ -3949,48 +3899,49 @@ PHP_METHOD(Phar, getStub)
len = stub->uncompressed_filesize;
goto carry_on;
} else {
- RETURN_STRINGL("", 0, 1);
+ RETURN_EMPTY_STRING();
}
}
- len = phar_obj->arc.archive->halt_offset;
+ len = phar_obj->archive->halt_offset;
- if (phar_obj->arc.archive->fp && !phar_obj->arc.archive->is_brandnew) {
- fp = phar_obj->arc.archive->fp;
+ if (phar_obj->archive->fp && !phar_obj->archive->is_brandnew) {
+ fp = phar_obj->archive->fp;
} else {
- fp = php_stream_open_wrapper(phar_obj->arc.archive->fname, "rb", 0, NULL);
+ fp = php_stream_open_wrapper(phar_obj->archive->fname, "rb", 0, NULL);
}
if (!fp) {
- zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0,
"Unable to read stub");
return;
}
php_stream_rewind(fp);
carry_on:
- buf = safe_emalloc(len, 1, 1);
+ buf = zend_string_alloc(len, 0);
- if (len != php_stream_read(fp, buf, len)) {
- if (fp != phar_obj->arc.archive->fp) {
+ if (len != php_stream_read(fp, ZSTR_VAL(buf), len)) {
+ if (fp != phar_obj->archive->fp) {
php_stream_close(fp);
}
- zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0,
"Unable to read stub");
- efree(buf);
+ zend_string_release(buf);
return;
}
if (filter) {
php_stream_filter_flush(filter, 1);
- php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ php_stream_filter_remove(filter, 1);
}
- if (fp != phar_obj->arc.archive->fp) {
+ if (fp != phar_obj->archive->fp) {
php_stream_close(fp);
}
- buf[len] = '\0';
- RETURN_STRINGL(buf, len, 0);
+ ZSTR_VAL(buf)[len] = '\0';
+ ZSTR_LEN(buf) = len;
+ RETVAL_STR(buf);
}
/* }}}*/
@@ -4001,7 +3952,7 @@ PHP_METHOD(Phar, hasMetadata)
{
PHAR_ARCHIVE_OBJECT();
- RETURN_BOOL(phar_obj->arc.archive->metadata != NULL);
+ RETURN_BOOL(Z_TYPE(phar_obj->archive->metadata) != IS_UNDEF);
}
/* }}} */
@@ -4016,16 +3967,15 @@ PHP_METHOD(Phar, getMetadata)
return;
}
- if (phar_obj->arc.archive->metadata) {
- if (phar_obj->arc.archive->is_persistent) {
- zval *ret;
- char *buf = estrndup((char *) phar_obj->arc.archive->metadata, phar_obj->arc.archive->metadata_len);
+ if (Z_TYPE(phar_obj->archive->metadata) != IS_UNDEF) {
+ if (phar_obj->archive->is_persistent) {
+ char *buf = estrndup((char *) Z_PTR(phar_obj->archive->metadata), phar_obj->archive->metadata_len);
/* assume success, we would have failed before */
- phar_parse_metadata(&buf, &ret, phar_obj->arc.archive->metadata_len TSRMLS_CC);
+ phar_parse_metadata(&buf, return_value, phar_obj->archive->metadata_len);
efree(buf);
- RETURN_ZVAL(ret, 0, 1);
+ } else {
+ ZVAL_COPY(return_value, &phar_obj->archive->metadata);
}
- RETURN_ZVAL(phar_obj->arc.archive->metadata, 1, 0);
}
}
/* }}} */
@@ -4040,31 +3990,30 @@ PHP_METHOD(Phar, setMetadata)
PHAR_ARCHIVE_OBJECT();
- if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Write operations disabled by the php.ini setting phar.readonly");
+ if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Write operations disabled by the php.ini setting phar.readonly");
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &metadata) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &metadata) == FAILURE) {
return;
}
- if (phar_obj->arc.archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) {
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname);
return;
}
- if (phar_obj->arc.archive->metadata) {
- zval_ptr_dtor(&phar_obj->arc.archive->metadata);
- phar_obj->arc.archive->metadata = NULL;
+ if (Z_TYPE(phar_obj->archive->metadata) != IS_UNDEF) {
+ zval_ptr_dtor(&phar_obj->archive->metadata);
+ ZVAL_UNDEF(&phar_obj->archive->metadata);
}
- MAKE_STD_ZVAL(phar_obj->arc.archive->metadata);
- ZVAL_ZVAL(phar_obj->arc.archive->metadata, metadata, 1, 0);
- phar_obj->arc.archive->is_modified = 1;
- phar_flush(phar_obj->arc.archive, 0, 0, 0, &error TSRMLS_CC);
+ ZVAL_COPY(&phar_obj->archive->metadata, metadata);
+ phar_obj->archive->is_modified = 1;
+ phar_flush(phar_obj->archive, 0, 0, 0, &error);
if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
}
@@ -4079,19 +4028,19 @@ PHP_METHOD(Phar, delMetadata)
PHAR_ARCHIVE_OBJECT();
- if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Write operations disabled by the php.ini setting phar.readonly");
+ if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Write operations disabled by the php.ini setting phar.readonly");
return;
}
- if (phar_obj->arc.archive->metadata) {
- zval_ptr_dtor(&phar_obj->arc.archive->metadata);
- phar_obj->arc.archive->metadata = NULL;
- phar_obj->arc.archive->is_modified = 1;
- phar_flush(phar_obj->arc.archive, 0, 0, 0, &error TSRMLS_CC);
+ if (Z_TYPE(phar_obj->archive->metadata) != IS_UNDEF) {
+ zval_ptr_dtor(&phar_obj->archive->metadata);
+ ZVAL_UNDEF(&phar_obj->archive->metadata);
+ phar_obj->archive->is_modified = 1;
+ phar_flush(phar_obj->archive, 0, 0, 0, &error);
if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
RETURN_FALSE;
} else {
@@ -4105,13 +4054,13 @@ PHP_METHOD(Phar, delMetadata)
/* }}} */
#if PHP_API_VERSION < 20100412
#define PHAR_OPENBASEDIR_CHECKPATH(filename) \
- (PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(filename TSRMLS_CC)
+ (PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(filename)
#else
#define PHAR_OPENBASEDIR_CHECKPATH(filename) \
- php_check_open_basedir(filename TSRMLS_CC)
+ php_check_open_basedir(filename)
#endif
-static int phar_extract_file(zend_bool overwrite, phar_entry_info *entry, char *dest, int dest_len, char **error TSRMLS_DC) /* {{{ */
+static int phar_extract_file(zend_bool overwrite, phar_entry_info *entry, char *dest, int dest_len, char **error) /* {{{ */
{
php_stream_statbuf ssb;
int len;
@@ -4136,7 +4085,7 @@ static int phar_extract_file(zend_bool overwrite, phar_entry_info *entry, char *
new_state.cwd[0] = DEFAULT_SLASH;
new_state.cwd[1] = '\0';
new_state.cwd_length = 1;
- if (virtual_file_ex(&new_state, entry->filename, NULL, CWD_EXPAND TSRMLS_CC) != 0 ||
+ if (virtual_file_ex(&new_state, entry->filename, NULL, CWD_EXPAND) != 0 ||
new_state.cwd_length <= 1) {
if (EINVAL == errno && entry->filename_len > 50) {
char *tmp = estrndup(entry->filename, 50);
@@ -4256,8 +4205,8 @@ static int phar_extract_file(zend_bool overwrite, phar_entry_info *entry, char *
return FAILURE;
}
- if (!phar_get_efp(entry, 0 TSRMLS_CC)) {
- if (FAILURE == phar_open_entry_fp(entry, error, 1 TSRMLS_CC)) {
+ if (!phar_get_efp(entry, 0)) {
+ if (FAILURE == phar_open_entry_fp(entry, error, 1)) {
if (error) {
spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", unable to open internal file pointer: %s", entry->filename, fullpath, *error);
} else {
@@ -4269,14 +4218,14 @@ static int phar_extract_file(zend_bool overwrite, phar_entry_info *entry, char *
}
}
- if (FAILURE == phar_seek_efp(entry, 0, SEEK_SET, 0, 0 TSRMLS_CC)) {
+ if (FAILURE == phar_seek_efp(entry, 0, SEEK_SET, 0, 0)) {
spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", unable to seek internal file pointer", entry->filename, fullpath);
efree(fullpath);
php_stream_close(fp);
return FAILURE;
}
- if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, 0 TSRMLS_CC), fp, entry->uncompressed_filesize, NULL)) {
+ if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, 0), fp, entry->uncompressed_filesize, NULL)) {
spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", copying contents failed", entry->filename, fullpath);
efree(fullpath);
php_stream_close(fp);
@@ -4306,8 +4255,8 @@ PHP_METHOD(Phar, extractTo)
php_stream *fp;
php_stream_statbuf ssb;
phar_entry_info *entry;
- char *pathto, *filename, *actual;
- int pathto_len, filename_len;
+ char *pathto, *filename;
+ size_t pathto_len, filename_len;
int ret, i;
int nelems;
zval *zval_files = NULL;
@@ -4315,23 +4264,22 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
- fp = php_stream_open_wrapper(phar_obj->arc.archive->fname, "rb", IGNORE_URL|STREAM_MUST_SEEK, &actual);
+ fp = php_stream_open_wrapper(phar_obj->archive->fname, "rb", IGNORE_URL|STREAM_MUST_SEEK, NULL);
if (!fp) {
- zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC,
- "Invalid argument, %s cannot be found", phar_obj->arc.archive->fname);
+ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0,
+ "Invalid argument, %s cannot be found", phar_obj->archive->fname);
return;
}
- efree(actual);
php_stream_close(fp);
if (pathto_len < 1) {
- zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0,
"Invalid argument, extraction path must be non-zero length");
return;
}
@@ -4339,7 +4287,7 @@ PHP_METHOD(Phar, extractTo)
if (pathto_len >= MAXPATHLEN) {
char *tmp = estrndup(pathto, 50);
/* truncate for error message */
- zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Cannot extract to \"%s...\", destination directory is too long for filesystem", tmp);
+ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Cannot extract to \"%s...\", destination directory is too long for filesystem", tmp);
efree(tmp);
return;
}
@@ -4347,12 +4295,12 @@ PHP_METHOD(Phar, extractTo)
if (php_stream_stat_path(pathto, &ssb) < 0) {
ret = php_stream_mkdir(pathto, 0777, PHP_STREAM_MKDIR_RECURSIVE, NULL);
if (!ret) {
- zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0,
"Unable to create path \"%s\" for extraction", pathto);
return;
}
} else if (!(ssb.sb.st_mode & S_IFDIR)) {
- zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0,
"Unable to use path \"%s\" for extraction, it is a file, must be a directory", pathto);
return;
}
@@ -4371,23 +4319,23 @@ PHP_METHOD(Phar, extractTo)
RETURN_FALSE;
}
for (i = 0; i < nelems; i++) {
- zval **zval_file;
- if (zend_hash_index_find(Z_ARRVAL_P(zval_files), i, (void **) &zval_file) == SUCCESS) {
- switch (Z_TYPE_PP(zval_file)) {
+ zval *zval_file;
+ if ((zval_file = zend_hash_index_find(Z_ARRVAL_P(zval_files), i)) != NULL) {
+ switch (Z_TYPE_P(zval_file)) {
case IS_STRING:
break;
default:
- zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0,
"Invalid argument, array of filenames to extract contains non-string value");
return;
}
- if (FAILURE == zend_hash_find(&phar_obj->arc.archive->manifest, Z_STRVAL_PP(zval_file), Z_STRLEN_PP(zval_file), (void **)&entry)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC,
- "Phar Error: attempted to extract non-existent file \"%s\" from phar \"%s\"", Z_STRVAL_PP(zval_file), phar_obj->arc.archive->fname);
+ if (NULL == (entry = zend_hash_find_ptr(&phar_obj->archive->manifest, Z_STR_P(zval_file)))) {
+ zend_throw_exception_ex(phar_ce_PharException, 0,
+ "Phar Error: attempted to extract non-existent file \"%s\" from phar \"%s\"", Z_STRVAL_P(zval_file), phar_obj->archive->fname);
}
- if (FAILURE == phar_extract_file(overwrite, entry, pathto, pathto_len, &error TSRMLS_CC)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC,
- "Extraction from phar \"%s\" failed: %s", phar_obj->arc.archive->fname, error);
+ if (FAILURE == phar_extract_file(overwrite, entry, pathto, pathto_len, &error)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0,
+ "Extraction from phar \"%s\" failed: %s", phar_obj->archive->fname, error);
efree(error);
return;
}
@@ -4395,47 +4343,40 @@ PHP_METHOD(Phar, extractTo)
}
RETURN_TRUE;
default:
- zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0,
"Invalid argument, expected a filename (string) or array of filenames");
return;
}
- if (FAILURE == zend_hash_find(&phar_obj->arc.archive->manifest, filename, filename_len, (void **)&entry)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC,
- "Phar Error: attempted to extract non-existent file \"%s\" from phar \"%s\"", filename, phar_obj->arc.archive->fname);
+ if (NULL == (entry = zend_hash_str_find_ptr(&phar_obj->archive->manifest, filename, filename_len))) {
+ zend_throw_exception_ex(phar_ce_PharException, 0,
+ "Phar Error: attempted to extract non-existent file \"%s\" from phar \"%s\"", filename, phar_obj->archive->fname);
return;
}
- if (FAILURE == phar_extract_file(overwrite, entry, pathto, pathto_len, &error TSRMLS_CC)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC,
- "Extraction from phar \"%s\" failed: %s", phar_obj->arc.archive->fname, error);
+ if (FAILURE == phar_extract_file(overwrite, entry, pathto, pathto_len, &error)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0,
+ "Extraction from phar \"%s\" failed: %s", phar_obj->archive->fname, error);
efree(error);
return;
}
} else {
phar_archive_data *phar;
all_files:
- phar = phar_obj->arc.archive;
+ phar = phar_obj->archive;
/* Extract all files */
if (!zend_hash_num_elements(&(phar->manifest))) {
RETURN_TRUE;
}
- for (zend_hash_internal_pointer_reset(&phar->manifest);
- zend_hash_has_more_elements(&phar->manifest) == SUCCESS;
- zend_hash_move_forward(&phar->manifest)) {
-
- if (zend_hash_get_current_data(&phar->manifest, (void **)&entry) == FAILURE) {
- continue;
- }
-
- if (FAILURE == phar_extract_file(overwrite, entry, pathto, pathto_len, &error TSRMLS_CC)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC,
+ ZEND_HASH_FOREACH_PTR(&phar->manifest, entry) {
+ if (FAILURE == phar_extract_file(overwrite, entry, pathto, pathto_len, &error)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0,
"Extraction from phar \"%s\" failed: %s", phar->fname, error);
efree(error);
return;
}
- }
+ } ZEND_HASH_FOREACH_END();
}
RETURN_TRUE;
}
@@ -4448,45 +4389,46 @@ all_files:
PHP_METHOD(PharFileInfo, __construct)
{
char *fname, *arch, *entry, *error;
- int fname_len, arch_len, entry_len;
+ size_t fname_len;
+ int arch_len, entry_len;
phar_entry_object *entry_obj;
phar_entry_info *entry_info;
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
- entry_obj = (phar_entry_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+ entry_obj = (phar_entry_object*)((char*)Z_OBJ_P(zobj) - Z_OBJ_P(zobj)->handlers->offset);
- if (entry_obj->ent.entry) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot call constructor twice");
+ if (entry_obj->entry) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot call constructor twice");
return;
}
- if (fname_len < 7 || memcmp(fname, "phar://", 7) || phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0 TSRMLS_CC) == FAILURE) {
- zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC,
+ if (fname_len < 7 || memcmp(fname, "phar://", 7) || phar_split_fname(fname, (int)fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0) == FAILURE) {
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0,
"'%s' is not a valid phar archive URL (must have at least phar://filename.phar)", fname);
return;
}
- if (phar_open_from_filename(arch, arch_len, NULL, 0, REPORT_ERRORS, &phar_data, &error TSRMLS_CC) == FAILURE) {
+ if (phar_open_from_filename(arch, arch_len, NULL, 0, REPORT_ERRORS, &phar_data, &error) == FAILURE) {
efree(arch);
efree(entry);
if (error) {
- zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0,
"Cannot open phar file '%s': %s", fname, error);
efree(error);
} else {
- zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0,
"Cannot open phar file '%s'", fname);
}
return;
}
- if ((entry_info = phar_get_entry_info_dir(phar_data, entry, entry_len, 1, &error, 1 TSRMLS_CC)) == NULL) {
- zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC,
+ if ((entry_info = phar_get_entry_info_dir(phar_data, entry, entry_len, 1, &error, 1)) == NULL) {
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0,
"Cannot access phar file entry '%s' in archive '%s'%s%s", entry, arch, error ? ", " : "", error ? error : "");
efree(arch);
efree(entry);
@@ -4496,20 +4438,22 @@ PHP_METHOD(PharFileInfo, __construct)
efree(arch);
efree(entry);
- entry_obj->ent.entry = entry_info;
+ entry_obj->entry = entry_info;
- INIT_PZVAL(&arg1);
- ZVAL_STRINGL(&arg1, fname, fname_len, 0);
+ ZVAL_STRINGL(&arg1, fname, fname_len);
- zend_call_method_with_1_params(&zobj, Z_OBJCE_P(zobj),
+ zend_call_method_with_1_params(zobj, Z_OBJCE_P(zobj),
&spl_ce_SplFileInfo->constructor, "__construct", NULL, &arg1);
+
+ zval_ptr_dtor(&arg1);
}
/* }}} */
#define PHAR_ENTRY_OBJECT() \
- phar_entry_object *entry_obj = (phar_entry_object*)zend_object_store_get_object(getThis() TSRMLS_CC); \
- if (!entry_obj->ent.entry) { \
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
+ zval *zobj = getThis(); \
+ phar_entry_object *entry_obj = (phar_entry_object*)((char*)Z_OBJ_P(zobj) - Z_OBJ_P(zobj)->handlers->offset); \
+ if (!entry_obj->entry) { \
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \
"Cannot call method on an uninitialized PharFileInfo object"); \
return; \
}
@@ -4519,16 +4463,17 @@ PHP_METHOD(PharFileInfo, __construct)
*/
PHP_METHOD(PharFileInfo, __destruct)
{
- phar_entry_object *entry_obj = (phar_entry_object*)zend_object_store_get_object(getThis() TSRMLS_CC); \
+ zval *zobj = getThis();
+ phar_entry_object *entry_obj = (phar_entry_object*)((char*)Z_OBJ_P(zobj) - Z_OBJ_P(zobj)->handlers->offset);
- if (entry_obj->ent.entry && entry_obj->ent.entry->is_temp_dir) {
- if (entry_obj->ent.entry->filename) {
- efree(entry_obj->ent.entry->filename);
- entry_obj->ent.entry->filename = NULL;
+ if (entry_obj->entry && entry_obj->entry->is_temp_dir) {
+ if (entry_obj->entry->filename) {
+ efree(entry_obj->entry->filename);
+ entry_obj->entry->filename = NULL;
}
- efree(entry_obj->ent.entry);
- entry_obj->ent.entry = NULL;
+ efree(entry_obj->entry);
+ entry_obj->entry = NULL;
}
}
/* }}} */
@@ -4544,7 +4489,7 @@ PHP_METHOD(PharFileInfo, getCompressedSize)
return;
}
- RETURN_LONG(entry_obj->ent.entry->compressed_filesize);
+ RETURN_LONG(entry_obj->entry->compressed_filesize);
}
/* }}} */
@@ -4554,22 +4499,22 @@ PHP_METHOD(PharFileInfo, getCompressedSize)
PHP_METHOD(PharFileInfo, isCompressed)
{
/* a number that is not Phar::GZ or Phar::BZ2 */
- long method = 9021976;
+ zend_long method = 9021976;
PHAR_ENTRY_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &method) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &method) == FAILURE) {
return;
}
switch (method) {
case 9021976:
- RETURN_BOOL(entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSION_MASK);
+ RETURN_BOOL(entry_obj->entry->flags & PHAR_ENT_COMPRESSION_MASK);
case PHAR_ENT_COMPRESSED_GZ:
- RETURN_BOOL(entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_GZ);
+ RETURN_BOOL(entry_obj->entry->flags & PHAR_ENT_COMPRESSED_GZ);
case PHAR_ENT_COMPRESSED_BZ2:
- RETURN_BOOL(entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_BZ2);
+ RETURN_BOOL(entry_obj->entry->flags & PHAR_ENT_COMPRESSED_BZ2);
default:
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \
"Unknown compression type specified"); \
}
}
@@ -4586,16 +4531,16 @@ PHP_METHOD(PharFileInfo, getCRC32)
return;
}
- if (entry_obj->ent.entry->is_dir) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
+ if (entry_obj->entry->is_dir) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \
"Phar entry is a directory, does not have a CRC"); \
return;
}
- if (entry_obj->ent.entry->is_crc_checked) {
- RETURN_LONG(entry_obj->ent.entry->crc32);
+ if (entry_obj->entry->is_crc_checked) {
+ RETURN_LONG(entry_obj->entry->crc32);
} else {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \
"Phar entry was not CRC checked"); \
}
}
@@ -4612,7 +4557,7 @@ PHP_METHOD(PharFileInfo, isCRCChecked)
return;
}
- RETURN_BOOL(entry_obj->ent.entry->is_crc_checked);
+ RETURN_BOOL(entry_obj->entry->is_crc_checked);
}
/* }}} */
@@ -4627,7 +4572,7 @@ PHP_METHOD(PharFileInfo, getPharFlags)
return;
}
- RETURN_LONG(entry_obj->ent.entry->flags & ~(PHAR_ENT_PERM_MASK|PHAR_ENT_COMPRESSION_MASK));
+ RETURN_LONG(entry_obj->entry->flags & ~(PHAR_ENT_PERM_MASK|PHAR_ENT_COMPRESSION_MASK));
}
/* }}} */
@@ -4637,41 +4582,41 @@ PHP_METHOD(PharFileInfo, getPharFlags)
PHP_METHOD(PharFileInfo, chmod)
{
char *error;
- long perms;
+ zend_long perms;
PHAR_ENTRY_OBJECT();
- if (entry_obj->ent.entry->is_temp_dir) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
- "Phar entry \"%s\" is a temporary directory (not an actual entry in the archive), cannot chmod", entry_obj->ent.entry->filename); \
+ if (entry_obj->entry->is_temp_dir) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \
+ "Phar entry \"%s\" is a temporary directory (not an actual entry in the archive), cannot chmod", entry_obj->entry->filename); \
return;
}
- if (PHAR_G(readonly) && !entry_obj->ent.entry->phar->is_data) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Cannot modify permissions for file \"%s\" in phar \"%s\", write operations are prohibited", entry_obj->ent.entry->filename, entry_obj->ent.entry->phar->fname);
+ if (PHAR_G(readonly) && !entry_obj->entry->phar->is_data) {
+ zend_throw_exception_ex(phar_ce_PharException, 0, "Cannot modify permissions for file \"%s\" in phar \"%s\", write operations are prohibited", entry_obj->entry->filename, entry_obj->entry->phar->fname);
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &perms) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &perms) == FAILURE) {
return;
}
- if (entry_obj->ent.entry->is_persistent) {
- phar_archive_data *phar = entry_obj->ent.entry->phar;
+ if (entry_obj->entry->is_persistent) {
+ phar_archive_data *phar = entry_obj->entry->phar;
- if (FAILURE == phar_copy_on_write(&phar TSRMLS_CC)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar->fname);
+ if (FAILURE == phar_copy_on_write(&phar)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar->fname);
return;
}
/* re-populate after copy-on-write */
- zend_hash_find(&phar->manifest, entry_obj->ent.entry->filename, entry_obj->ent.entry->filename_len, (void **)&entry_obj->ent.entry);
+ entry_obj->entry = zend_hash_str_find_ptr(&phar->manifest, entry_obj->entry->filename, entry_obj->entry->filename_len);
}
/* clear permissions */
- entry_obj->ent.entry->flags &= ~PHAR_ENT_PERM_MASK;
+ entry_obj->entry->flags &= ~PHAR_ENT_PERM_MASK;
perms &= 0777;
- entry_obj->ent.entry->flags |= perms;
- entry_obj->ent.entry->old_flags = entry_obj->ent.entry->flags;
- entry_obj->ent.entry->phar->is_modified = 1;
- entry_obj->ent.entry->is_modified = 1;
+ entry_obj->entry->flags |= perms;
+ entry_obj->entry->old_flags = entry_obj->entry->flags;
+ entry_obj->entry->phar->is_modified = 1;
+ entry_obj->entry->is_modified = 1;
/* hackish cache in php_stat needs to be cleared */
/* if this code fails to work, check main/streams/streams.c, _php_stream_stat_path */
@@ -4685,10 +4630,10 @@ PHP_METHOD(PharFileInfo, chmod)
BG(CurrentLStatFile) = NULL;
BG(CurrentStatFile) = NULL;
- phar_flush(entry_obj->ent.entry->phar, 0, 0, 0, &error TSRMLS_CC);
+ phar_flush(entry_obj->entry->phar, 0, 0, 0, &error);
if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
}
@@ -4705,7 +4650,7 @@ PHP_METHOD(PharFileInfo, hasMetadata)
return;
}
- RETURN_BOOL(entry_obj->ent.entry->metadata != NULL);
+ RETURN_BOOL(Z_TYPE(entry_obj->entry->metadata) != IS_UNDEF);
}
/* }}} */
@@ -4720,16 +4665,15 @@ PHP_METHOD(PharFileInfo, getMetadata)
return;
}
- if (entry_obj->ent.entry->metadata) {
- if (entry_obj->ent.entry->is_persistent) {
- zval *ret;
- char *buf = estrndup((char *) entry_obj->ent.entry->metadata, entry_obj->ent.entry->metadata_len);
+ if (Z_TYPE(entry_obj->entry->metadata) != IS_UNDEF) {
+ if (entry_obj->entry->is_persistent) {
+ char *buf = estrndup((char *) Z_PTR(entry_obj->entry->metadata), entry_obj->entry->metadata_len);
/* assume success, we would have failed before */
- phar_parse_metadata(&buf, &ret, entry_obj->ent.entry->metadata_len TSRMLS_CC);
+ phar_parse_metadata(&buf, return_value, entry_obj->entry->metadata_len);
efree(buf);
- RETURN_ZVAL(ret, 0, 1);
+ } else {
+ ZVAL_COPY(return_value, &entry_obj->entry->metadata);
}
- RETURN_ZVAL(entry_obj->ent.entry->metadata, 1, 0);
}
}
/* }}} */
@@ -4744,45 +4688,44 @@ PHP_METHOD(PharFileInfo, setMetadata)
PHAR_ENTRY_OBJECT();
- if (PHAR_G(readonly) && !entry_obj->ent.entry->phar->is_data) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Write operations disabled by the php.ini setting phar.readonly");
+ if (PHAR_G(readonly) && !entry_obj->entry->phar->is_data) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Write operations disabled by the php.ini setting phar.readonly");
return;
}
- if (entry_obj->ent.entry->is_temp_dir) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
+ if (entry_obj->entry->is_temp_dir) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \
"Phar entry is a temporary directory (not an actual entry in the archive), cannot set metadata"); \
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &metadata) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &metadata) == FAILURE) {
return;
}
- if (entry_obj->ent.entry->is_persistent) {
- phar_archive_data *phar = entry_obj->ent.entry->phar;
+ if (entry_obj->entry->is_persistent) {
+ phar_archive_data *phar = entry_obj->entry->phar;
- if (FAILURE == phar_copy_on_write(&phar TSRMLS_CC)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar->fname);
+ if (FAILURE == phar_copy_on_write(&phar)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar->fname);
return;
}
/* re-populate after copy-on-write */
- zend_hash_find(&phar->manifest, entry_obj->ent.entry->filename, entry_obj->ent.entry->filename_len, (void **)&entry_obj->ent.entry);
+ entry_obj->entry = zend_hash_str_find_ptr(&phar->manifest, entry_obj->entry->filename, entry_obj->entry->filename_len);
}
- if (entry_obj->ent.entry->metadata) {
- zval_ptr_dtor(&entry_obj->ent.entry->metadata);
- entry_obj->ent.entry->metadata = NULL;
+ if (Z_TYPE(entry_obj->entry->metadata) != IS_UNDEF) {
+ zval_ptr_dtor(&entry_obj->entry->metadata);
+ ZVAL_UNDEF(&entry_obj->entry->metadata);
}
- MAKE_STD_ZVAL(entry_obj->ent.entry->metadata);
- ZVAL_ZVAL(entry_obj->ent.entry->metadata, metadata, 1, 0);
+ ZVAL_COPY(&entry_obj->entry->metadata, metadata);
- entry_obj->ent.entry->is_modified = 1;
- entry_obj->ent.entry->phar->is_modified = 1;
- phar_flush(entry_obj->ent.entry->phar, 0, 0, 0, &error TSRMLS_CC);
+ entry_obj->entry->is_modified = 1;
+ entry_obj->entry->phar->is_modified = 1;
+ phar_flush(entry_obj->entry->phar, 0, 0, 0, &error);
if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
}
@@ -4801,37 +4744,37 @@ PHP_METHOD(PharFileInfo, delMetadata)
return;
}
- if (PHAR_G(readonly) && !entry_obj->ent.entry->phar->is_data) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Write operations disabled by the php.ini setting phar.readonly");
+ if (PHAR_G(readonly) && !entry_obj->entry->phar->is_data) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Write operations disabled by the php.ini setting phar.readonly");
return;
}
- if (entry_obj->ent.entry->is_temp_dir) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
+ if (entry_obj->entry->is_temp_dir) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \
"Phar entry is a temporary directory (not an actual entry in the archive), cannot delete metadata"); \
return;
}
- if (entry_obj->ent.entry->metadata) {
- if (entry_obj->ent.entry->is_persistent) {
- phar_archive_data *phar = entry_obj->ent.entry->phar;
+ if (Z_TYPE(entry_obj->entry->metadata) != IS_UNDEF) {
+ if (entry_obj->entry->is_persistent) {
+ phar_archive_data *phar = entry_obj->entry->phar;
- if (FAILURE == phar_copy_on_write(&phar TSRMLS_CC)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar->fname);
+ if (FAILURE == phar_copy_on_write(&phar)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar->fname);
return;
}
/* re-populate after copy-on-write */
- zend_hash_find(&phar->manifest, entry_obj->ent.entry->filename, entry_obj->ent.entry->filename_len, (void **)&entry_obj->ent.entry);
+ entry_obj->entry = zend_hash_str_find_ptr(&phar->manifest, entry_obj->entry->filename, entry_obj->entry->filename_len);
}
- zval_ptr_dtor(&entry_obj->ent.entry->metadata);
- entry_obj->ent.entry->metadata = NULL;
- entry_obj->ent.entry->is_modified = 1;
- entry_obj->ent.entry->phar->is_modified = 1;
+ zval_ptr_dtor(&entry_obj->entry->metadata);
+ ZVAL_UNDEF(&entry_obj->entry->metadata);
+ entry_obj->entry->is_modified = 1;
+ entry_obj->entry->phar->is_modified = 1;
- phar_flush(entry_obj->ent.entry->phar, 0, 0, 0, &error TSRMLS_CC);
+ phar_flush(entry_obj->entry->phar, 0, 0, 0, &error);
if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
RETURN_FALSE;
} else {
@@ -4852,6 +4795,7 @@ PHP_METHOD(PharFileInfo, getContent)
char *error;
php_stream *fp;
phar_entry_info *link;
+ zend_string *str;
PHAR_ENTRY_OBJECT();
@@ -4859,38 +4803,37 @@ PHP_METHOD(PharFileInfo, getContent)
return;
}
- if (entry_obj->ent.entry->is_dir) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Phar error: Cannot retrieve contents, \"%s\" in phar \"%s\" is a directory", entry_obj->ent.entry->filename, entry_obj->ent.entry->phar->fname);
+ if (entry_obj->entry->is_dir) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
+ "Phar error: Cannot retrieve contents, \"%s\" in phar \"%s\" is a directory", entry_obj->entry->filename, entry_obj->entry->phar->fname);
return;
}
- link = phar_get_link_source(entry_obj->ent.entry TSRMLS_CC);
+ link = phar_get_link_source(entry_obj->entry);
if (!link) {
- link = entry_obj->ent.entry;
+ link = entry_obj->entry;
}
- if (SUCCESS != phar_open_entry_fp(link, &error, 0 TSRMLS_CC)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Phar error: Cannot retrieve contents, \"%s\" in phar \"%s\": %s", entry_obj->ent.entry->filename, entry_obj->ent.entry->phar->fname, error);
+ if (SUCCESS != phar_open_entry_fp(link, &error, 0)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
+ "Phar error: Cannot retrieve contents, \"%s\" in phar \"%s\": %s", entry_obj->entry->filename, entry_obj->entry->phar->fname, error);
efree(error);
return;
}
- if (!(fp = phar_get_efp(link, 0 TSRMLS_CC))) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Phar error: Cannot retrieve contents of \"%s\" in phar \"%s\"", entry_obj->ent.entry->filename, entry_obj->ent.entry->phar->fname);
+ if (!(fp = phar_get_efp(link, 0))) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
+ "Phar error: Cannot retrieve contents of \"%s\" in phar \"%s\"", entry_obj->entry->filename, entry_obj->entry->phar->fname);
return;
}
- phar_seek_efp(link, 0, SEEK_SET, 0, 0 TSRMLS_CC);
- Z_TYPE_P(return_value) = IS_STRING;
- Z_STRVAL_P(return_value) = NULL;
- Z_STRLEN_P(return_value) = php_stream_copy_to_mem(fp, &(Z_STRVAL_P(return_value)), link->uncompressed_filesize, 0);
-
- if (!Z_STRVAL_P(return_value)) {
- Z_STRVAL_P(return_value) = estrndup("", 0);
+ phar_seek_efp(link, 0, SEEK_SET, 0, 0);
+ str = php_stream_copy_to_mem(fp, link->uncompressed_filesize, 0);
+ if (str) {
+ RETURN_STR(str);
+ } else {
+ RETURN_EMPTY_STRING();
}
}
/* }}} */
@@ -4900,121 +4843,121 @@ PHP_METHOD(PharFileInfo, getContent)
*/
PHP_METHOD(PharFileInfo, compress)
{
- long method;
+ zend_long method;
char *error;
PHAR_ENTRY_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &method) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &method) == FAILURE) {
return;
}
- if (entry_obj->ent.entry->is_tar) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ if (entry_obj->entry->is_tar) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress with Gzip compression, not possible with tar-based phar archives");
return;
}
- if (entry_obj->ent.entry->is_dir) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
+ if (entry_obj->entry->is_dir) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \
"Phar entry is a directory, cannot set compression"); \
return;
}
- if (PHAR_G(readonly) && !entry_obj->ent.entry->phar->is_data) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ if (PHAR_G(readonly) && !entry_obj->entry->phar->is_data) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Phar is readonly, cannot change compression");
return;
}
- if (entry_obj->ent.entry->is_deleted) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ if (entry_obj->entry->is_deleted) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress deleted file");
return;
}
- if (entry_obj->ent.entry->is_persistent) {
- phar_archive_data *phar = entry_obj->ent.entry->phar;
+ if (entry_obj->entry->is_persistent) {
+ phar_archive_data *phar = entry_obj->entry->phar;
- if (FAILURE == phar_copy_on_write(&phar TSRMLS_CC)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar->fname);
+ if (FAILURE == phar_copy_on_write(&phar)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar->fname);
return;
}
/* re-populate after copy-on-write */
- zend_hash_find(&phar->manifest, entry_obj->ent.entry->filename, entry_obj->ent.entry->filename_len, (void **)&entry_obj->ent.entry);
+ entry_obj->entry = zend_hash_str_find_ptr(&phar->manifest, entry_obj->entry->filename, entry_obj->entry->filename_len);
}
switch (method) {
case PHAR_ENT_COMPRESSED_GZ:
- if (entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_GZ) {
+ if (entry_obj->entry->flags & PHAR_ENT_COMPRESSED_GZ) {
RETURN_TRUE;
}
- if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_BZ2) != 0) {
+ if ((entry_obj->entry->flags & PHAR_ENT_COMPRESSED_BZ2) != 0) {
if (!PHAR_G(has_bz2)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress with gzip compression, file is already compressed with bzip2 compression and bz2 extension is not enabled, cannot decompress");
return;
}
/* decompress this file indirectly */
- if (SUCCESS != phar_open_entry_fp(entry_obj->ent.entry, &error, 1 TSRMLS_CC)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Phar error: Cannot decompress bzip2-compressed file \"%s\" in phar \"%s\" in order to compress with gzip: %s", entry_obj->ent.entry->filename, entry_obj->ent.entry->phar->fname, error);
+ if (SUCCESS != phar_open_entry_fp(entry_obj->entry, &error, 1)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
+ "Phar error: Cannot decompress bzip2-compressed file \"%s\" in phar \"%s\" in order to compress with gzip: %s", entry_obj->entry->filename, entry_obj->entry->phar->fname, error);
efree(error);
return;
}
}
if (!PHAR_G(has_zlib)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress with gzip compression, zlib extension is not enabled");
return;
}
- entry_obj->ent.entry->old_flags = entry_obj->ent.entry->flags;
- entry_obj->ent.entry->flags &= ~PHAR_ENT_COMPRESSION_MASK;
- entry_obj->ent.entry->flags |= PHAR_ENT_COMPRESSED_GZ;
+ entry_obj->entry->old_flags = entry_obj->entry->flags;
+ entry_obj->entry->flags &= ~PHAR_ENT_COMPRESSION_MASK;
+ entry_obj->entry->flags |= PHAR_ENT_COMPRESSED_GZ;
break;
case PHAR_ENT_COMPRESSED_BZ2:
- if (entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_BZ2) {
+ if (entry_obj->entry->flags & PHAR_ENT_COMPRESSED_BZ2) {
RETURN_TRUE;
}
- if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_GZ) != 0) {
+ if ((entry_obj->entry->flags & PHAR_ENT_COMPRESSED_GZ) != 0) {
if (!PHAR_G(has_zlib)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress with bzip2 compression, file is already compressed with gzip compression and zlib extension is not enabled, cannot decompress");
return;
}
/* decompress this file indirectly */
- if (SUCCESS != phar_open_entry_fp(entry_obj->ent.entry, &error, 1 TSRMLS_CC)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Phar error: Cannot decompress gzip-compressed file \"%s\" in phar \"%s\" in order to compress with bzip2: %s", entry_obj->ent.entry->filename, entry_obj->ent.entry->phar->fname, error);
+ if (SUCCESS != phar_open_entry_fp(entry_obj->entry, &error, 1)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
+ "Phar error: Cannot decompress gzip-compressed file \"%s\" in phar \"%s\" in order to compress with bzip2: %s", entry_obj->entry->filename, entry_obj->entry->phar->fname, error);
efree(error);
return;
}
}
if (!PHAR_G(has_bz2)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress with bzip2 compression, bz2 extension is not enabled");
return;
}
- entry_obj->ent.entry->old_flags = entry_obj->ent.entry->flags;
- entry_obj->ent.entry->flags &= ~PHAR_ENT_COMPRESSION_MASK;
- entry_obj->ent.entry->flags |= PHAR_ENT_COMPRESSED_BZ2;
+ entry_obj->entry->old_flags = entry_obj->entry->flags;
+ entry_obj->entry->flags &= ~PHAR_ENT_COMPRESSION_MASK;
+ entry_obj->entry->flags |= PHAR_ENT_COMPRESSED_BZ2;
break;
default:
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \
"Unknown compression type specified"); \
}
- entry_obj->ent.entry->phar->is_modified = 1;
- entry_obj->ent.entry->is_modified = 1;
- phar_flush(entry_obj->ent.entry->phar, 0, 0, 0, &error TSRMLS_CC);
+ entry_obj->entry->phar->is_modified = 1;
+ entry_obj->entry->is_modified = 1;
+ phar_flush(entry_obj->entry->phar, 0, 0, 0, &error);
if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
@@ -5034,66 +4977,66 @@ PHP_METHOD(PharFileInfo, decompress)
return;
}
- if (entry_obj->ent.entry->is_dir) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
+ if (entry_obj->entry->is_dir) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \
"Phar entry is a directory, cannot set compression"); \
return;
}
- if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSION_MASK) == 0) {
+ if ((entry_obj->entry->flags & PHAR_ENT_COMPRESSION_MASK) == 0) {
RETURN_TRUE;
}
- if (PHAR_G(readonly) && !entry_obj->ent.entry->phar->is_data) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ if (PHAR_G(readonly) && !entry_obj->entry->phar->is_data) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Phar is readonly, cannot decompress");
return;
}
- if (entry_obj->ent.entry->is_deleted) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ if (entry_obj->entry->is_deleted) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress deleted file");
return;
}
- if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_GZ) != 0 && !PHAR_G(has_zlib)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ if ((entry_obj->entry->flags & PHAR_ENT_COMPRESSED_GZ) != 0 && !PHAR_G(has_zlib)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot decompress Gzip-compressed file, zlib extension is not enabled");
return;
}
- if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_BZ2) != 0 && !PHAR_G(has_bz2)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ if ((entry_obj->entry->flags & PHAR_ENT_COMPRESSED_BZ2) != 0 && !PHAR_G(has_bz2)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot decompress Bzip2-compressed file, bz2 extension is not enabled");
return;
}
- if (entry_obj->ent.entry->is_persistent) {
- phar_archive_data *phar = entry_obj->ent.entry->phar;
+ if (entry_obj->entry->is_persistent) {
+ phar_archive_data *phar = entry_obj->entry->phar;
- if (FAILURE == phar_copy_on_write(&phar TSRMLS_CC)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar->fname);
+ if (FAILURE == phar_copy_on_write(&phar)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar->fname);
return;
}
/* re-populate after copy-on-write */
- zend_hash_find(&phar->manifest, entry_obj->ent.entry->filename, entry_obj->ent.entry->filename_len, (void **)&entry_obj->ent.entry);
+ entry_obj->entry = zend_hash_str_find_ptr(&phar->manifest, entry_obj->entry->filename, entry_obj->entry->filename_len);
}
- if (!entry_obj->ent.entry->fp) {
- if (FAILURE == phar_open_archive_fp(entry_obj->ent.entry->phar TSRMLS_CC)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot decompress entry \"%s\", phar error: Cannot open phar archive \"%s\" for reading", entry_obj->ent.entry->filename, entry_obj->ent.entry->phar->fname);
+ if (!entry_obj->entry->fp) {
+ if (FAILURE == phar_open_archive_fp(entry_obj->entry->phar)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot decompress entry \"%s\", phar error: Cannot open phar archive \"%s\" for reading", entry_obj->entry->filename, entry_obj->entry->phar->fname);
return;
}
- entry_obj->ent.entry->fp_type = PHAR_FP;
+ entry_obj->entry->fp_type = PHAR_FP;
}
- entry_obj->ent.entry->old_flags = entry_obj->ent.entry->flags;
- entry_obj->ent.entry->flags &= ~PHAR_ENT_COMPRESSION_MASK;
- entry_obj->ent.entry->phar->is_modified = 1;
- entry_obj->ent.entry->is_modified = 1;
- phar_flush(entry_obj->ent.entry->phar, 0, 0, 0, &error TSRMLS_CC);
+ entry_obj->entry->old_flags = entry_obj->entry->flags;
+ entry_obj->entry->flags &= ~PHAR_ENT_COMPRESSION_MASK;
+ entry_obj->entry->phar->is_modified = 1;
+ entry_obj->entry->is_modified = 1;
+ phar_flush(entry_obj->entry->phar, 0, 0, 0, &error);
if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
RETURN_TRUE;
@@ -5393,38 +5336,36 @@ zend_function_entry phar_exception_methods[] = {
/* }}} */
#define REGISTER_PHAR_CLASS_CONST_LONG(class_name, const_name, value) \
- zend_declare_class_constant_long(class_name, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC);
-
-#define phar_exception_get_default() zend_exception_get_default(TSRMLS_C)
+ zend_declare_class_constant_long(class_name, const_name, sizeof(const_name)-1, (zend_long)value);
-void phar_object_init(TSRMLS_D) /* {{{ */
+void phar_object_init(void) /* {{{ */
{
zend_class_entry ce;
INIT_CLASS_ENTRY(ce, "PharException", phar_exception_methods);
- phar_ce_PharException = zend_register_internal_class_ex(&ce, phar_exception_get_default(), NULL TSRMLS_CC);
+ phar_ce_PharException = zend_register_internal_class_ex(&ce, zend_ce_exception);
#if HAVE_SPL
INIT_CLASS_ENTRY(ce, "Phar", php_archive_methods);
- phar_ce_archive = zend_register_internal_class_ex(&ce, spl_ce_RecursiveDirectoryIterator, NULL TSRMLS_CC);
+ phar_ce_archive = zend_register_internal_class_ex(&ce, spl_ce_RecursiveDirectoryIterator);
- zend_class_implements(phar_ce_archive TSRMLS_CC, 2, spl_ce_Countable, zend_ce_arrayaccess);
+ zend_class_implements(phar_ce_archive, 2, spl_ce_Countable, zend_ce_arrayaccess);
INIT_CLASS_ENTRY(ce, "PharData", php_archive_methods);
- phar_ce_data = zend_register_internal_class_ex(&ce, spl_ce_RecursiveDirectoryIterator, NULL TSRMLS_CC);
+ phar_ce_data = zend_register_internal_class_ex(&ce, spl_ce_RecursiveDirectoryIterator);
- zend_class_implements(phar_ce_data TSRMLS_CC, 2, spl_ce_Countable, zend_ce_arrayaccess);
+ zend_class_implements(phar_ce_data, 2, spl_ce_Countable, zend_ce_arrayaccess);
INIT_CLASS_ENTRY(ce, "PharFileInfo", php_entry_methods);
- phar_ce_entry = zend_register_internal_class_ex(&ce, spl_ce_SplFileInfo, NULL TSRMLS_CC);
+ phar_ce_entry = zend_register_internal_class_ex(&ce, spl_ce_SplFileInfo);
#else
INIT_CLASS_ENTRY(ce, "Phar", php_archive_methods);
- phar_ce_archive = zend_register_internal_class(&ce TSRMLS_CC);
- phar_ce_archive->ce_flags |= ZEND_ACC_FINAL_CLASS;
+ phar_ce_archive = zend_register_internal_class(&ce);
+ phar_ce_archive->ce_flags |= ZEND_ACC_FINAL;
INIT_CLASS_ENTRY(ce, "PharData", php_archive_methods);
- phar_ce_data = zend_register_internal_class(&ce TSRMLS_CC);
- phar_ce_data->ce_flags |= ZEND_ACC_FINAL_CLASS;
+ phar_ce_data = zend_register_internal_class(&ce);
+ phar_ce_data->ce_flags |= ZEND_ACC_FINAL;
#endif
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "BZ2", PHAR_ENT_COMPRESSED_BZ2)
diff --git a/ext/phar/pharzip.h b/ext/phar/pharzip.h
index ec80646443..9efdacc3fe 100644
--- a/ext/phar/pharzip.h
+++ b/ext/phar/pharzip.h
@@ -179,7 +179,7 @@ typedef struct _phar_zip_dir_signature {
/* unused in this release */
typedef struct _phar_zip64_dir_end {
- char signature[4]; /* zip64 end of central dir
+ char signature[4]; /* zip64 end of central dir
signature 4 bytes (0x06064b50) */
char size1[4]; /* size of zip64 end of central
directory record 8 bytes */
@@ -187,7 +187,7 @@ typedef struct _phar_zip64_dir_end {
char madeby[2]; /* version made by 2 bytes */
char extractneeded[2]; /* version needed to extract 2 bytes */
char disknum[4]; /* number of this disk 4 bytes */
- char cdir_num[4]; /* number of the disk with the
+ char cdir_num[4]; /* number of the disk with the
start of the central directory 4 bytes */
char entries1[4]; /* total number of entries in the
central directory on this disk 8 bytes */
@@ -206,10 +206,10 @@ typedef struct _phar_zip64_dir_end {
/* unused in this release */
typedef struct _phar_zip64_dir_locator {
- char signature[4]; /* zip64 end of central dir locator
+ char signature[4]; /* zip64 end of central dir locator
signature 4 bytes (0x07064b50) */
char disknum[4]; /* number of the disk with the
- start of the zip64 end of
+ start of the zip64 end of
central directory 4 bytes */
char diroffset1[4]; /* relative offset of the zip64
end of central directory record 8 bytes */
diff --git a/ext/phar/php_phar.h b/ext/phar/php_phar.h
index 73e43e0e1a..a767148874 100644
--- a/ext/phar/php_phar.h
+++ b/ext/phar/php_phar.h
@@ -34,7 +34,7 @@ extern zend_module_entry phar_module_entry;
#define PHP_PHAR_API PHPAPI
#endif
-PHP_PHAR_API int phar_resolve_alias(char *alias, int alias_len, char **filename, int *filename_len TSRMLS_DC);
+PHP_PHAR_API int phar_resolve_alias(char *alias, int alias_len, char **filename, int *filename_len);
#endif /* PHP_PHAR_H */
diff --git a/ext/phar/stream.c b/ext/phar/stream.c
index 5a8d6a292d..e68c04b0ec 100644
--- a/ext/phar/stream.c
+++ b/ext/phar/stream.c
@@ -56,7 +56,7 @@ php_stream_wrapper php_stream_phar_wrapper = {
/**
* Open a phar file for streams API
*/
-php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const char *mode, int options TSRMLS_DC) /* {{{ */
+php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const char *mode, int options) /* {{{ */
{
php_url *resource;
char *arch = NULL, *entry = NULL, *error;
@@ -67,17 +67,17 @@ php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const
}
if (mode[0] == 'a') {
if (!(options & PHP_STREAM_URL_STAT_QUIET)) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: open mode append not supported");
+ php_stream_wrapper_log_error(wrapper, options, "phar error: open mode append not supported");
}
return NULL;
}
- if (phar_split_fname(filename, strlen(filename), &arch, &arch_len, &entry, &entry_len, 2, (mode[0] == 'w' ? 2 : 0) TSRMLS_CC) == FAILURE) {
+ if (phar_split_fname(filename, strlen(filename), &arch, &arch_len, &entry, &entry_len, 2, (mode[0] == 'w' ? 2 : 0)) == FAILURE) {
if (!(options & PHP_STREAM_URL_STAT_QUIET)) {
if (arch && !entry) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: no directory in \"%s\", must have at least phar://%s/ for root directory (always use full path to a new phar)", filename, arch);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: no directory in \"%s\", must have at least phar://%s/ for root directory (always use full path to a new phar)", filename, arch);
arch = NULL;
} else {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: invalid url or non-existent phar \"%s\"", filename);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: invalid url or non-existent phar \"%s\"", filename);
}
}
return NULL;
@@ -101,34 +101,34 @@ php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const
}
#endif
if (mode[0] == 'w' || (mode[0] == 'r' && mode[1] == '+')) {
- phar_archive_data **pphar = NULL, *phar;
+ phar_archive_data *pphar = NULL, *phar;
- if (PHAR_GLOBALS->request_init && PHAR_GLOBALS->phar_fname_map.arBuckets && FAILURE == zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), arch, arch_len, (void **)&pphar)) {
+ if (PHAR_G(request_init) && PHAR_G(phar_fname_map.u.flags) && NULL == (pphar = zend_hash_str_find_ptr(&(PHAR_G(phar_fname_map)), arch, arch_len))) {
pphar = NULL;
}
- if (PHAR_G(readonly) && (!pphar || !(*pphar)->is_data)) {
+ if (PHAR_G(readonly) && (!pphar || !pphar->is_data)) {
if (!(options & PHP_STREAM_URL_STAT_QUIET)) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: write operations disabled by the php.ini setting phar.readonly");
+ php_stream_wrapper_log_error(wrapper, options, "phar error: write operations disabled by the php.ini setting phar.readonly");
}
php_url_free(resource);
return NULL;
}
- if (phar_open_or_create_filename(resource->host, arch_len, NULL, 0, 0, options, &phar, &error TSRMLS_CC) == FAILURE)
+ if (phar_open_or_create_filename(resource->host, arch_len, NULL, 0, 0, options, &phar, &error) == FAILURE)
{
if (error) {
if (!(options & PHP_STREAM_URL_STAT_QUIET)) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", error);
+ php_stream_wrapper_log_error(wrapper, options, "%s", error);
}
efree(error);
}
php_url_free(resource);
return NULL;
}
- if (phar->is_persistent && FAILURE == phar_copy_on_write(&phar TSRMLS_CC)) {
+ if (phar->is_persistent && FAILURE == phar_copy_on_write(&phar)) {
if (error) {
spprintf(&error, 0, "Cannot open cached phar '%s' as writeable, copy on write failed", resource->host);
if (!(options & PHP_STREAM_URL_STAT_QUIET)) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", error);
+ php_stream_wrapper_log_error(wrapper, options, "%s", error);
}
efree(error);
}
@@ -136,11 +136,11 @@ php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const
return NULL;
}
} else {
- if (phar_open_from_filename(resource->host, arch_len, NULL, 0, options, NULL, &error TSRMLS_CC) == FAILURE)
+ if (phar_open_from_filename(resource->host, arch_len, NULL, 0, options, NULL, &error) == FAILURE)
{
if (error) {
if (!(options & PHP_STREAM_URL_STAT_QUIET)) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", error);
+ php_stream_wrapper_log_error(wrapper, options, "%s", error);
}
efree(error);
}
@@ -155,7 +155,7 @@ php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const
/**
* used for fopen('phar://...') and company
*/
-static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) /* {{{ */
+static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC) /* {{{ */
{
phar_archive_data *phar;
phar_entry_data *idata;
@@ -164,38 +164,38 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha
HashTable *pharcontext;
php_url *resource = NULL;
php_stream *fpf;
- zval **pzoption, *metadata;
+ zval *pzoption, *metadata;
uint host_len;
- if ((resource = phar_parse_url(wrapper, path, mode, options TSRMLS_CC)) == NULL) {
+ if ((resource = phar_parse_url(wrapper, path, mode, options)) == NULL) {
return NULL;
}
/* we must have at the very least phar://alias.phar/internalfile.php */
if (!resource->scheme || !resource->host || !resource->path) {
php_url_free(resource);
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: invalid url \"%s\"", path);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: invalid url \"%s\"", path);
return NULL;
}
if (strcasecmp("phar", resource->scheme)) {
php_url_free(resource);
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: not a phar stream url \"%s\"", path);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: not a phar stream url \"%s\"", path);
return NULL;
}
host_len = strlen(resource->host);
- phar_request_initialize(TSRMLS_C);
+ phar_request_initialize();
/* strip leading "/" */
internal_file = estrdup(resource->path + 1);
if (mode[0] == 'w' || (mode[0] == 'r' && mode[1] == '+')) {
- if (NULL == (idata = phar_get_or_create_entry_data(resource->host, host_len, internal_file, strlen(internal_file), mode, 0, &error, 1 TSRMLS_CC))) {
+ if (NULL == (idata = phar_get_or_create_entry_data(resource->host, host_len, internal_file, strlen(internal_file), mode, 0, &error, 1))) {
if (error) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", error);
+ php_stream_wrapper_log_error(wrapper, options, "%s", error);
efree(error);
} else {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: file \"%s\" could not be created in phar \"%s\"", internal_file, resource->host);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: file \"%s\" could not be created in phar \"%s\"", internal_file, resource->host);
}
efree(internal_file);
php_url_free(resource);
@@ -208,49 +208,49 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha
php_url_free(resource);
efree(internal_file);
- if (context && context->options && zend_hash_find(HASH_OF(context->options), "phar", sizeof("phar"), (void**)&pzoption) == SUCCESS) {
- pharcontext = HASH_OF(*pzoption);
+ if (context && Z_TYPE(context->options) != IS_UNDEF && (pzoption = zend_hash_str_find(HASH_OF(&context->options), "phar", sizeof("phar")-1)) != NULL) {
+ pharcontext = HASH_OF(pzoption);
if (idata->internal_file->uncompressed_filesize == 0
&& idata->internal_file->compressed_filesize == 0
- && zend_hash_find(pharcontext, "compress", sizeof("compress"), (void**)&pzoption) == SUCCESS
- && Z_TYPE_PP(pzoption) == IS_LONG
- && (Z_LVAL_PP(pzoption) & ~PHAR_ENT_COMPRESSION_MASK) == 0
+ && (pzoption = zend_hash_str_find(pharcontext, "compress", sizeof("compress")-1)) != NULL
+ && Z_TYPE_P(pzoption) == IS_LONG
+ && (Z_LVAL_P(pzoption) & ~PHAR_ENT_COMPRESSION_MASK) == 0
) {
idata->internal_file->flags &= ~PHAR_ENT_COMPRESSION_MASK;
- idata->internal_file->flags |= Z_LVAL_PP(pzoption);
+ idata->internal_file->flags |= Z_LVAL_P(pzoption);
}
- if (zend_hash_find(pharcontext, "metadata", sizeof("metadata"), (void**)&pzoption) == SUCCESS) {
- if (idata->internal_file->metadata) {
+ if ((pzoption = zend_hash_str_find(pharcontext, "metadata", sizeof("metadata")-1)) != NULL) {
+ if (Z_TYPE(idata->internal_file->metadata) != IS_UNDEF) {
zval_ptr_dtor(&idata->internal_file->metadata);
- idata->internal_file->metadata = NULL;
+ ZVAL_UNDEF(&idata->internal_file->metadata);
}
- MAKE_STD_ZVAL(idata->internal_file->metadata);
- metadata = *pzoption;
- ZVAL_ZVAL(idata->internal_file->metadata, metadata, 1, 0);
+ metadata = pzoption;
+ ZVAL_DEREF(metadata);
+ ZVAL_COPY(&idata->internal_file->metadata, metadata);
idata->phar->is_modified = 1;
}
}
if (opened_path) {
- spprintf(opened_path, MAXPATHLEN, "phar://%s/%s", idata->phar->fname, idata->internal_file->filename);
+ *opened_path = strpprintf(MAXPATHLEN, "phar://%s/%s", idata->phar->fname, idata->internal_file->filename);
}
return fpf;
} else {
if (!*internal_file && (options & STREAM_OPEN_FOR_INCLUDE)) {
/* retrieve the stub */
- if (FAILURE == phar_get_archive(&phar, resource->host, host_len, NULL, 0, NULL TSRMLS_CC)) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "file %s is not a valid phar archive", resource->host);
+ if (FAILURE == phar_get_archive(&phar, resource->host, host_len, NULL, 0, NULL)) {
+ php_stream_wrapper_log_error(wrapper, options, "file %s is not a valid phar archive", resource->host);
efree(internal_file);
php_url_free(resource);
return NULL;
}
if (phar->is_tar || phar->is_zip) {
- if ((FAILURE == phar_get_entry_data(&idata, resource->host, host_len, ".phar/stub.php", sizeof(".phar/stub.php")-1, "r", 0, &error, 0 TSRMLS_CC)) || !idata) {
+ if ((FAILURE == phar_get_entry_data(&idata, resource->host, host_len, ".phar/stub.php", sizeof(".phar/stub.php")-1, "r", 0, &error, 0)) || !idata) {
goto idata_error;
}
efree(internal_file);
if (opened_path) {
- spprintf(opened_path, MAXPATHLEN, "%s", phar->fname);
+ *opened_path = strpprintf(MAXPATHLEN, "%s", phar->fname);
}
php_url_free(resource);
goto phar_stub;
@@ -267,7 +267,7 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha
entry->is_crc_checked = 1;
idata = (phar_entry_data *) ecalloc(1, sizeof(phar_entry_data));
- idata->fp = phar_get_pharfp(phar TSRMLS_CC);
+ idata->fp = phar_get_pharfp(phar);
idata->phar = phar;
idata->internal_file = entry;
if (!phar->is_persistent) {
@@ -276,20 +276,20 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha
++(entry->fp_refcount);
php_url_free(resource);
if (opened_path) {
- spprintf(opened_path, MAXPATHLEN, "%s", phar->fname);
+ *opened_path = strpprintf(MAXPATHLEN, "%s", phar->fname);
}
efree(internal_file);
goto phar_stub;
}
}
/* read-only access is allowed to magic files in .phar directory */
- if ((FAILURE == phar_get_entry_data(&idata, resource->host, host_len, internal_file, strlen(internal_file), "r", 0, &error, 0 TSRMLS_CC)) || !idata) {
+ if ((FAILURE == phar_get_entry_data(&idata, resource->host, host_len, internal_file, strlen(internal_file), "r", 0, &error, 0)) || !idata) {
idata_error:
if (error) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", error);
+ php_stream_wrapper_log_error(wrapper, options, "%s", error);
efree(error);
} else {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: \"%s\" is not a file in phar \"%s\"", internal_file, resource->host);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: \"%s\" is not a file in phar \"%s\"", internal_file, resource->host);
}
efree(internal_file);
php_url_free(resource);
@@ -308,10 +308,10 @@ idata_error:
#endif
/* check length, crc32 */
- if (!idata->internal_file->is_crc_checked && phar_postprocess_file(idata, idata->internal_file->crc32, &error, 2 TSRMLS_CC) != SUCCESS) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", error);
+ if (!idata->internal_file->is_crc_checked && phar_postprocess_file(idata, idata->internal_file->crc32, &error, 2) != SUCCESS) {
+ php_stream_wrapper_log_error(wrapper, options, "%s", error);
efree(error);
- phar_entry_delref(idata TSRMLS_CC);
+ phar_entry_delref(idata);
efree(internal_file);
return NULL;
}
@@ -333,7 +333,7 @@ idata_error:
}
}
if (opened_path) {
- spprintf(opened_path, MAXPATHLEN, "phar://%s/%s", idata->phar->fname, idata->internal_file->filename);
+ *opened_path = strpprintf(MAXPATHLEN, "phar://%s/%s", idata->phar->fname, idata->internal_file->filename);
}
efree(internal_file);
phar_stub:
@@ -345,9 +345,12 @@ phar_stub:
/**
* Used for fclose($fp) where $fp is a phar archive
*/
-static int phar_stream_close(php_stream *stream, int close_handle TSRMLS_DC) /* {{{ */
+static int phar_stream_close(php_stream *stream, int close_handle) /* {{{ */
{
- phar_entry_delref((phar_entry_data *)stream->abstract TSRMLS_CC);
+ /* for some reasons phar needs to be flushed even if there is no write going on */
+ phar_stream_flush(stream);
+
+ phar_entry_delref((phar_entry_data *)stream->abstract);
return 0;
}
@@ -356,14 +359,14 @@ static int phar_stream_close(php_stream *stream, int close_handle TSRMLS_DC) /*
/**
* used for fread($fp) and company on a fopen()ed phar file handle
*/
-static size_t phar_stream_read(php_stream *stream, char *buf, size_t count TSRMLS_DC) /* {{{ */
+static size_t phar_stream_read(php_stream *stream, char *buf, size_t count) /* {{{ */
{
phar_entry_data *data = (phar_entry_data *)stream->abstract;
size_t got;
phar_entry_info *entry;
if (data->internal_file->link) {
- entry = phar_get_link_source(data->internal_file TSRMLS_CC);
+ entry = phar_get_link_source(data->internal_file);
} else {
entry = data->internal_file;
}
@@ -378,7 +381,7 @@ static size_t phar_stream_read(php_stream *stream, char *buf, size_t count TSRML
got = php_stream_read(data->fp, buf, MIN(count, entry->uncompressed_filesize - data->position));
data->position = php_stream_tell(data->fp) - data->zero;
- stream->eof = (data->position == (off_t) entry->uncompressed_filesize);
+ stream->eof = (data->position == (zend_off_t) entry->uncompressed_filesize);
return got;
}
@@ -387,15 +390,15 @@ static size_t phar_stream_read(php_stream *stream, char *buf, size_t count TSRML
/**
* Used for fseek($fp) on a phar file handle
*/
-static int phar_stream_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC) /* {{{ */
+static int phar_stream_seek(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffset) /* {{{ */
{
phar_entry_data *data = (phar_entry_data *)stream->abstract;
phar_entry_info *entry;
int res;
- off_t temp;
+ zend_off_t temp;
if (data->internal_file->link) {
- entry = phar_get_link_source(data->internal_file TSRMLS_CC);
+ entry = phar_get_link_source(data->internal_file);
} else {
entry = data->internal_file;
}
@@ -413,7 +416,7 @@ static int phar_stream_seek(php_stream *stream, off_t offset, int whence, off_t
default:
temp = 0;
}
- if (temp > data->zero + (off_t) entry->uncompressed_filesize) {
+ if (temp > data->zero + (zend_off_t) entry->uncompressed_filesize) {
*newoffset = -1;
return -1;
}
@@ -431,17 +434,17 @@ static int phar_stream_seek(php_stream *stream, off_t offset, int whence, off_t
/**
* Used for writing to a phar file
*/
-static size_t phar_stream_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC) /* {{{ */
+static size_t phar_stream_write(php_stream *stream, const char *buf, size_t count) /* {{{ */
{
phar_entry_data *data = (phar_entry_data *) stream->abstract;
php_stream_seek(data->fp, data->position, SEEK_SET);
if (count != php_stream_write(data->fp, buf, count)) {
- php_stream_wrapper_log_error(stream->wrapper, stream->flags TSRMLS_CC, "phar error: Could not write %d characters to \"%s\" in phar \"%s\"", (int) count, data->internal_file->filename, data->phar->fname);
- return -1;
+ php_stream_wrapper_log_error(stream->wrapper, stream->flags, "phar error: Could not write %d characters to \"%s\" in phar \"%s\"", (int) count, data->internal_file->filename, data->phar->fname);
+ return 0;
}
data->position = php_stream_tell(data->fp);
- if (data->position > (off_t)data->internal_file->uncompressed_filesize) {
+ if (data->position > (zend_off_t)data->internal_file->uncompressed_filesize) {
data->internal_file->uncompressed_filesize = data->position;
}
data->internal_file->compressed_filesize = data->internal_file->uncompressed_filesize;
@@ -454,17 +457,17 @@ static size_t phar_stream_write(php_stream *stream, const char *buf, size_t coun
/**
* Used to save work done on a writeable phar
*/
-static int phar_stream_flush(php_stream *stream TSRMLS_DC) /* {{{ */
+static int phar_stream_flush(php_stream *stream) /* {{{ */
{
char *error;
int ret;
phar_entry_data *data = (phar_entry_data *) stream->abstract;
-
+
if (data->internal_file->is_modified) {
data->internal_file->timestamp = time(0);
- ret = phar_flush(data->phar, 0, 0, 0, &error TSRMLS_CC);
+ ret = phar_flush(data->phar, 0, 0, 0, &error);
if (error) {
- php_stream_wrapper_log_error(stream->wrapper, REPORT_ERRORS TSRMLS_CC, "%s", error);
+ php_stream_wrapper_log_error(stream->wrapper, REPORT_ERRORS, "%s", error);
efree(error);
}
return ret;
@@ -478,7 +481,7 @@ static int phar_stream_flush(php_stream *stream TSRMLS_DC) /* {{{ */
/**
* stat an opened phar file handle stream, used by phar_stat()
*/
-void phar_dostat(phar_archive_data *phar, phar_entry_info *data, php_stream_statbuf *ssb, zend_bool is_temp_dir TSRMLS_DC)
+void phar_dostat(phar_archive_data *phar, phar_entry_info *data, php_stream_statbuf *ssb, zend_bool is_temp_dir)
{
memset(ssb, 0, sizeof(php_stream_statbuf));
@@ -546,7 +549,7 @@ void phar_dostat(phar_archive_data *phar, phar_entry_info *data, php_stream_stat
/**
* Stat an opened phar file handle
*/
-static int phar_stream_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC) /* {{{ */
+static int phar_stream_stat(php_stream *stream, php_stream_statbuf *ssb) /* {{{ */
{
phar_entry_data *data = (phar_entry_data *)stream->abstract;
@@ -555,7 +558,7 @@ static int phar_stream_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_D
return -1;
}
- phar_dostat(data->phar, data->internal_file, ssb, 0 TSRMLS_CC);
+ phar_dostat(data->phar, data->internal_file, ssb, 0);
return 0;
}
/* }}} */
@@ -564,7 +567,7 @@ static int phar_stream_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_D
* Stream wrapper stat implementation of stat()
*/
static int phar_wrapper_stat(php_stream_wrapper *wrapper, const char *url, int flags,
- php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC) /* {{{ */
+ php_stream_statbuf *ssb, php_stream_context *context) /* {{{ */
{
php_url *resource = NULL;
char *internal_file, *error;
@@ -573,7 +576,7 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, const char *url, int f
uint host_len;
int internal_file_len;
- if ((resource = phar_parse_url(wrapper, url, "r", flags|PHP_STREAM_URL_STAT_QUIET TSRMLS_CC)) == NULL) {
+ if ((resource = phar_parse_url(wrapper, url, "r", flags|PHP_STREAM_URL_STAT_QUIET)) == NULL) {
return FAILURE;
}
@@ -589,11 +592,11 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, const char *url, int f
}
host_len = strlen(resource->host);
- phar_request_initialize(TSRMLS_C);
+ phar_request_initialize();
internal_file = resource->path + 1; /* strip leading "/" */
/* find the phar in our trusty global hash indexed by alias (host of phar://blah.phar/file.whatever) */
- if (FAILURE == phar_get_archive(&phar, resource->host, host_len, NULL, 0, &error TSRMLS_CC)) {
+ if (FAILURE == phar_get_archive(&phar, resource->host, host_len, NULL, 0, &error)) {
php_url_free(resource);
if (error) {
efree(error);
@@ -605,69 +608,63 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, const char *url, int f
}
if (*internal_file == '\0') {
/* root directory requested */
- phar_dostat(phar, NULL, ssb, 1 TSRMLS_CC);
+ phar_dostat(phar, NULL, ssb, 1);
php_url_free(resource);
return SUCCESS;
}
- if (!phar->manifest.arBuckets) {
+ if (!phar->manifest.u.flags) {
php_url_free(resource);
return FAILURE;
}
internal_file_len = strlen(internal_file);
/* search through the manifest of files, and if we have an exact match, it's a file */
- if (SUCCESS == zend_hash_find(&phar->manifest, internal_file, internal_file_len, (void**)&entry)) {
- phar_dostat(phar, entry, ssb, 0 TSRMLS_CC);
+ if (NULL != (entry = zend_hash_str_find_ptr(&phar->manifest, internal_file, internal_file_len))) {
+ phar_dostat(phar, entry, ssb, 0);
php_url_free(resource);
return SUCCESS;
}
- if (zend_hash_exists(&(phar->virtual_dirs), internal_file, internal_file_len)) {
- phar_dostat(phar, NULL, ssb, 1 TSRMLS_CC);
+ if (zend_hash_str_exists(&(phar->virtual_dirs), internal_file, internal_file_len)) {
+ phar_dostat(phar, NULL, ssb, 1);
php_url_free(resource);
return SUCCESS;
}
/* check for mounted directories */
- if (phar->mounted_dirs.arBuckets && zend_hash_num_elements(&phar->mounted_dirs)) {
- char *str_key;
- ulong unused;
- uint keylen;
- HashPosition pos;
-
- for (zend_hash_internal_pointer_reset_ex(&phar->mounted_dirs, &pos);
- HASH_KEY_NON_EXISTENT != zend_hash_get_current_key_ex(&phar->mounted_dirs, &str_key, &keylen, &unused, 0, &pos);
- zend_hash_move_forward_ex(&phar->mounted_dirs, &pos)
- ) {
- if ((int)keylen >= internal_file_len || strncmp(str_key, internal_file, keylen)) {
+ if (phar->mounted_dirs.u.flags && zend_hash_num_elements(&phar->mounted_dirs)) {
+ zend_string *str_key;
+
+ ZEND_HASH_FOREACH_STR_KEY(&phar->mounted_dirs, str_key) {
+ if ((int)ZSTR_LEN(str_key) >= internal_file_len || strncmp(ZSTR_VAL(str_key), internal_file, ZSTR_LEN(str_key))) {
continue;
} else {
char *test;
int test_len;
php_stream_statbuf ssbi;
- if (SUCCESS != zend_hash_find(&phar->manifest, str_key, keylen, (void **) &entry)) {
+ if (NULL == (entry = zend_hash_find_ptr(&phar->manifest, str_key))) {
goto free_resource;
}
if (!entry->tmp || !entry->is_mounted) {
goto free_resource;
}
- test_len = spprintf(&test, MAXPATHLEN, "%s%s", entry->tmp, internal_file + keylen);
+ test_len = spprintf(&test, MAXPATHLEN, "%s%s", entry->tmp, internal_file + ZSTR_LEN(str_key));
if (SUCCESS != php_stream_stat_path(test, &ssbi)) {
efree(test);
continue;
}
/* mount the file/directory just in time */
- if (SUCCESS != phar_mount_entry(phar, test, test_len, internal_file, internal_file_len TSRMLS_CC)) {
+ if (SUCCESS != phar_mount_entry(phar, test, test_len, internal_file, internal_file_len)) {
efree(test);
goto free_resource;
}
efree(test);
- if (SUCCESS != zend_hash_find(&phar->manifest, internal_file, internal_file_len, (void**)&entry)) {
+ if (NULL == (entry = zend_hash_str_find_ptr(&phar->manifest, internal_file, internal_file_len))) {
goto free_resource;
}
- phar_dostat(phar, entry, ssb, 0 TSRMLS_CC);
+ phar_dostat(phar, entry, ssb, 0);
php_url_free(resource);
return SUCCESS;
}
- }
+ } ZEND_HASH_FOREACH_END();
}
free_resource:
php_url_free(resource);
@@ -678,55 +675,53 @@ free_resource:
/**
* Unlink a file within a phar archive
*/
-static int phar_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context TSRMLS_DC) /* {{{ */
+static int phar_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context) /* {{{ */
{
php_url *resource;
char *internal_file, *error;
int internal_file_len;
phar_entry_data *idata;
- phar_archive_data **pphar;
+ phar_archive_data *pphar;
uint host_len;
- if ((resource = phar_parse_url(wrapper, url, "rb", options TSRMLS_CC)) == NULL) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: unlink failed");
+ if ((resource = phar_parse_url(wrapper, url, "rb", options)) == NULL) {
+ php_stream_wrapper_log_error(wrapper, options, "phar error: unlink failed");
return 0;
}
/* we must have at the very least phar://alias.phar/internalfile.php */
if (!resource->scheme || !resource->host || !resource->path) {
php_url_free(resource);
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: invalid url \"%s\"", url);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: invalid url \"%s\"", url);
return 0;
}
if (strcasecmp("phar", resource->scheme)) {
php_url_free(resource);
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: not a phar stream url \"%s\"", url);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: not a phar stream url \"%s\"", url);
return 0;
}
host_len = strlen(resource->host);
- phar_request_initialize(TSRMLS_C);
+ phar_request_initialize();
- if (FAILURE == zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), resource->host, host_len, (void **) &pphar)) {
- pphar = NULL;
- }
- if (PHAR_G(readonly) && (!pphar || !(*pphar)->is_data)) {
+ pphar = zend_hash_str_find_ptr(&(PHAR_G(phar_fname_map)), resource->host, host_len);
+ if (PHAR_G(readonly) && (!pphar || !pphar->is_data)) {
php_url_free(resource);
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: write operations disabled by the php.ini setting phar.readonly");
+ php_stream_wrapper_log_error(wrapper, options, "phar error: write operations disabled by the php.ini setting phar.readonly");
return 0;
}
/* need to copy to strip leading "/", will get touched again */
internal_file = estrdup(resource->path + 1);
internal_file_len = strlen(internal_file);
- if (FAILURE == phar_get_entry_data(&idata, resource->host, host_len, internal_file, internal_file_len, "r", 0, &error, 1 TSRMLS_CC)) {
+ if (FAILURE == phar_get_entry_data(&idata, resource->host, host_len, internal_file, internal_file_len, "r", 0, &error, 1)) {
/* constraints of fp refcount were not met */
if (error) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "unlink of \"%s\" failed: %s", url, error);
+ php_stream_wrapper_log_error(wrapper, options, "unlink of \"%s\" failed: %s", url, error);
efree(error);
} else {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "unlink of \"%s\" failed, file does not exist", url);
+ php_stream_wrapper_log_error(wrapper, options, "unlink of \"%s\" failed, file does not exist", url);
}
efree(internal_file);
php_url_free(resource);
@@ -737,24 +732,24 @@ static int phar_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int
}
if (idata->internal_file->fp_refcount > 1) {
/* more than just our fp resource is open for this file */
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: \"%s\" in phar \"%s\", has open file pointers, cannot unlink", internal_file, resource->host);
+ php_stream_wrapper_log_error(wrapper, options, "phar error: \"%s\" in phar \"%s\", has open file pointers, cannot unlink", internal_file, resource->host);
efree(internal_file);
php_url_free(resource);
- phar_entry_delref(idata TSRMLS_CC);
+ phar_entry_delref(idata);
return 0;
}
php_url_free(resource);
efree(internal_file);
- phar_entry_remove(idata, &error TSRMLS_CC);
+ phar_entry_remove(idata, &error);
if (error) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", error);
+ php_stream_wrapper_log_error(wrapper, options, "%s", error);
efree(error);
}
return 1;
}
/* }}} */
-static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from, const char *url_to, int options, php_stream_context *context TSRMLS_DC) /* {{{ */
+static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from, const char *url_to, int options, php_stream_context *context) /* {{{ */
{
php_url *resource_from, *resource_to;
char *error;
@@ -766,11 +761,11 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
error = NULL;
- if ((resource_from = phar_parse_url(wrapper, url_from, "wb", options|PHP_STREAM_URL_STAT_QUIET TSRMLS_CC)) == NULL) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": invalid or non-writable url \"%s\"", url_from, url_to, url_from);
+ if ((resource_from = phar_parse_url(wrapper, url_from, "wb", options|PHP_STREAM_URL_STAT_QUIET)) == NULL) {
+ php_error_docref(NULL, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": invalid or non-writable url \"%s\"", url_from, url_to, url_from);
return 0;
}
- if (SUCCESS != phar_get_archive(&pfrom, resource_from->host, strlen(resource_from->host), NULL, 0, &error TSRMLS_CC)) {
+ if (SUCCESS != phar_get_archive(&pfrom, resource_from->host, strlen(resource_from->host), NULL, 0, &error)) {
pfrom = NULL;
if (error) {
efree(error);
@@ -778,16 +773,16 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
}
if (PHAR_G(readonly) && (!pfrom || !pfrom->is_data)) {
php_url_free(resource_from);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: Write operations disabled by the php.ini setting phar.readonly");
+ php_error_docref(NULL, E_WARNING, "phar error: Write operations disabled by the php.ini setting phar.readonly");
return 0;
}
- if ((resource_to = phar_parse_url(wrapper, url_to, "wb", options|PHP_STREAM_URL_STAT_QUIET TSRMLS_CC)) == NULL) {
+ if ((resource_to = phar_parse_url(wrapper, url_to, "wb", options|PHP_STREAM_URL_STAT_QUIET)) == NULL) {
php_url_free(resource_from);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": invalid or non-writable url \"%s\"", url_from, url_to, url_to);
+ php_error_docref(NULL, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": invalid or non-writable url \"%s\"", url_from, url_to, url_to);
return 0;
}
- if (SUCCESS != phar_get_archive(&pto, resource_to->host, strlen(resource_to->host), NULL, 0, &error TSRMLS_CC)) {
+ if (SUCCESS != phar_get_archive(&pto, resource_to->host, strlen(resource_to->host), NULL, 0, &error)) {
if (error) {
efree(error);
}
@@ -795,14 +790,14 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
}
if (PHAR_G(readonly) && (!pto || !pto->is_data)) {
php_url_free(resource_from);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: Write operations disabled by the php.ini setting phar.readonly");
+ php_error_docref(NULL, E_WARNING, "phar error: Write operations disabled by the php.ini setting phar.readonly");
return 0;
}
if (strcmp(resource_from->host, resource_to->host)) {
php_url_free(resource_from);
php_url_free(resource_to);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\", not within the same phar archive", url_from, url_to);
+ php_error_docref(NULL, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\", not within the same phar archive", url_from, url_to);
return 0;
}
@@ -810,56 +805,56 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
if (!resource_from->scheme || !resource_from->host || !resource_from->path) {
php_url_free(resource_from);
php_url_free(resource_to);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": invalid url \"%s\"", url_from, url_to, url_from);
+ php_error_docref(NULL, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": invalid url \"%s\"", url_from, url_to, url_from);
return 0;
}
if (!resource_to->scheme || !resource_to->host || !resource_to->path) {
php_url_free(resource_from);
php_url_free(resource_to);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": invalid url \"%s\"", url_from, url_to, url_to);
+ php_error_docref(NULL, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": invalid url \"%s\"", url_from, url_to, url_to);
return 0;
}
if (strcasecmp("phar", resource_from->scheme)) {
php_url_free(resource_from);
php_url_free(resource_to);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": not a phar stream url \"%s\"", url_from, url_to, url_from);
+ php_error_docref(NULL, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": not a phar stream url \"%s\"", url_from, url_to, url_from);
return 0;
}
if (strcasecmp("phar", resource_to->scheme)) {
php_url_free(resource_from);
php_url_free(resource_to);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": not a phar stream url \"%s\"", url_from, url_to, url_to);
+ php_error_docref(NULL, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": not a phar stream url \"%s\"", url_from, url_to, url_to);
return 0;
}
host_len = strlen(resource_from->host);
- if (SUCCESS != phar_get_archive(&phar, resource_from->host, host_len, NULL, 0, &error TSRMLS_CC)) {
+ if (SUCCESS != phar_get_archive(&phar, resource_from->host, host_len, NULL, 0, &error)) {
php_url_free(resource_from);
php_url_free(resource_to);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": %s", url_from, url_to, error);
+ php_error_docref(NULL, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": %s", url_from, url_to, error);
efree(error);
return 0;
}
- if (phar->is_persistent && FAILURE == phar_copy_on_write(&phar TSRMLS_CC)) {
+ if (phar->is_persistent && FAILURE == phar_copy_on_write(&phar)) {
php_url_free(resource_from);
php_url_free(resource_to);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": could not make cached phar writeable", url_from, url_to);
+ php_error_docref(NULL, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": could not make cached phar writeable", url_from, url_to);
return 0;
}
- if (SUCCESS == zend_hash_find(&(phar->manifest), resource_from->path+1, strlen(resource_from->path)-1, (void **)&entry)) {
+ if (NULL != (entry = zend_hash_str_find_ptr(&(phar->manifest), resource_from->path+1, strlen(resource_from->path)-1))) {
phar_entry_info new, *source;
/* perform rename magic */
if (entry->is_deleted) {
php_url_free(resource_from);
php_url_free(resource_to);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\" from extracted phar archive, source has been deleted", url_from, url_to);
+ php_error_docref(NULL, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\" from extracted phar archive, source has been deleted", url_from, url_to);
return 0;
}
/* transfer all data over to the new entry */
@@ -867,20 +862,20 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
/* mark the old one for deletion */
entry->is_deleted = 1;
entry->fp = NULL;
- entry->metadata = 0;
+ ZVAL_UNDEF(&entry->metadata);
entry->link = entry->tmp = NULL;
source = entry;
/* add to the manifest, and then store the pointer to the new guy in entry */
- zend_hash_add(&(phar->manifest), resource_to->path+1, strlen(resource_to->path)-1, (void **)&new, sizeof(phar_entry_info), (void **) &entry);
+ entry = zend_hash_str_add_mem(&(phar->manifest), resource_to->path+1, strlen(resource_to->path)-1, (void **)&new, sizeof(phar_entry_info));
entry->filename = estrdup(resource_to->path+1);
- if (FAILURE == phar_copy_entry_fp(source, entry, &error TSRMLS_CC)) {
+ if (FAILURE == phar_copy_entry_fp(source, entry, &error)) {
php_url_free(resource_from);
php_url_free(resource_to);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": %s", url_from, url_to, error);
+ php_error_docref(NULL, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": %s", url_from, url_to, error);
efree(error);
- zend_hash_del(&(phar->manifest), entry->filename, strlen(entry->filename));
+ zend_hash_str_del(&(phar->manifest), entry->filename, strlen(entry->filename));
return 0;
}
is_modified = 1;
@@ -888,12 +883,12 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
entry->filename_len = strlen(entry->filename);
is_dir = entry->is_dir;
} else {
- is_dir = zend_hash_exists(&(phar->virtual_dirs), resource_from->path+1, strlen(resource_from->path)-1);
+ is_dir = zend_hash_str_exists(&(phar->virtual_dirs), resource_from->path+1, strlen(resource_from->path)-1);
if (!is_dir) {
/* file does not exist */
php_url_free(resource_from);
php_url_free(resource_to);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\" from extracted phar archive, source does not exist", url_from, url_to);
+ php_error_docref(NULL, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\" from extracted phar archive, source does not exist", url_from, url_to);
return 0;
}
@@ -901,85 +896,82 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
/* Rename directory. Update all nested paths */
if (is_dir) {
- int key_type;
- char *str_key, *new_str_key;
- uint key_len, new_key_len;
- ulong unused;
+ Bucket *b;
+ zend_string *str_key;
+ zend_string *new_str_key;
uint from_len = strlen(resource_from->path+1);
uint to_len = strlen(resource_to->path+1);
- for (zend_hash_internal_pointer_reset(&phar->manifest);
- HASH_KEY_NON_EXISTENT != (key_type = zend_hash_get_current_key_ex(&phar->manifest, &str_key, &key_len, &unused, 0, NULL)) &&
- SUCCESS == zend_hash_get_current_data(&phar->manifest, (void **) &entry);
- zend_hash_move_forward(&phar->manifest)
- ) {
+ ZEND_HASH_FOREACH_BUCKET(&phar->manifest, b) {
+ str_key = b->key;
+ entry = Z_PTR(b->val);
if (!entry->is_deleted &&
- key_len > from_len &&
- memcmp(str_key, resource_from->path+1, from_len) == 0 &&
- IS_SLASH(str_key[from_len])) {
+ ZSTR_LEN(str_key) > from_len &&
+ memcmp(ZSTR_VAL(str_key), resource_from->path+1, from_len) == 0 &&
+ IS_SLASH(ZSTR_VAL(str_key)[from_len])) {
- new_key_len = key_len + to_len - from_len;
- new_str_key = emalloc(new_key_len+1);
- memcpy(new_str_key, resource_to->path + 1, to_len);
- memcpy(new_str_key + to_len, str_key + from_len, key_len - from_len);
- new_str_key[new_key_len] = 0;
+ new_str_key = zend_string_alloc(ZSTR_LEN(str_key) + to_len - from_len, 0);
+ memcpy(ZSTR_VAL(new_str_key), resource_to->path + 1, to_len);
+ memcpy(ZSTR_VAL(new_str_key) + to_len, ZSTR_VAL(str_key) + from_len, ZSTR_LEN(str_key) - from_len);
+ ZSTR_VAL(new_str_key)[ZSTR_LEN(new_str_key)] = 0;
is_modified = 1;
entry->is_modified = 1;
efree(entry->filename);
- entry->filename = new_str_key;
- entry->filename_len = new_key_len;
+ // TODO: avoid reallocation (make entry->filename zend_string*)
+ entry->filename = estrndup(ZSTR_VAL(new_str_key), ZSTR_LEN(new_str_key));
+ entry->filename_len = ZSTR_LEN(new_str_key);
- zend_hash_update_current_key_ex(&phar->manifest, key_type, new_str_key, new_key_len, 0, HASH_UPDATE_KEY_ANYWAY, NULL);
+ zend_string_release(str_key);
+ b->h = zend_string_hash_val(new_str_key);
+ b->key = new_str_key;
}
- }
-
- for (zend_hash_internal_pointer_reset(&phar->virtual_dirs);
- HASH_KEY_NON_EXISTENT != (key_type = zend_hash_get_current_key_ex(&phar->virtual_dirs, &str_key, &key_len, &unused, 0, NULL));
- zend_hash_move_forward(&phar->virtual_dirs)
- ) {
- if (key_len >= from_len &&
- memcmp(str_key, resource_from->path+1, from_len) == 0 &&
- (key_len == from_len || IS_SLASH(str_key[from_len]))) {
-
- new_key_len = key_len + to_len - from_len;
- new_str_key = emalloc(new_key_len+1);
- memcpy(new_str_key, resource_to->path + 1, to_len);
- memcpy(new_str_key + to_len, str_key + from_len, key_len - from_len);
- new_str_key[new_key_len] = 0;
-
- zend_hash_update_current_key_ex(&phar->virtual_dirs, key_type, new_str_key, new_key_len, 0, HASH_UPDATE_KEY_ANYWAY, NULL);
- efree(new_str_key);
+ } ZEND_HASH_FOREACH_END();
+ zend_hash_rehash(&phar->manifest);
+
+ ZEND_HASH_FOREACH_BUCKET(&phar->virtual_dirs, b) {
+ str_key = b->key;
+ if (ZSTR_LEN(str_key) >= from_len &&
+ memcmp(ZSTR_VAL(str_key), resource_from->path+1, from_len) == 0 &&
+ (ZSTR_LEN(str_key) == from_len || IS_SLASH(ZSTR_VAL(str_key)[from_len]))) {
+
+ new_str_key = zend_string_alloc(ZSTR_LEN(str_key) + to_len - from_len, 0);
+ memcpy(ZSTR_VAL(new_str_key), resource_to->path + 1, to_len);
+ memcpy(ZSTR_VAL(new_str_key) + to_len, ZSTR_VAL(str_key) + from_len, ZSTR_LEN(str_key) - from_len);
+ ZSTR_VAL(new_str_key)[ZSTR_LEN(new_str_key)] = 0;
+
+ zend_string_release(str_key);
+ b->h = zend_string_hash_val(new_str_key);
+ b->key = new_str_key;
}
- }
-
- for (zend_hash_internal_pointer_reset(&phar->mounted_dirs);
- HASH_KEY_NON_EXISTENT != (key_type = zend_hash_get_current_key_ex(&phar->mounted_dirs, &str_key, &key_len, &unused, 0, NULL)) &&
- SUCCESS == zend_hash_get_current_data(&phar->mounted_dirs, (void **) &entry);
- zend_hash_move_forward(&phar->mounted_dirs)
- ) {
- if (key_len >= from_len &&
- memcmp(str_key, resource_from->path+1, from_len) == 0 &&
- (key_len == from_len || IS_SLASH(str_key[from_len]))) {
-
- new_key_len = key_len + to_len - from_len;
- new_str_key = emalloc(new_key_len+1);
- memcpy(new_str_key, resource_to->path + 1, to_len);
- memcpy(new_str_key + to_len, str_key + from_len, key_len - from_len);
- new_str_key[new_key_len] = 0;
-
- zend_hash_update_current_key_ex(&phar->mounted_dirs, key_type, new_str_key, new_key_len, 0, HASH_UPDATE_KEY_ANYWAY, NULL);
- efree(new_str_key);
+ } ZEND_HASH_FOREACH_END();
+ zend_hash_rehash(&phar->virtual_dirs);
+
+ ZEND_HASH_FOREACH_BUCKET(&phar->mounted_dirs, b) {
+ str_key = b->key;
+ if (ZSTR_LEN(str_key) >= from_len &&
+ memcmp(ZSTR_VAL(str_key), resource_from->path+1, from_len) == 0 &&
+ (ZSTR_LEN(str_key) == from_len || IS_SLASH(ZSTR_VAL(str_key)[from_len]))) {
+
+ new_str_key = zend_string_alloc(ZSTR_LEN(str_key) + to_len - from_len, 0);
+ memcpy(ZSTR_VAL(new_str_key), resource_to->path + 1, to_len);
+ memcpy(ZSTR_VAL(new_str_key) + to_len, ZSTR_VAL(str_key) + from_len, ZSTR_LEN(str_key) - from_len);
+ ZSTR_VAL(new_str_key)[ZSTR_LEN(new_str_key)] = 0;
+
+ zend_string_release(str_key);
+ b->h = zend_string_hash_val(new_str_key);
+ b->key = new_str_key;
}
- }
+ } ZEND_HASH_FOREACH_END();
+ zend_hash_rehash(&phar->mounted_dirs);
}
if (is_modified) {
- phar_flush(phar, 0, 0, 0, &error TSRMLS_CC);
+ phar_flush(phar, 0, 0, 0, &error);
if (error) {
php_url_free(resource_from);
php_url_free(resource_to);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": %s", url_from, url_to, error);
+ php_error_docref(NULL, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": %s", url_from, url_to, error);
efree(error);
return 0;
}
diff --git a/ext/phar/stream.h b/ext/phar/stream.h
index 02d6a36eb2..ecdf7eb56f 100644
--- a/ext/phar/stream.h
+++ b/ext/phar/stream.h
@@ -21,21 +21,21 @@
BEGIN_EXTERN_C()
-php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const char *mode, int options TSRMLS_DC);
-void phar_entry_remove(phar_entry_data *idata, char **error TSRMLS_DC);
+php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const char *mode, int options);
+void phar_entry_remove(phar_entry_data *idata, char **error);
-static php_stream* phar_wrapper_open_url(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
-static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from, const char *url_to, int options, php_stream_context *context TSRMLS_DC);
-static int phar_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context TSRMLS_DC);
-static int phar_wrapper_stat(php_stream_wrapper *wrapper, const char *url, int flags, php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC);
+static php_stream* phar_wrapper_open_url(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC);
+static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from, const char *url_to, int options, php_stream_context *context);
+static int phar_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context);
+static int phar_wrapper_stat(php_stream_wrapper *wrapper, const char *url, int flags, php_stream_statbuf *ssb, php_stream_context *context);
/* file/stream handlers */
-static size_t phar_stream_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC);
-static size_t phar_stream_read( php_stream *stream, char *buf, size_t count TSRMLS_DC);
-static int phar_stream_close(php_stream *stream, int close_handle TSRMLS_DC);
-static int phar_stream_flush(php_stream *stream TSRMLS_DC);
-static int phar_stream_seek( php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC);
-static int phar_stream_stat( php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC);
+static size_t phar_stream_write(php_stream *stream, const char *buf, size_t count);
+static size_t phar_stream_read( php_stream *stream, char *buf, size_t count);
+static int phar_stream_close(php_stream *stream, int close_handle);
+static int phar_stream_flush(php_stream *stream);
+static int phar_stream_seek( php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffset);
+static int phar_stream_stat( php_stream *stream, php_stream_statbuf *ssb);
END_EXTERN_C()
/*
diff --git a/ext/phar/stub.h b/ext/phar/stub.h
index 28251420c3..139ac5da57 100644
--- a/ext/phar/stub.h
+++ b/ext/phar/stub.h
@@ -18,7 +18,7 @@
/* $Id$ */
-static inline void phar_get_stub(const char *index_php, const char *web, size_t *len, char **stub, const int name_len, const int web_len TSRMLS_DC)
+static inline zend_string* phar_get_stub(const char *index_php, const char *web, const int name_len, const int web_len)
{
static const char newstub0[] = "<?php\n\n$web = '";
static const char newstub1_0[] = "';\n\nif (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {\nPhar::interceptFileFuncs();\nset_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());\nPhar::webPhar(null, $web);\ninclude 'phar://' . __FILE__ . '/' . Extract_Phar::START;\nreturn;\n}\n\nif (@(isset($_SERVER['REQUEST_URI']) && isset($_SERVER['REQUEST_METHOD']) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'POST'))) {\nExtract_Phar::go(true);\n$mimes = array(\n'phps' => 2,\n'c' => 'text/plain',\n'cc' => 'text/plain',\n'cpp' => 'text/plain',\n'c++' => 'text/plain',\n'dtd' => 'text/plain',\n'h' => 'text/plain',\n'log' => 'text/plain',\n'rng' => 'text/plain',\n'txt' => 'text/plain',\n'xsd' => 'text/plain',\n'php' => 1,\n'inc' => 1,\n'avi' => 'video/avi',\n'bmp' => 'image/bmp',\n'css' => 'text/css',\n'gif' => 'image/gif',\n'htm' => 'text/html',\n'html' => 'text/html',\n'htmls' => 'text/html',\n'ico' => 'image/x-ico',\n'jpe' => 'image/jpeg',\n'jpg' => 'image/jpeg',\n'jpeg' => 'image/jpeg',\n'js' => 'application/x-javascript',\n'midi' => 'audio/midi',\n'mid' => 'audio/midi',\n'mod' => 'audio/mod',\n'mov' => 'movie/quicktime',\n'mp3' => 'audio/mp3',\n'mpg' => 'video/mpeg',\n'mpeg' => 'video/mpeg',\n'pdf' => 'application/pdf',\n'png' => 'image/png',\n'swf' => 'application/shockwave-flash',\n'tif' => 'image/tiff',\n'tiff' => 'image/tiff',\n'wav' => 'audio/wav',\n'xbm' => 'image/xbm',\n'xml' => 'text/xml',\n);\n\nheader(\"Cache-Control: no-cache, must-revalidate\");\nheader(\"Pragma: no-cache\");\n\n$basename = basename(__FILE__);\nif (!strpos($_SERVER['REQUEST_URI'], $basename)) {\nchdir(Extract_Phar::$temp);\ninclude $web;\nreturn;\n}\n$pt = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $basename) + strlen($basename));\nif (!$pt || $pt == '/') {\n$pt = $web;\nheader('HTTP/1.1 301 Moved Permanently');\nheader('Location: ' . $_SERVER['REQUEST_URI'] . '/' . $pt);\nexit;\n}\n$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);\nif (!$a || strlen(dirname($a)) < strlen(";
@@ -30,5 +30,5 @@ static inline void phar_get_stub(const char *index_php, const char *web, size_t
static const int newstub_len = 6665;
- *len = spprintf(stub, name_len + web_len + newstub_len, "%s%s%s%s%s%s%d%s%s%s", newstub0, web, newstub1_0, newstub1_1, index_php, newstub2, name_len + web_len + newstub_len, newstub3_0, newstub3_1, newstub3_2);
+ return strpprintf(name_len + web_len + newstub_len, "%s%s%s%s%s%s%d%s%s%s", newstub0, web, newstub1_0, newstub1_1, index_php, newstub2, name_len + web_len + newstub_len, newstub3_0, newstub3_1, newstub3_2);
}
diff --git a/ext/phar/tar.c b/ext/phar/tar.c
index 62edcb59f1..aeb5c7ef1e 100644
--- a/ext/phar/tar.c
+++ b/ext/phar/tar.c
@@ -124,10 +124,10 @@ int phar_is_tar(char *buf, char *fname) /* {{{ */
}
/* }}} */
-int phar_open_or_create_tar(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC) /* {{{ */
+int phar_open_or_create_tar(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error) /* {{{ */
{
phar_archive_data *phar;
- int ret = phar_create_or_parse_filename(fname, fname_len, alias, alias_len, is_data, options, &phar, error TSRMLS_CC);
+ int ret = phar_create_or_parse_filename(fname, fname_len, alias, alias_len, is_data, options, &phar, error);
if (FAILURE == ret) {
return FAILURE;
@@ -158,7 +158,7 @@ int phar_open_or_create_tar(char *fname, int fname_len, char *alias, int alias_l
}
/* }}} */
-static int phar_tar_process_metadata(phar_entry_info *entry, php_stream *fp TSRMLS_DC) /* {{{ */
+static int phar_tar_process_metadata(phar_entry_info *entry, php_stream *fp) /* {{{ */
{
char *metadata;
size_t save = php_stream_tell(fp), read;
@@ -173,7 +173,7 @@ static int phar_tar_process_metadata(phar_entry_info *entry, php_stream *fp TSRM
return FAILURE;
}
- if (phar_parse_metadata(&metadata, &entry->metadata, entry->uncompressed_filesize TSRMLS_CC) == FAILURE) {
+ if (phar_parse_metadata(&metadata, &entry->metadata, entry->uncompressed_filesize) == FAILURE) {
/* if not valid serialized data, it is a regular string */
efree(metadata);
php_stream_seek(fp, save, SEEK_SET);
@@ -182,11 +182,11 @@ static int phar_tar_process_metadata(phar_entry_info *entry, php_stream *fp TSRM
if (entry->filename_len == sizeof(".phar/.metadata.bin")-1 && !memcmp(entry->filename, ".phar/.metadata.bin", sizeof(".phar/.metadata.bin")-1)) {
entry->phar->metadata = entry->metadata;
- entry->metadata = NULL;
- } else if (entry->filename_len >= sizeof(".phar/.metadata/") + sizeof("/.metadata.bin") - 1 && SUCCESS == zend_hash_find(&(entry->phar->manifest), entry->filename + sizeof(".phar/.metadata/") - 1, entry->filename_len - (sizeof("/.metadata.bin") - 1 + sizeof(".phar/.metadata/") - 1), (void *)&mentry)) {
+ ZVAL_UNDEF(&entry->metadata);
+ } else if (entry->filename_len >= sizeof(".phar/.metadata/") + sizeof("/.metadata.bin") - 1 && NULL != (mentry = zend_hash_str_find_ptr(&(entry->phar->manifest), entry->filename + sizeof(".phar/.metadata/") - 1, entry->filename_len - (sizeof("/.metadata.bin") - 1 + sizeof(".phar/.metadata/") - 1)))) {
/* transfer this metadata to the entry it refers */
mentry->metadata = entry->metadata;
- entry->metadata = NULL;
+ ZVAL_UNDEF(&entry->metadata);
}
efree(metadata);
@@ -202,14 +202,14 @@ static size_t strnlen(const char *s, size_t maxlen) {
}
#endif
-int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char *alias, int alias_len, phar_archive_data** pphar, int is_data, php_uint32 compression, char **error TSRMLS_DC) /* {{{ */
+int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char *alias, int alias_len, phar_archive_data** pphar, int is_data, php_uint32 compression, char **error) /* {{{ */
{
char buf[512], *actual_alias = NULL, *p;
phar_entry_info entry = {0};
size_t pos = 0, read, totalsize;
tar_header *hdr;
php_uint32 sum1, sum2, size, old;
- phar_archive_data *myphar, **actual;
+ phar_archive_data *myphar, *actual;
int last_was_longlink = 0;
int linkname_len;
@@ -273,7 +273,7 @@ int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char *alias,
}
if (((!old && hdr->prefix[0] == 0) || old) && strnlen(hdr->name, 100) == sizeof(".phar/signature.bin")-1 && !strncmp(hdr->name, ".phar/signature.bin", sizeof(".phar/signature.bin")-1)) {
- off_t curloc;
+ zend_off_t curloc;
if (size > 511) {
if (error) {
@@ -281,7 +281,7 @@ int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char *alias,
}
bail:
php_stream_close(fp);
- phar_destroy_phar_data(myphar TSRMLS_CC);
+ phar_destroy_phar_data(myphar);
return FAILURE;
}
curloc = php_stream_tell(fp);
@@ -302,7 +302,7 @@ bail:
# define PHAR_GET_32(buffer) (php_uint32) *(buffer)
#endif
myphar->sig_flags = PHAR_GET_32(buf);
- if (FAILURE == phar_verify_signature(fp, php_stream_tell(fp) - size - 512, myphar->sig_flags, buf + 8, size - 8, fname, &myphar->signature, &myphar->sig_len, error TSRMLS_CC)) {
+ if (FAILURE == phar_verify_signature(fp, php_stream_tell(fp) - size - 512, myphar->sig_flags, buf + 8, size - 8, fname, &myphar->signature, &myphar->sig_len, error)) {
if (error) {
char *save = *error;
spprintf(error, 4096, "phar error: tar-based phar \"%s\" signature cannot be verified: %s", fname, save);
@@ -320,7 +320,7 @@ bail:
spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (truncated)", fname);
}
php_stream_close(fp);
- phar_destroy_phar_data(myphar TSRMLS_CC);
+ phar_destroy_phar_data(myphar);
return FAILURE;
}
}
@@ -332,7 +332,7 @@ bail:
spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (truncated)", fname);
}
php_stream_close(fp);
- phar_destroy_phar_data(myphar TSRMLS_CC);
+ phar_destroy_phar_data(myphar);
return FAILURE;
}
@@ -361,7 +361,7 @@ bail:
spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (invalid entry size)", fname);
}
php_stream_close(fp);
- phar_destroy_phar_data(myphar TSRMLS_CC);
+ phar_destroy_phar_data(myphar);
return FAILURE;
}
entry.filename = pemalloc(entry.filename_len+1, myphar->is_persistent);
@@ -373,7 +373,7 @@ bail:
spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (truncated)", fname);
}
php_stream_close(fp);
- phar_destroy_phar_data(myphar TSRMLS_CC);
+ phar_destroy_phar_data(myphar);
return FAILURE;
}
entry.filename[entry.filename_len] = '\0';
@@ -389,7 +389,7 @@ bail:
spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (truncated)", fname);
}
php_stream_close(fp);
- phar_destroy_phar_data(myphar TSRMLS_CC);
+ phar_destroy_phar_data(myphar);
return FAILURE;
}
@@ -401,7 +401,7 @@ bail:
spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (truncated)", fname);
}
php_stream_close(fp);
- phar_destroy_phar_data(myphar TSRMLS_CC);
+ phar_destroy_phar_data(myphar);
return FAILURE;
}
continue;
@@ -450,7 +450,7 @@ bail:
}
last_was_longlink = 0;
- phar_add_virtual_dirs(myphar, entry.filename, entry.filename_len TSRMLS_CC);
+ phar_add_virtual_dirs(myphar, entry.filename, entry.filename_len);
if (sum1 != sum2) {
if (error) {
@@ -458,7 +458,7 @@ bail:
}
pefree(entry.filename, myphar->is_persistent);
php_stream_close(fp);
- phar_destroy_phar_data(myphar TSRMLS_CC);
+ phar_destroy_phar_data(myphar);
return FAILURE;
}
@@ -468,9 +468,7 @@ bail:
entry.flags = phar_tar_number(hdr->mode, sizeof(hdr->mode)) & PHAR_ENT_PERM_MASK;
entry.timestamp = phar_tar_number(hdr->mtime, sizeof(hdr->mtime));
entry.is_persistent = myphar->is_persistent;
-#ifndef S_ISDIR
-#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
-#endif
+
if (old && entry.tar_type == TAR_FILE && S_ISDIR(entry.flags)) {
entry.tar_type = TAR_DIR;
}
@@ -486,22 +484,22 @@ bail:
* Thus we can not use strlen. */
linkname_len = strnlen(hdr->linkname, 100);
if (entry.tar_type == TAR_LINK) {
- if (!zend_hash_exists(&myphar->manifest, hdr->linkname, linkname_len)) {
+ if (!zend_hash_str_exists(&myphar->manifest, hdr->linkname, linkname_len)) {
if (error) {
spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file - hard link to non-existent file \"%.*s\"", fname, linkname_len, hdr->linkname);
}
pefree(entry.filename, entry.is_persistent);
php_stream_close(fp);
- phar_destroy_phar_data(myphar TSRMLS_CC);
+ phar_destroy_phar_data(myphar);
return FAILURE;
}
entry.link = estrndup(hdr->linkname, linkname_len);
} else if (entry.tar_type == TAR_SYMLINK) {
entry.link = estrndup(hdr->linkname, linkname_len);
}
- phar_set_inode(&entry TSRMLS_CC);
+ phar_set_inode(&entry);
- zend_hash_update(&myphar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info), (void **) &newentry);
+ newentry = zend_hash_str_update_mem(&myphar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info));
ZEND_ASSERT(newentry != NULL);
if (entry.is_persistent) {
@@ -509,12 +507,12 @@ bail:
}
if (entry.filename_len >= sizeof(".phar/.metadata")-1 && !memcmp(entry.filename, ".phar/.metadata", sizeof(".phar/.metadata")-1)) {
- if (FAILURE == phar_tar_process_metadata(newentry, fp TSRMLS_CC)) {
+ if (FAILURE == phar_tar_process_metadata(newentry, fp)) {
if (error) {
spprintf(error, 4096, "phar error: tar-based phar \"%s\" has invalid metadata in magic file \"%s\"", fname, entry.filename);
}
php_stream_close(fp);
- phar_destroy_phar_data(myphar TSRMLS_CC);
+ phar_destroy_phar_data(myphar);
return FAILURE;
}
}
@@ -526,7 +524,7 @@ bail:
spprintf(error, 4096, "phar error: tar-based phar \"%s\" has alias that is larger than 511 bytes, cannot process", fname);
}
php_stream_close(fp);
- phar_destroy_phar_data(myphar TSRMLS_CC);
+ phar_destroy_phar_data(myphar);
return FAILURE;
}
@@ -547,7 +545,7 @@ bail:
}
php_stream_close(fp);
- phar_destroy_phar_data(myphar TSRMLS_CC);
+ phar_destroy_phar_data(myphar);
return FAILURE;
}
@@ -561,7 +559,7 @@ bail:
}
php_stream_close(fp);
- phar_destroy_phar_data(myphar TSRMLS_CC);
+ phar_destroy_phar_data(myphar);
return FAILURE;
}
}
@@ -577,7 +575,7 @@ next:
spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (truncated)", fname);
}
php_stream_close(fp);
- phar_destroy_phar_data(myphar TSRMLS_CC);
+ phar_destroy_phar_data(myphar);
return FAILURE;
}
}
@@ -589,12 +587,12 @@ next:
spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (truncated)", fname);
}
php_stream_close(fp);
- phar_destroy_phar_data(myphar TSRMLS_CC);
+ phar_destroy_phar_data(myphar);
return FAILURE;
}
- } while (read != 0);
+ } while (!php_stream_eof(fp));
- if (zend_hash_exists(&(myphar->manifest), ".phar/stub.php", sizeof(".phar/stub.php")-1)) {
+ if (zend_hash_str_exists(&(myphar->manifest), ".phar/stub.php", sizeof(".phar/stub.php")-1)) {
myphar->is_data = 0;
} else {
myphar->is_data = 1;
@@ -603,7 +601,7 @@ next:
/* ensure signature set */
if (!myphar->is_data && PHAR_G(require_hash) && !myphar->signature) {
php_stream_close(fp);
- phar_destroy_phar_data(myphar TSRMLS_CC);
+ phar_destroy_phar_data(myphar);
if (error) {
spprintf(error, 0, "tar-based phar \"%s\" does not have a signature", fname);
}
@@ -628,49 +626,49 @@ next:
}
}
- phar_request_initialize(TSRMLS_C);
+ phar_request_initialize();
- if (SUCCESS != zend_hash_add(&(PHAR_GLOBALS->phar_fname_map), myphar->fname, fname_len, (void*)&myphar, sizeof(phar_archive_data*), (void **)&actual)) {
+ if (NULL == (actual = zend_hash_str_add_ptr(&(PHAR_G(phar_fname_map)), myphar->fname, fname_len, myphar))) {
if (error) {
spprintf(error, 4096, "phar error: Unable to add tar-based phar \"%s\" to phar registry", fname);
}
php_stream_close(fp);
- phar_destroy_phar_data(myphar TSRMLS_CC);
+ phar_destroy_phar_data(myphar);
return FAILURE;
}
- myphar = *actual;
+ myphar = actual;
if (actual_alias) {
- phar_archive_data **fd_ptr;
+ phar_archive_data *fd_ptr;
myphar->is_temporary_alias = 0;
- if (SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), actual_alias, myphar->alias_len, (void **)&fd_ptr)) {
- if (SUCCESS != phar_free_alias(*fd_ptr, actual_alias, myphar->alias_len TSRMLS_CC)) {
+ if (NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), actual_alias, myphar->alias_len))) {
+ if (SUCCESS != phar_free_alias(fd_ptr, actual_alias, myphar->alias_len)) {
if (error) {
spprintf(error, 4096, "phar error: Unable to add tar-based phar \"%s\", alias is already in use", fname);
}
- zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), myphar->fname, fname_len);
+ zend_hash_str_del(&(PHAR_G(phar_fname_map)), myphar->fname, fname_len);
return FAILURE;
}
}
- zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), actual_alias, myphar->alias_len, (void*)&myphar, sizeof(phar_archive_data*), NULL);
+ zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), actual_alias, myphar->alias_len, myphar);
} else {
- phar_archive_data **fd_ptr;
+ phar_archive_data *fd_ptr;
if (alias_len) {
- if (SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void **)&fd_ptr)) {
- if (SUCCESS != phar_free_alias(*fd_ptr, alias, alias_len TSRMLS_CC)) {
+ if (NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len))) {
+ if (SUCCESS != phar_free_alias(fd_ptr, alias, alias_len)) {
if (error) {
spprintf(error, 4096, "phar error: Unable to add tar-based phar \"%s\", alias is already in use", fname);
}
- zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), myphar->fname, fname_len);
+ zend_hash_str_del(&(PHAR_G(phar_fname_map)), myphar->fname, fname_len);
return FAILURE;
}
}
- zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void*)&myphar, sizeof(phar_archive_data*), NULL);
+ zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len, myphar);
myphar->alias = pestrndup(alias, alias_len, myphar->is_persistent);
myphar->alias_len = alias_len;
} else {
@@ -697,11 +695,10 @@ struct _phar_pass_tar_info {
char **error;
};
-static int phar_tar_writeheaders(void *pDest, void *argument TSRMLS_DC) /* {{{ */
+static int phar_tar_writeheaders_int(phar_entry_info *entry, void *argument) /* {{{ */
{
tar_header header;
size_t pos;
- phar_entry_info *entry = (phar_entry_info *) pDest;
struct _phar_pass_tar_info *fp = (struct _phar_pass_tar_info *)argument;
char padding[512];
@@ -718,7 +715,7 @@ static int phar_tar_writeheaders(void *pDest, void *argument TSRMLS_DC) /* {{{ *
}
}
- phar_add_virtual_dirs(entry->phar, entry->filename, entry->filename_len TSRMLS_CC);
+ phar_add_virtual_dirs(entry->phar, entry->filename, entry->filename_len);
memset((char *) &header, 0, sizeof(header));
if (entry->filename_len > 100) {
@@ -794,18 +791,18 @@ static int phar_tar_writeheaders(void *pDest, void *argument TSRMLS_DC) /* {{{ *
/* write contents */
if (entry->uncompressed_filesize) {
- if (FAILURE == phar_open_entry_fp(entry, fp->error, 0 TSRMLS_CC)) {
+ if (FAILURE == phar_open_entry_fp(entry, fp->error, 0)) {
return ZEND_HASH_APPLY_STOP;
}
- if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0 TSRMLS_CC)) {
+ if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0)) {
if (fp->error) {
spprintf(fp->error, 4096, "tar-based phar \"%s\" cannot be created, contents of file \"%s\" could not be written, seek failed", entry->phar->fname, entry->filename);
}
return ZEND_HASH_APPLY_STOP;
}
- if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, 0 TSRMLS_CC), fp->new, entry->uncompressed_filesize, NULL)) {
+ if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, 0), fp->new, entry->uncompressed_filesize, NULL)) {
if (fp->error) {
spprintf(fp->error, 4096, "tar-based phar \"%s\" cannot be created, contents of file \"%s\" could not be written", entry->phar->fname, entry->filename);
}
@@ -846,20 +843,25 @@ static int phar_tar_writeheaders(void *pDest, void *argument TSRMLS_DC) /* {{{ *
}
/* }}} */
-int phar_tar_setmetadata(zval *metadata, phar_entry_info *entry, char **error TSRMLS_DC) /* {{{ */
+static int phar_tar_writeheaders(zval *zv, void *argument) /* {{{ */
+{
+ return phar_tar_writeheaders_int(Z_PTR_P(zv), argument);
+}
+/* }}} */
+
+int phar_tar_setmetadata(zval *metadata, phar_entry_info *entry, char **error) /* {{{ */
{
php_serialize_data_t metadata_hash;
- if (entry->metadata_str.c) {
+ if (entry->metadata_str.s) {
smart_str_free(&entry->metadata_str);
}
- entry->metadata_str.c = 0;
- entry->metadata_str.len = 0;
+ entry->metadata_str.s = NULL;
PHP_VAR_SERIALIZE_INIT(metadata_hash);
- php_var_serialize(&entry->metadata_str, &metadata, &metadata_hash TSRMLS_CC);
+ php_var_serialize(&entry->metadata_str, metadata, &metadata_hash);
PHP_VAR_SERIALIZE_DESTROY(metadata_hash);
- entry->uncompressed_filesize = entry->compressed_filesize = entry->metadata_str.len;
+ entry->uncompressed_filesize = entry->compressed_filesize = entry->metadata_str.s ? ZSTR_LEN(entry->metadata_str.s) : 0;
if (entry->fp && entry->fp_type == PHAR_MOD) {
php_stream_close(entry->fp);
@@ -873,9 +875,9 @@ int phar_tar_setmetadata(zval *metadata, phar_entry_info *entry, char **error TS
spprintf(error, 0, "phar error: unable to create temporary file");
return -1;
}
- if (entry->metadata_str.len != php_stream_write(entry->fp, entry->metadata_str.c, entry->metadata_str.len)) {
+ if (ZSTR_LEN(entry->metadata_str.s) != php_stream_write(entry->fp, ZSTR_VAL(entry->metadata_str.s), ZSTR_LEN(entry->metadata_str.s))) {
spprintf(error, 0, "phar tar error: unable to write metadata to magic metadata file \"%s\"", entry->filename);
- zend_hash_del(&(entry->phar->manifest), entry->filename, entry->filename_len);
+ zend_hash_str_del(&(entry->phar->manifest), entry->filename, entry->filename_len);
return ZEND_HASH_APPLY_STOP;
}
@@ -883,22 +885,19 @@ int phar_tar_setmetadata(zval *metadata, phar_entry_info *entry, char **error TS
}
/* }}} */
-static int phar_tar_setupmetadata(void *pDest, void *argument TSRMLS_DC) /* {{{ */
+static int phar_tar_setupmetadata(zval *zv, void *argument) /* {{{ */
{
int lookfor_len;
struct _phar_pass_tar_info *i = (struct _phar_pass_tar_info *)argument;
char *lookfor, **error = i->error;
- phar_entry_info *entry = (phar_entry_info *)pDest, *metadata, newentry = {0};
+ phar_entry_info *entry = (phar_entry_info *)Z_PTR_P(zv), *metadata, newentry = {0};
if (entry->filename_len >= sizeof(".phar/.metadata") && !memcmp(entry->filename, ".phar/.metadata", sizeof(".phar/.metadata")-1)) {
if (entry->filename_len == sizeof(".phar/.metadata.bin")-1 && !memcmp(entry->filename, ".phar/.metadata.bin", sizeof(".phar/.metadata.bin")-1)) {
- if (entry->phar->metadata == NULL) {
- return ZEND_HASH_APPLY_REMOVE;
- }
- return phar_tar_setmetadata(entry->phar->metadata, entry, error TSRMLS_CC);
+ return phar_tar_setmetadata(&entry->phar->metadata, entry, error);
}
/* search for the file this metadata entry references */
- if (entry->filename_len >= sizeof(".phar/.metadata/") + sizeof("/.metadata.bin") - 1 && !zend_hash_exists(&(entry->phar->manifest), entry->filename + sizeof(".phar/.metadata/") - 1, entry->filename_len - (sizeof("/.metadata.bin") - 1 + sizeof(".phar/.metadata/") - 1))) {
+ if (entry->filename_len >= sizeof(".phar/.metadata/") + sizeof("/.metadata.bin") - 1 && !zend_hash_str_exists(&(entry->phar->manifest), entry->filename + sizeof(".phar/.metadata/") - 1, entry->filename_len - (sizeof("/.metadata.bin") - 1 + sizeof(".phar/.metadata/") - 1))) {
/* this is orphaned metadata, erase it */
return ZEND_HASH_APPLY_REMOVE;
}
@@ -913,15 +912,15 @@ static int phar_tar_setupmetadata(void *pDest, void *argument TSRMLS_DC) /* {{{
/* now we are dealing with regular files, so look for metadata */
lookfor_len = spprintf(&lookfor, 0, ".phar/.metadata/%s/.metadata.bin", entry->filename);
- if (!entry->metadata) {
- zend_hash_del(&(entry->phar->manifest), lookfor, lookfor_len);
+ if (Z_TYPE(entry->metadata) == IS_UNDEF) {
+ zend_hash_str_del(&(entry->phar->manifest), lookfor, lookfor_len);
efree(lookfor);
return ZEND_HASH_APPLY_KEEP;
}
- if (SUCCESS == zend_hash_find(&(entry->phar->manifest), lookfor, lookfor_len, (void **)&metadata)) {
+ if (NULL != (metadata = zend_hash_str_find_ptr(&(entry->phar->manifest), lookfor, lookfor_len))) {
int ret;
- ret = phar_tar_setmetadata(entry->metadata, metadata, error TSRMLS_CC);
+ ret = phar_tar_setmetadata(&entry->metadata, metadata, error);
efree(lookfor);
return ret;
}
@@ -932,17 +931,17 @@ static int phar_tar_setupmetadata(void *pDest, void *argument TSRMLS_DC) /* {{{
newentry.tar_type = TAR_FILE;
newentry.is_tar = 1;
- if (SUCCESS != zend_hash_add(&(entry->phar->manifest), lookfor, lookfor_len, (void *)&newentry, sizeof(phar_entry_info), (void **)&metadata)) {
+ if (NULL == (metadata = zend_hash_str_add_mem(&(entry->phar->manifest), lookfor, lookfor_len, (void *)&newentry, sizeof(phar_entry_info)))) {
efree(lookfor);
spprintf(error, 0, "phar tar error: unable to add magic metadata file to manifest for file \"%s\"", entry->filename);
return ZEND_HASH_APPLY_STOP;
}
- return phar_tar_setmetadata(entry->metadata, metadata, error TSRMLS_CC);
+ return phar_tar_setmetadata(&entry->metadata, metadata, error);
}
/* }}} */
-int phar_tar_flush(phar_archive_data *phar, char *user_stub, long len, int defaultstub, char **error TSRMLS_DC) /* {{{ */
+int phar_tar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int defaultstub, char **error) /* {{{ */
{
phar_entry_info entry = {0};
static const char newstub[] = "<?php // tar-based phar archive stub file\n__HALT_COMPILER();";
@@ -990,14 +989,14 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, long len, int defau
entry.uncompressed_filesize = phar->alias_len;
- if (SUCCESS != zend_hash_update(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info), NULL)) {
+ if (NULL == zend_hash_str_update_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info))) {
if (error) {
spprintf(error, 0, "unable to set alias in tar-based phar \"%s\"", phar->fname);
}
return EOF;
}
} else {
- zend_hash_del(&phar->manifest, ".phar/alias.txt", sizeof(".phar/alias.txt")-1);
+ zend_hash_str_del(&phar->manifest, ".phar/alias.txt", sizeof(".phar/alias.txt")-1);
}
/* set stub */
@@ -1005,7 +1004,7 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, long len, int defau
char *pos;
if (len < 0) {
/* resource passed in */
- if (!(php_stream_from_zval_no_verify(stubfile, (zval **)user_stub))) {
+ if (!(php_stream_from_zval_no_verify(stubfile, (zval *)user_stub))) {
if (error) {
spprintf(error, 0, "unable to access resource to copy stub to new tar-based phar \"%s\"", phar->fname);
}
@@ -1018,7 +1017,21 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, long len, int defau
}
user_stub = 0;
- if (!(len = php_stream_copy_to_mem(stubfile, &user_stub, len, 0)) || !user_stub) {
+ // TODO: refactor to avoid reallocation ???
+//??? len = php_stream_copy_to_mem(stubfile, &user_stub, len, 0)
+ {
+ zend_string *str = php_stream_copy_to_mem(stubfile, len, 0);
+ if (str) {
+ len = ZSTR_LEN(str);
+ user_stub = estrndup(ZSTR_VAL(str), ZSTR_LEN(str));
+ zend_string_release(str);
+ } else {
+ user_stub = NULL;
+ len = 0;
+ }
+ }
+
+ if (!len || !user_stub) {
if (error) {
spprintf(error, 0, "unable to read resource to copy stub to new tar-based phar \"%s\"", phar->fname);
}
@@ -1065,7 +1078,7 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, long len, int defau
entry.filename = estrndup(".phar/stub.php", sizeof(".phar/stub.php")-1);
entry.filename_len = sizeof(".phar/stub.php")-1;
- zend_hash_update(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info), NULL);
+ zend_hash_str_update_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info));
if (free_user_stub) {
efree(user_stub);
@@ -1090,8 +1103,8 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, long len, int defau
entry.filename_len = sizeof(".phar/stub.php")-1;
if (!defaultstub) {
- if (!zend_hash_exists(&phar->manifest, ".phar/stub.php", sizeof(".phar/stub.php")-1)) {
- if (SUCCESS != zend_hash_add(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info), NULL)) {
+ if (!zend_hash_str_exists(&phar->manifest, ".phar/stub.php", sizeof(".phar/stub.php")-1)) {
+ if (NULL == zend_hash_str_add_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info))) {
php_stream_close(entry.fp);
efree(entry.filename);
if (error) {
@@ -1104,7 +1117,7 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, long len, int defau
efree(entry.filename);
}
} else {
- if (SUCCESS != zend_hash_update(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info), NULL)) {
+ if (NULL == zend_hash_str_update_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info))) {
php_stream_close(entry.fp);
efree(entry.filename);
if (error) {
@@ -1141,10 +1154,10 @@ nostub:
pass.free_fp = 1;
pass.free_ufp = 1;
- if (phar->metadata) {
+ if (Z_TYPE(phar->metadata) != IS_UNDEF) {
phar_entry_info *mentry;
- if (SUCCESS == zend_hash_find(&(phar->manifest), ".phar/.metadata.bin", sizeof(".phar/.metadata.bin")-1, (void **)&mentry)) {
- if (ZEND_HASH_APPLY_KEEP != phar_tar_setmetadata(phar->metadata, mentry, error TSRMLS_CC)) {
+ if (NULL != (mentry = zend_hash_str_find_ptr(&(phar->manifest), ".phar/.metadata.bin", sizeof(".phar/.metadata.bin")-1))) {
+ if (ZEND_HASH_APPLY_KEEP != phar_tar_setmetadata(&phar->metadata, mentry, error)) {
if (closeoldfile) {
php_stream_close(oldfile);
}
@@ -1159,7 +1172,7 @@ nostub:
newentry.tar_type = TAR_FILE;
newentry.is_tar = 1;
- if (SUCCESS != zend_hash_add(&(phar->manifest), ".phar/.metadata.bin", sizeof(".phar/.metadata.bin")-1, (void *)&newentry, sizeof(phar_entry_info), (void **)&mentry)) {
+ if (NULL == (mentry = zend_hash_str_add_mem(&(phar->manifest), ".phar/.metadata.bin", sizeof(".phar/.metadata.bin")-1, (void *)&newentry, sizeof(phar_entry_info)))) {
spprintf(error, 0, "phar tar error: unable to add magic metadata file to manifest for phar archive \"%s\"", phar->fname);
if (closeoldfile) {
php_stream_close(oldfile);
@@ -1167,8 +1180,8 @@ nostub:
return EOF;
}
- if (ZEND_HASH_APPLY_KEEP != phar_tar_setmetadata(phar->metadata, mentry, error TSRMLS_CC)) {
- zend_hash_del(&(phar->manifest), ".phar/.metadata.bin", sizeof(".phar/.metadata.bin")-1);
+ if (ZEND_HASH_APPLY_KEEP != phar_tar_setmetadata(&phar->metadata, mentry, error)) {
+ zend_hash_str_del(&(phar->manifest), ".phar/.metadata.bin", sizeof(".phar/.metadata.bin")-1);
if (closeoldfile) {
php_stream_close(oldfile);
}
@@ -1177,7 +1190,7 @@ nostub:
}
}
- zend_hash_apply_with_argument(&phar->manifest, (apply_func_arg_t) phar_tar_setupmetadata, (void *) &pass TSRMLS_CC);
+ zend_hash_apply_with_argument(&phar->manifest, phar_tar_setupmetadata, (void *) &pass);
if (error && *error) {
if (closeoldfile) {
@@ -1189,11 +1202,11 @@ nostub:
return EOF;
}
- zend_hash_apply_with_argument(&phar->manifest, (apply_func_arg_t) phar_tar_writeheaders, (void *) &pass TSRMLS_CC);
+ zend_hash_apply_with_argument(&phar->manifest, phar_tar_writeheaders, (void *) &pass);
/* add signature for executable tars or tars explicitly set with setSignatureAlgorithm */
if (!phar->is_data || phar->sig_flags) {
- if (FAILURE == phar_create_signature(phar, newfile, &signature, &signature_length, error TSRMLS_CC)) {
+ if (FAILURE == phar_create_signature(phar, newfile, &signature, &signature_length, error)) {
if (error) {
char *save = *error;
spprintf(error, 0, "phar error: unable to write signature to tar-based phar: %s", save);
@@ -1243,7 +1256,7 @@ nostub:
efree(signature);
entry.uncompressed_filesize = entry.compressed_filesize = signature_length + 8;
/* throw out return value and write the signature */
- entry.filename_len = phar_tar_writeheaders((void *)&entry, (void *)&pass TSRMLS_CC);
+ entry.filename_len = phar_tar_writeheaders_int(&entry, (void *)&pass);
if (error && *error) {
if (closeoldfile) {
@@ -1308,7 +1321,7 @@ nostub:
#define MAX_WBITS 15
#endif
add_assoc_long(&filterparams, "window", MAX_WBITS + 16);
- filter = php_stream_filter_create("zlib.deflate", &filterparams, php_stream_is_persistent(phar->fp) TSRMLS_CC);
+ filter = php_stream_filter_create("zlib.deflate", &filterparams, php_stream_is_persistent(phar->fp));
zval_dtor(&filterparams);
if (!filter) {
@@ -1324,18 +1337,18 @@ nostub:
php_stream_filter_append(&phar->fp->writefilters, filter);
php_stream_copy_to_stream_ex(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL);
php_stream_filter_flush(filter, 1);
- php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ php_stream_filter_remove(filter, 1);
php_stream_close(phar->fp);
/* use the temp stream as our base */
phar->fp = newfile;
} else if (phar->flags & PHAR_FILE_COMPRESSED_BZ2) {
php_stream_filter *filter;
- filter = php_stream_filter_create("bzip2.compress", NULL, php_stream_is_persistent(phar->fp) TSRMLS_CC);
+ filter = php_stream_filter_create("bzip2.compress", NULL, php_stream_is_persistent(phar->fp));
php_stream_filter_append(&phar->fp->writefilters, filter);
php_stream_copy_to_stream_ex(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL);
php_stream_filter_flush(filter, 1);
- php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ php_stream_filter_remove(filter, 1);
php_stream_close(phar->fp);
/* use the temp stream as our base */
phar->fp = newfile;
diff --git a/ext/phar/tests/017.phpt b/ext/phar/tests/017.phpt
index 7c64c401c8..fdbb3be17b 100644
--- a/ext/phar/tests/017.phpt
+++ b/ext/phar/tests/017.phpt
@@ -3,7 +3,7 @@ Phar: opendir test - no dir specified at all
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/017U.phpt b/ext/phar/tests/017U.phpt
index af65b6d020..edcfcf4078 100644
--- a/ext/phar/tests/017U.phpt
+++ b/ext/phar/tests/017U.phpt
@@ -3,7 +3,7 @@ Phar: opendir test - no dir specified at all
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/018.phpt b/ext/phar/tests/018.phpt
index 2e2df470bf..5640cfb82c 100644
--- a/ext/phar/tests/018.phpt
+++ b/ext/phar/tests/018.phpt
@@ -3,7 +3,7 @@ Phar: opendir test, root directory
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/018U.phpt b/ext/phar/tests/018U.phpt
index c8d798df20..7d75e96b01 100644
--- a/ext/phar/tests/018U.phpt
+++ b/ext/phar/tests/018U.phpt
@@ -3,7 +3,7 @@ Phar: opendir test, root directory
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/019b.phpt b/ext/phar/tests/019b.phpt
index 5a0ef71335..7a22d8b4f6 100644
--- a/ext/phar/tests/019b.phpt
+++ b/ext/phar/tests/019b.phpt
@@ -3,7 +3,7 @@ Phar: opendir test, recurse into
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/019bU.phpt b/ext/phar/tests/019bU.phpt
index c0864aa2ce..eb3f07a1f8 100644
--- a/ext/phar/tests/019bU.phpt
+++ b/ext/phar/tests/019bU.phpt
@@ -3,7 +3,7 @@ Phar: opendir test, recurse into
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/019c.phpt b/ext/phar/tests/019c.phpt
index 2cb508c46c..d31981e914 100644
--- a/ext/phar/tests/019c.phpt
+++ b/ext/phar/tests/019c.phpt
@@ -3,7 +3,7 @@ Phar: opendir test, recurse into
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/019cU.phpt b/ext/phar/tests/019cU.phpt
index 36ef6d8208..6ea5cf285c 100644
--- a/ext/phar/tests/019cU.phpt
+++ b/ext/phar/tests/019cU.phpt
@@ -3,7 +3,7 @@ Phar: opendir test, recurse into
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/027.phpt b/ext/phar/tests/027.phpt
index 8736efbeb2..45837bfd1e 100644
--- a/ext/phar/tests/027.phpt
+++ b/ext/phar/tests/027.phpt
@@ -3,7 +3,7 @@ Phar: phar:// opendir
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/027U.phpt b/ext/phar/tests/027U.phpt
index 6794c5229e..598f969a59 100644
--- a/ext/phar/tests/027U.phpt
+++ b/ext/phar/tests/027U.phpt
@@ -3,7 +3,7 @@ Phar: phar:// opendir
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/badparameters.phpt b/ext/phar/tests/badparameters.phpt
index c33426e9d9..4d0887f66f 100644
--- a/ext/phar/tests/badparameters.phpt
+++ b/ext/phar/tests/badparameters.phpt
@@ -7,16 +7,37 @@ phar.readonly=0
--FILE--
<?php
ini_set('phar.readonly', 1);
+
+function print_exception($e) {
+ echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n";
+}
+
Phar::mungServer('hi');
Phar::createDefaultStub(array());
Phar::loadPhar(array());
Phar::canCompress('hi');
-$a = new Phar(array());
-$a = new Phar(dirname(__FILE__) . '/files/frontcontroller10.phar');
+try {
+ $a = new Phar(array());
+} catch (TypeError $e) {
+ print_exception($e);
+}
+try {
+ $a = new Phar(dirname(__FILE__) . '/files/frontcontroller10.phar');
+} catch (PharException $e) {
+ print_exception($e);
+}
$a->convertToExecutable(array());
$a->convertToData(array());
-$b = new PharData(dirname(__FILE__) . '/whatever.tar');
-$c = new PharData(dirname(__FILE__) . '/whatever.zip');
+try {
+ $b = new PharData(dirname(__FILE__) . '/whatever.tar');
+} catch (PharException $e) {
+ print_exception($e);
+}
+try {
+ $c = new PharData(dirname(__FILE__) . '/whatever.zip');
+} catch (PharException $e) {
+ print_exception($e);
+}
$b->delete(array());
try {
$a->delete('oops');
@@ -130,13 +151,13 @@ Warning: Phar::createDefaultStub() expects parameter 1 to be a valid path, array
Warning: Phar::loadPhar() expects parameter 1 to be a valid path, array given in %sbadparameters.php on line %d
-Warning: Phar::canCompress() expects parameter 1 to be long, %string given in %sbadparameters.php on line %d
+Warning: Phar::canCompress() expects parameter 1 to be integer, %string given in %sbadparameters.php on line %d
-Warning: Phar::__construct() expects parameter 1 to be a valid path, array given in %sbadparameters.php on line %d
+Exception: Phar::__construct() expects parameter 1 to be a valid path, array given in %sbadparameters.php on line %d
-Warning: Phar::convertToExecutable() expects parameter 1 to be long, array given in %sbadparameters.php on line %d
+Warning: Phar::convertToExecutable() expects parameter 1 to be integer, array given in %sbadparameters.php on line %d
-Warning: Phar::convertToData() expects parameter 1 to be long, array given in %sbadparameters.php on line %d
+Warning: Phar::convertToData() expects parameter 1 to be integer, array given in %sbadparameters.php on line %d
Warning: PharData::delete() expects parameter 1 to be a valid path, array given in %sbadparameters.php on line %d
Cannot write out phar archive, phar is read-only
@@ -156,10 +177,10 @@ Warning: Phar::setDefaultStub() expects parameter 1 to be %string, array given i
Cannot change stub: phar.readonly=1
Cannot set signature algorithm, phar is read-only
-Warning: Phar::compress() expects parameter 1 to be long, array given in %sbadparameters.php on line %d
+Warning: Phar::compress() expects parameter 1 to be integer, array given in %sbadparameters.php on line %d
Cannot compress phar archive, phar is read-only
-Warning: Phar::compressFiles() expects parameter 1 to be long, array given in %sbadparameters.php on line %d
+Warning: Phar::compressFiles() expects parameter 1 to be integer, array given in %sbadparameters.php on line %d
Phar is readonly, cannot change compression
Warning: Phar::copy() expects exactly 2 parameters, 1 given in %sbadparameters.php on line %d
diff --git a/ext/phar/tests/bug45218_SLOWTEST.phpt b/ext/phar/tests/bug45218_SLOWTEST.phpt
index 80356afc52..fd3b2fa710 100644
--- a/ext/phar/tests/bug45218_SLOWTEST.phpt
+++ b/ext/phar/tests/bug45218_SLOWTEST.phpt
@@ -3,7 +3,7 @@ Phar::buildFromIterator() iterator, too many files for open file handles (Bug #4
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request');
?>
--INI--
diff --git a/ext/phar/tests/bug45218_SLOWTESTU.phpt b/ext/phar/tests/bug45218_SLOWTESTU.phpt
index 1639691bad..e4a82a16ec 100644
--- a/ext/phar/tests/bug45218_SLOWTESTU.phpt
+++ b/ext/phar/tests/bug45218_SLOWTESTU.phpt
@@ -3,7 +3,7 @@ Phar::buildFromIterator() iterator, too many files for open file handles (Bug #4
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
if (getenv("SKIP_SLOW_TESTS")) die("skip slow tests excluded by request");
?>
--INI--
diff --git a/ext/phar/tests/bug46032.phpt b/ext/phar/tests/bug46032.phpt
index 7700e9b6f8..a59ddadd43 100644
--- a/ext/phar/tests/bug46032.phpt
+++ b/ext/phar/tests/bug46032.phpt
@@ -27,7 +27,7 @@ new phardata('0000000000000000000');
%string|unicode%(%d) "%smytest"
%string|unicode%(%d) "%smytest"
-Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Cannot create phar '0000000000000000000', file extension (or combination) not recognised or the directory does not exist' in %sbug46032.php:%d
+Fatal error: Uncaught UnexpectedValueException: Cannot create phar '0000000000000000000', file extension (or combination) not recognised or the directory does not exist in %sbug46032.php:%d
Stack trace:
#0 %sbug46032.php(%d): PharData->__construct('000000000000000...')
#1 {main}
diff --git a/ext/phar/tests/bug60261.phpt b/ext/phar/tests/bug60261.phpt
index 1b6cd7a7cd..84d4203e10 100644
--- a/ext/phar/tests/bug60261.phpt
+++ b/ext/phar/tests/bug60261.phpt
@@ -5,15 +5,13 @@ Bug #60261 (phar dos null pointer)
--FILE--
<?php
-$nx = new Phar();
try {
+ $nx = new Phar();
$nx->getLinkTarget();
-} catch (Exception $e) {
+} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECTF--
-
-Warning: Phar::__construct() expects at least 1 parameter, 0 given in %s on line %d
-SplFileInfo::getLinkTarget(): Empty filename
+Phar::__construct() expects at least 1 parameter, 0 given
diff --git a/ext/phar/tests/bug69441.phpt b/ext/phar/tests/bug69441.phpt
index 934c5f6b73..3536c3a835 100644
--- a/ext/phar/tests/bug69441.phpt
+++ b/ext/phar/tests/bug69441.phpt
@@ -14,7 +14,7 @@ $r = new Phar($fname, 0);
==DONE==
--EXPECTF--
-exception 'UnexpectedValueException' with message 'phar error: corrupted central directory entry, no magic signature in zip-based phar "%sbug69441.phar"' in %sbug69441.php:%d
+UnexpectedValueException: phar error: corrupted central directory entry, no magic signature in zip-based phar "%sbug69441.phar" in %sbug69441.php:%d
Stack trace:
#0 %s%ebug69441.php(%d): Phar->__construct('%s', 0)
#1 {main}
diff --git a/ext/phar/tests/bug69453.phpt b/ext/phar/tests/bug69453.phpt
index ddd2992ae0..6f280a5351 100644
--- a/ext/phar/tests/bug69453.phpt
+++ b/ext/phar/tests/bug69453.phpt
@@ -14,7 +14,7 @@ $r = new Phar($fname, 0);
==DONE==
--EXPECTF--
-exception 'UnexpectedValueException' with message 'phar error: "%s%ebug69453.tar.phar" is a corrupted tar file (checksum mismatch of file "")' in %s:%d
+UnexpectedValueException: phar error: "%s%ebug69453.tar.phar" is a corrupted tar file (checksum mismatch of file "") in %s:%d
Stack trace:
#0 %s%ebug69453.php(%d): Phar->__construct('%s', 0)
#1 {main}
diff --git a/ext/phar/tests/bug69720.phpt b/ext/phar/tests/bug69720.phpt
index 43b701d014..286d3cbdbe 100644
--- a/ext/phar/tests/bug69720.phpt
+++ b/ext/phar/tests/bug69720.phpt
@@ -25,7 +25,7 @@ try {
MY_METADATA_NULL
-Warning: file_get_contents(phar:///%s): failed to open stream: phar error: "test.php" is not a file in phar "%s.phar" in %s.php on line %d
+Warning: file_get_contents(phar://%s): failed to open stream: phar error: "test.php" is not a file in phar "%s.phar" in %s.php on line %d
array(1) {
["whatever"]=>
int(123)
diff --git a/ext/phar/tests/bug71331.phpt b/ext/phar/tests/bug71331.phpt
index 7864a872a7..0026c406e8 100644
--- a/ext/phar/tests/bug71331.phpt
+++ b/ext/phar/tests/bug71331.phpt
@@ -8,7 +8,7 @@ $p = new PharData(__DIR__."/bug71331.tar");
?>
DONE
--EXPECTF--
-Fatal error: Uncaught exception 'UnexpectedValueException' with message 'phar error: "%s%ebug71331.tar" is a corrupted tar file (invalid entry size)' in %s%ebug71331.php:2
+Fatal error: Uncaught UnexpectedValueException: phar error: "%s%ebug71331.tar" is a corrupted tar file (invalid entry size) in %s%ebug71331.php:2
Stack trace:
#0 %s%ebug71331.php(2): PharData->__construct('%s')
#1 {main}
diff --git a/ext/phar/tests/bug71625.phpt b/ext/phar/tests/bug71625.phpt
index d57ba5ef71..8e6c31f462 100644
--- a/ext/phar/tests/bug71625.phpt
+++ b/ext/phar/tests/bug71625.phpt
@@ -18,7 +18,7 @@ $phar["hello_habr.txt"] = '<? Hello Habr!?>';
?>
DONE
--EXPECTF--
-Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Cannot create phar 'A:A:.phar', file extension (or combination) not recognised or the directory does not exist' in %sbug71625.php:%d
+Fatal error: Uncaught UnexpectedValueException: Cannot create phar 'A:A:.phar', file extension (or combination) not recognised or the directory does not exist in %sbug71625.php:%d
Stack trace:
#0 %sbug71625.php(%d): Phar->__construct('A:A:.phar')
#1 {main}
diff --git a/ext/phar/tests/cache_list/frontcontroller11.phpt b/ext/phar/tests/cache_list/frontcontroller11.phpt
index 25b147e194..f5e4e2269f 100644
--- a/ext/phar/tests/cache_list/frontcontroller11.phpt
+++ b/ext/phar/tests/cache_list/frontcontroller11.phpt
@@ -15,7 +15,7 @@ files/frontcontroller5.phar
--EXPECTHEADERS--
Content-type: text/html; charset=UTF-8
--EXPECTF--
-Fatal error: Uncaught exception 'PharException' with message 'Key of MIME type overrides array must be a file extension, was "0"' in %sfrontcontroller11.php:2
+Fatal error: Uncaught PharException: Key of MIME type overrides array must be a file extension, was "0" in %sfrontcontroller11.php:2
Stack trace:
#0 %sfrontcontroller11.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
#1 {main}
diff --git a/ext/phar/tests/cache_list/frontcontroller12.phpt b/ext/phar/tests/cache_list/frontcontroller12.phpt
index cfc7d0e43a..6d798f9f8a 100644
--- a/ext/phar/tests/cache_list/frontcontroller12.phpt
+++ b/ext/phar/tests/cache_list/frontcontroller12.phpt
@@ -14,7 +14,7 @@ files/frontcontroller6.phar
--EXPECTHEADERS--
Content-type: text/html; charset=UTF-8
--EXPECTF--
-Fatal error: Uncaught exception 'PharException' with message 'Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed' in %sfrontcontroller12.php:2
+Fatal error: Uncaught PharException: Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed in %sfrontcontroller12.php:2
Stack trace:
#0 %sfrontcontroller12.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
#1 {main}
diff --git a/ext/phar/tests/cache_list/frontcontroller13.phpt b/ext/phar/tests/cache_list/frontcontroller13.phpt
index e6c9dee4ae..c81d0cfbd9 100644
--- a/ext/phar/tests/cache_list/frontcontroller13.phpt
+++ b/ext/phar/tests/cache_list/frontcontroller13.phpt
@@ -14,7 +14,7 @@ files/frontcontroller7.phar
--EXPECTHEADERS--
Content-type: text/html; charset=UTF-8
--EXPECTF--
-Fatal error: Uncaught exception 'PharException' with message 'Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed' in %sfrontcontroller13.php:2
+Fatal error: Uncaught PharException: Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed in %sfrontcontroller13.php:2
Stack trace:
#0 %sfrontcontroller13.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
#1 {main}
diff --git a/ext/phar/tests/cache_list/frontcontroller18.phpt b/ext/phar/tests/cache_list/frontcontroller18.phpt
index 5e94bf6ff5..77c0303d0c 100644
--- a/ext/phar/tests/cache_list/frontcontroller18.phpt
+++ b/ext/phar/tests/cache_list/frontcontroller18.phpt
@@ -11,7 +11,7 @@ PATH_INFO=/fronk.gronk
--FILE_EXTERNAL--
files/frontcontroller9.phar
--EXPECTF--
-Fatal error: Uncaught exception 'PharException' with message 'No values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller18.php:2
+Fatal error: Uncaught PharException: No values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME in %sfrontcontroller18.php:2
Stack trace:
#0 %sfrontcontroller18.php(2): Phar::mungServer(Array)
#1 {main}
diff --git a/ext/phar/tests/cache_list/frontcontroller19.phpt b/ext/phar/tests/cache_list/frontcontroller19.phpt
index bed0b1df31..548c6db479 100644
--- a/ext/phar/tests/cache_list/frontcontroller19.phpt
+++ b/ext/phar/tests/cache_list/frontcontroller19.phpt
@@ -11,7 +11,7 @@ PATH_INFO=/
--FILE_EXTERNAL--
files/frontcontroller10.phar
--EXPECTF--
-Fatal error: Uncaught exception 'PharException' with message 'Too many values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller19.php:2
+Fatal error: Uncaught PharException: Too many values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME in %sfrontcontroller19.php:2
Stack trace:
#0 %sfrontcontroller19.php(2): Phar::mungServer(Array)
#1 {main}
diff --git a/ext/phar/tests/cache_list/frontcontroller20.phpt b/ext/phar/tests/cache_list/frontcontroller20.phpt
index bf333c773c..68591c962a 100644
--- a/ext/phar/tests/cache_list/frontcontroller20.phpt
+++ b/ext/phar/tests/cache_list/frontcontroller20.phpt
@@ -11,7 +11,7 @@ PATH_INFO=/
--FILE_EXTERNAL--
files/frontcontroller11.phar
--EXPECTF--
-Fatal error: Uncaught exception 'PharException' with message 'Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller20.php:2
+Fatal error: Uncaught PharException: Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME in %sfrontcontroller20.php:2
Stack trace:
#0 %sfrontcontroller20.php(2): Phar::mungServer(Array)
#1 {main}
diff --git a/ext/phar/tests/cache_list/frontcontroller29.phpt b/ext/phar/tests/cache_list/frontcontroller29.phpt
index 1cd8f96f2d..c86cdfe4ac 100644
--- a/ext/phar/tests/cache_list/frontcontroller29.phpt
+++ b/ext/phar/tests/cache_list/frontcontroller29.phpt
@@ -14,4 +14,9 @@ files/frontcontroller8.phar
--EXPECTHEADERS--
Content-type: text/html; charset=UTF-8
--EXPECTF--
-Fatal error: Call to undefined function oopsie_daisy() in phar://%sfatalerror.phps on line 1 \ No newline at end of file
+Fatal error: Uncaught Error: Call to undefined function oopsie_daisy() in phar://%sfatalerror.phps:1
+Stack trace:
+#0 [internal function]: unknown()
+#1 %s(%d): Phar::webPhar('whatever', 'index.php', '404.php', Array)
+#2 {main}
+ thrown in phar://%sfatalerror.phps on line 1 \ No newline at end of file
diff --git a/ext/phar/tests/cached_manifest_1.phpt b/ext/phar/tests/cached_manifest_1.phpt
index af58523e7b..84ec5cb583 100644
--- a/ext/phar/tests/cached_manifest_1.phpt
+++ b/ext/phar/tests/cached_manifest_1.phpt
@@ -3,7 +3,7 @@ Phar: phar.cache_list basic read test
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
?>
--INI--
phar.cache_list={PWD}/files/nophar.phar
diff --git a/ext/phar/tests/cached_manifest_1U.phpt b/ext/phar/tests/cached_manifest_1U.phpt
index df77f07a79..3c870bdf03 100644
--- a/ext/phar/tests/cached_manifest_1U.phpt
+++ b/ext/phar/tests/cached_manifest_1U.phpt
@@ -3,7 +3,7 @@ Phar: phar.cache_list basic read test
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
?>
--INI--
phar.cache_list={PWD}/files/nophar.phar
diff --git a/ext/phar/tests/create_new_and_modify.phpt b/ext/phar/tests/create_new_and_modify.phpt
index c03576cb2c..c924d74c68 100644
--- a/ext/phar/tests/create_new_and_modify.phpt
+++ b/ext/phar/tests/create_new_and_modify.phpt
@@ -23,7 +23,7 @@ include $pname . '/a.php';
if (function_exists("opcache_get_status")) {
$status = opcache_get_status();
- if ($status["opcache_enabled"]) {
+ if ($status["opcache_enabled"] || (isset($status["file_cache_only"]) && $status["file_cache_only"])) {
ini_set("opcache.revalidate_freq", "0");
sleep(2);
}
diff --git a/ext/phar/tests/create_path_error.phpt b/ext/phar/tests/create_path_error.phpt
index d457deb22d..3449b07fc6 100644
--- a/ext/phar/tests/create_path_error.phpt
+++ b/ext/phar/tests/create_path_error.phpt
@@ -75,10 +75,10 @@ string(5) "query"
6:
7:
8:
-9:Error: file_put_contents(phar:///%s): failed to open stream: phar error: invalid path "%s" contains illegal character
-10:Error: file_put_contents(phar:///%s): failed to open stream: phar error: invalid path "%s" contains illegal character
-11:Error: file_put_contents(phar:///%s): failed to open stream: phar error: invalid path "%s" contains illegal character
-12:Error: file_put_contents(phar:///%s): failed to open stream: phar error: invalid path "%s" contains illegal character
-13:Error: file_put_contents(phar:///%s): failed to open stream: phar error: invalid path "%s" contains illegal character
+9:Error: file_put_contents(phar://%s): failed to open stream: phar error: invalid path "%s" contains illegal character
+10:Error: file_put_contents(phar://%s): failed to open stream: phar error: invalid path "%s" contains illegal character
+11:Error: file_put_contents(phar://%s): failed to open stream: phar error: invalid path "%s" contains illegal character
+12:Error: file_put_contents(phar://%s): failed to open stream: phar error: invalid path "%s" contains illegal character
+13:Error: file_put_contents(phar://%s): failed to open stream: phar error: invalid path "%s" contains illegal character
Error: Phar::offsetSet() expects parameter 1 to be a valid path, string given===DONE===
diff --git a/ext/phar/tests/fgc_edgecases.phpt b/ext/phar/tests/fgc_edgecases.phpt
index 2699834eb0..094a432339 100644
--- a/ext/phar/tests/fgc_edgecases.phpt
+++ b/ext/phar/tests/fgc_edgecases.phpt
@@ -3,7 +3,7 @@ Phar: test edge cases of file_get_contents() function interception
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
?>
--INI--
phar.readonly=0
diff --git a/ext/phar/tests/files/phar_test.inc b/ext/phar/tests/files/phar_test.inc
index 30ccf2058f..6f93969542 100644
--- a/ext/phar/tests/files/phar_test.inc
+++ b/ext/phar/tests/files/phar_test.inc
@@ -75,4 +75,4 @@ if (@$bz2) {
fclose($fp);
}
-?> \ No newline at end of file
+?>
diff --git a/ext/phar/tests/fopen_edgecases2U.phpt b/ext/phar/tests/fopen_edgecases2U.phpt
index 09c7b00570..c6ab93fe73 100644
--- a/ext/phar/tests/fopen_edgecases2U.phpt
+++ b/ext/phar/tests/fopen_edgecases2U.phpt
@@ -2,7 +2,7 @@
Phar: test edge cases of fopen() function interception #2 (PHP 6)
--SKIPIF--
<?php if (!extension_loaded("phar")) die("skip"); ?>
-<?php if (version_compare(PHP_VERSION, "6.0.0-dev", "<")) die("skip Unicode support required"); ?>
+<?php if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required"); ?>
--INI--
phar.readonly=0
--FILE--
@@ -43,4 +43,4 @@ blah
test
Warning: fopen(phar://%sfopen_edgecases2U.phar.php/oops): failed to open stream: phar error: path "oops" is a directory in phar://%sfopen_edgecases2U.phar.php/foo/hi on line 6
-===DONE=== \ No newline at end of file
+===DONE===
diff --git a/ext/phar/tests/frontcontroller11.phpt b/ext/phar/tests/frontcontroller11.phpt
index 1e6f1a00ff..aa20e19e97 100644
--- a/ext/phar/tests/frontcontroller11.phpt
+++ b/ext/phar/tests/frontcontroller11.phpt
@@ -14,7 +14,7 @@ files/frontcontroller5.phar
--EXPECTHEADERS--
Content-type: text/html
--EXPECTF--
-Fatal error: Uncaught exception 'PharException' with message 'Key of MIME type overrides array must be a file extension, was "0"' in %sfrontcontroller11.php:2
+Fatal error: Uncaught PharException: Key of MIME type overrides array must be a file extension, was "0" in %sfrontcontroller11.php:2
Stack trace:
#0 %sfrontcontroller11.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
#1 {main}
diff --git a/ext/phar/tests/frontcontroller12.phpt b/ext/phar/tests/frontcontroller12.phpt
index 956ea1c050..bad71d0ac5 100644
--- a/ext/phar/tests/frontcontroller12.phpt
+++ b/ext/phar/tests/frontcontroller12.phpt
@@ -13,7 +13,7 @@ files/frontcontroller6.phar
--EXPECTHEADERS--
Content-type: text/html; charset=UTF-8
--EXPECTF--
-Fatal error: Uncaught exception 'PharException' with message 'Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed' in %sfrontcontroller12.php:2
+Fatal error: Uncaught PharException: Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed in %sfrontcontroller12.php:2
Stack trace:
#0 %sfrontcontroller12.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
#1 {main}
diff --git a/ext/phar/tests/frontcontroller13.phpt b/ext/phar/tests/frontcontroller13.phpt
index 717e56996f..7d018a141a 100644
--- a/ext/phar/tests/frontcontroller13.phpt
+++ b/ext/phar/tests/frontcontroller13.phpt
@@ -13,7 +13,7 @@ files/frontcontroller7.phar
--EXPECTHEADERS--
Content-type: text/html; charset=UTF-8
--EXPECTF--
-Fatal error: Uncaught exception 'PharException' with message 'Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed' in %sfrontcontroller13.php:2
+Fatal error: Uncaught PharException: Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed in %sfrontcontroller13.php:2
Stack trace:
#0 %sfrontcontroller13.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
#1 {main}
diff --git a/ext/phar/tests/frontcontroller18.phpt b/ext/phar/tests/frontcontroller18.phpt
index 19aea45563..d01886e6b0 100644
--- a/ext/phar/tests/frontcontroller18.phpt
+++ b/ext/phar/tests/frontcontroller18.phpt
@@ -9,7 +9,7 @@ PATH_INFO=/fronk.gronk
--FILE_EXTERNAL--
files/frontcontroller9.phar
--EXPECTF--
-Fatal error: Uncaught exception 'PharException' with message 'No values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller18.php:2
+Fatal error: Uncaught PharException: No values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME in %sfrontcontroller18.php:2
Stack trace:
#0 %sfrontcontroller18.php(2): Phar::mungServer(Array)
#1 {main}
diff --git a/ext/phar/tests/frontcontroller19.phpt b/ext/phar/tests/frontcontroller19.phpt
index 9adafa2b30..e577ecb6a4 100644
--- a/ext/phar/tests/frontcontroller19.phpt
+++ b/ext/phar/tests/frontcontroller19.phpt
@@ -9,7 +9,7 @@ PATH_INFO=/
--FILE_EXTERNAL--
files/frontcontroller10.phar
--EXPECTF--
-Fatal error: Uncaught exception 'PharException' with message 'Too many values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller19.php:2
+Fatal error: Uncaught PharException: Too many values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME in %sfrontcontroller19.php:2
Stack trace:
#0 %sfrontcontroller19.php(2): Phar::mungServer(Array)
#1 {main}
diff --git a/ext/phar/tests/frontcontroller20.phpt b/ext/phar/tests/frontcontroller20.phpt
index 45e2bfc25e..e67ec06a5c 100644
--- a/ext/phar/tests/frontcontroller20.phpt
+++ b/ext/phar/tests/frontcontroller20.phpt
@@ -9,7 +9,7 @@ PATH_INFO=/
--FILE_EXTERNAL--
files/frontcontroller11.phar
--EXPECTF--
-Fatal error: Uncaught exception 'PharException' with message 'Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller20.php:2
+Fatal error: Uncaught PharException: Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME in %sfrontcontroller20.php:2
Stack trace:
#0 %sfrontcontroller20.php(2): Phar::mungServer(Array)
#1 {main}
diff --git a/ext/phar/tests/frontcontroller29.phpt b/ext/phar/tests/frontcontroller29.phpt
index 0afc17929f..710a58f91b 100644
--- a/ext/phar/tests/frontcontroller29.phpt
+++ b/ext/phar/tests/frontcontroller29.phpt
@@ -13,4 +13,9 @@ files/frontcontroller8.phar
--EXPECTHEADERS--
Content-type: text/html; charset=UTF-8
--EXPECTF--
-Fatal error: Call to undefined function oopsie_daisy() in phar://%sfatalerror.phps on line 1 \ No newline at end of file
+Fatal error: Uncaught Error: Call to undefined function oopsie_daisy() in phar://%sfatalerror.phps:1
+Stack trace:
+#0 [internal function]: unknown()
+#1 %s(%d): Phar::webPhar('whatever', 'index.php', '404.php', Array)
+#2 {main}
+ thrown in phar://%sfatalerror.phps on line 1 \ No newline at end of file
diff --git a/ext/phar/tests/ini_set_off.phpt b/ext/phar/tests/ini_set_off.phpt
index 878f8bf90d..e3a5ab7b1e 100644
--- a/ext/phar/tests/ini_set_off.phpt
+++ b/ext/phar/tests/ini_set_off.phpt
@@ -3,7 +3,7 @@ Phar: test ini_set with readonly and require_hash disabled
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/ini_set_offU.phpt b/ext/phar/tests/ini_set_offU.phpt
index 150cbeda5f..10a36f935b 100644
--- a/ext/phar/tests/ini_set_offU.phpt
+++ b/ext/phar/tests/ini_set_offU.phpt
@@ -3,7 +3,7 @@ Phar: test ini_set with readonly and require_hash disabled
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/metadata_read.phpt b/ext/phar/tests/metadata_read.phpt
index 5c37382ec6..1e852c0f53 100644
--- a/ext/phar/tests/metadata_read.phpt
+++ b/ext/phar/tests/metadata_read.phpt
@@ -3,7 +3,7 @@ Phar with meta-data (read)
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/metadata_readU.phpt b/ext/phar/tests/metadata_readU.phpt
index 7197eadfa6..bca71bdd3f 100644
--- a/ext/phar/tests/metadata_readU.phpt
+++ b/ext/phar/tests/metadata_readU.phpt
@@ -3,7 +3,7 @@ Phar with meta-data (read)
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/metadata_write.phpt b/ext/phar/tests/metadata_write.phpt
index 1aaa30d630..a9617956b7 100644
--- a/ext/phar/tests/metadata_write.phpt
+++ b/ext/phar/tests/metadata_write.phpt
@@ -3,7 +3,7 @@ Phar with meta-data (write)
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/metadata_writeU.phpt b/ext/phar/tests/metadata_writeU.phpt
index dc0764be4b..52903ea83a 100644
--- a/ext/phar/tests/metadata_writeU.phpt
+++ b/ext/phar/tests/metadata_writeU.phpt
@@ -3,7 +3,7 @@ Phar with meta-data (write)
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/metadata_write_commit.phpt b/ext/phar/tests/metadata_write_commit.phpt
index fd2f10762a..caaa7d9132 100644
--- a/ext/phar/tests/metadata_write_commit.phpt
+++ b/ext/phar/tests/metadata_write_commit.phpt
@@ -3,7 +3,7 @@ Phar with meta-data (write)
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/metadata_write_commitU.phpt b/ext/phar/tests/metadata_write_commitU.phpt
index 712a6f5571..bd642c7fa1 100644
--- a/ext/phar/tests/metadata_write_commitU.phpt
+++ b/ext/phar/tests/metadata_write_commitU.phpt
@@ -3,7 +3,7 @@ Phar with meta-data (write)
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/mounteddir.phpt b/ext/phar/tests/mounteddir.phpt
index e1308956fe..9c07ea34a5 100644
--- a/ext/phar/tests/mounteddir.phpt
+++ b/ext/phar/tests/mounteddir.phpt
@@ -3,7 +3,7 @@ Phar: mounted manifest directory test
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
?>
--INI--
phar.readonly=0
diff --git a/ext/phar/tests/mounteddirU.phpt b/ext/phar/tests/mounteddirU.phpt
index d05cb00b2a..e20bd2b0c9 100644
--- a/ext/phar/tests/mounteddirU.phpt
+++ b/ext/phar/tests/mounteddirU.phpt
@@ -3,7 +3,7 @@ Phar: mounted manifest directory test
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
?>
--INI--
phar.readonly=0
diff --git a/ext/phar/tests/phar_begin_setstub_commit.phpt b/ext/phar/tests/phar_begin_setstub_commit.phpt
index 9d3e38323e..59a80dc6dd 100644
--- a/ext/phar/tests/phar_begin_setstub_commit.phpt
+++ b/ext/phar/tests/phar_begin_setstub_commit.phpt
@@ -3,7 +3,7 @@ Phar::startBuffering()/setStub()/stopBuffering()
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/phar_begin_setstub_commitU.phpt b/ext/phar/tests/phar_begin_setstub_commitU.phpt
index 805e762320..10b73a0467 100644
--- a/ext/phar/tests/phar_begin_setstub_commitU.phpt
+++ b/ext/phar/tests/phar_begin_setstub_commitU.phpt
@@ -3,7 +3,7 @@ Phar::startBuffering()/setStub()/stopBuffering()
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/phar_bz2.phpt b/ext/phar/tests/phar_bz2.phpt
index 0e6e3ecb54..0fb3db8cda 100644
--- a/ext/phar/tests/phar_bz2.phpt
+++ b/ext/phar/tests/phar_bz2.phpt
@@ -60,6 +60,6 @@ echo $e->getMessage(),"\n";
bool(true)
bool(true)
-Warning: Phar::isFileFormat() expects parameter 1 to be long, array given in %sphar_bz2.php on line %d
+Warning: Phar::isFileFormat() expects parameter 1 to be integer, array given in %sphar_bz2.php on line %d
Unknown file format specified
===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/phar_gzip.phpt b/ext/phar/tests/phar_gzip.phpt
index c722834ba6..2421414f8c 100644
--- a/ext/phar/tests/phar_gzip.phpt
+++ b/ext/phar/tests/phar_gzip.phpt
@@ -3,7 +3,7 @@ Phar: gzipped phar
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
if (!extension_loaded("spl")) die("skip SPL not available");
if (!extension_loaded("zlib")) die("skip zlib not available");
if (version_compare(phpversion(), '5.2.6', '<')) die("skip zlib is buggy in PHP < 5.2.6");
diff --git a/ext/phar/tests/phar_gzipU.phpt b/ext/phar/tests/phar_gzipU.phpt
index 662f862ef0..2dc4530969 100644
--- a/ext/phar/tests/phar_gzipU.phpt
+++ b/ext/phar/tests/phar_gzipU.phpt
@@ -3,7 +3,7 @@ Phar: gzipped phar
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
if (!extension_loaded("spl")) die("skip SPL not available");
if (!extension_loaded("zlib")) die("skip zlib not available");
if (version_compare(phpversion(), '5.2.6', '<')) die("skip zlib is buggy in PHP < 5.2.6");
diff --git a/ext/phar/tests/phar_metadata_read.phpt b/ext/phar/tests/phar_metadata_read.phpt
index 2d6586d590..bf7b6c4981 100644
--- a/ext/phar/tests/phar_metadata_read.phpt
+++ b/ext/phar/tests/phar_metadata_read.phpt
@@ -3,7 +3,7 @@ Phar with metadata (read)
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
?>
--INI--
phar.readonly=0
diff --git a/ext/phar/tests/phar_metadata_readU.phpt b/ext/phar/tests/phar_metadata_readU.phpt
index 281e9786dd..325c3ccf25 100644
--- a/ext/phar/tests/phar_metadata_readU.phpt
+++ b/ext/phar/tests/phar_metadata_readU.phpt
@@ -3,7 +3,7 @@ Phar with metadata (read)
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
?>
--INI--
phar.readonly=0
diff --git a/ext/phar/tests/phar_metadata_write.phpt b/ext/phar/tests/phar_metadata_write.phpt
index 0a3b66d749..d9f0aba601 100644
--- a/ext/phar/tests/phar_metadata_write.phpt
+++ b/ext/phar/tests/phar_metadata_write.phpt
@@ -3,7 +3,7 @@ Phar with metadata (write)
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/phar_metadata_writeU.phpt b/ext/phar/tests/phar_metadata_writeU.phpt
index 21c42d7f1a..715b697596 100644
--- a/ext/phar/tests/phar_metadata_writeU.phpt
+++ b/ext/phar/tests/phar_metadata_writeU.phpt
@@ -3,7 +3,7 @@ Phar with metadata (write)
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/phar_oo_001.phpt b/ext/phar/tests/phar_oo_001.phpt
index bb4c9d7188..e89e3c2794 100644
--- a/ext/phar/tests/phar_oo_001.phpt
+++ b/ext/phar/tests/phar_oo_001.phpt
@@ -3,7 +3,7 @@ Phar object: basics
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
if (!extension_loaded("spl")) die("skip SPL not available");
?>
--INI--
diff --git a/ext/phar/tests/phar_oo_001U.phpt b/ext/phar/tests/phar_oo_001U.phpt
index a21026a5b6..ce0057918b 100644
--- a/ext/phar/tests/phar_oo_001U.phpt
+++ b/ext/phar/tests/phar_oo_001U.phpt
@@ -3,7 +3,7 @@ Phar object: basics
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
if (!extension_loaded("spl")) die("skip SPL not available");
?>
--INI--
diff --git a/ext/phar/tests/phar_oo_002.phpt b/ext/phar/tests/phar_oo_002.phpt
index 476cd7d3c2..bcdcc35b31 100644
--- a/ext/phar/tests/phar_oo_002.phpt
+++ b/ext/phar/tests/phar_oo_002.phpt
@@ -3,7 +3,7 @@ Phar object: iterator & entries
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
if (!extension_loaded("spl")) die("skip SPL not available");
?>
--INI--
diff --git a/ext/phar/tests/phar_oo_002U.phpt b/ext/phar/tests/phar_oo_002U.phpt
index da17152b32..ec44ba4b40 100644
--- a/ext/phar/tests/phar_oo_002U.phpt
+++ b/ext/phar/tests/phar_oo_002U.phpt
@@ -3,7 +3,7 @@ Phar object: iterator & entries
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip requires Unicode support");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip requires Unicode support");
if (!extension_loaded("spl")) die("skip SPL not available");
?>
--INI--
diff --git a/ext/phar/tests/phar_oo_004.phpt b/ext/phar/tests/phar_oo_004.phpt
index 3e4581992e..e801978903 100644
--- a/ext/phar/tests/phar_oo_004.phpt
+++ b/ext/phar/tests/phar_oo_004.phpt
@@ -4,7 +4,7 @@ Phar and DirectoryIterator
<?php
if (!extension_loaded("phar")) die("skip");
if (!extension_loaded("spl")) die("skip SPL not available");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/phar_oo_004U.phpt b/ext/phar/tests/phar_oo_004U.phpt
index 51be9dab2e..d3272f434d 100644
--- a/ext/phar/tests/phar_oo_004U.phpt
+++ b/ext/phar/tests/phar_oo_004U.phpt
@@ -4,7 +4,7 @@ Phar and DirectoryIterator
<?php
if (!extension_loaded("phar")) die("skip");
if (!extension_loaded("spl")) die("skip SPL not available");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip requires Unicode support");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip requires Unicode support");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/phar_oo_005U.phpt b/ext/phar/tests/phar_oo_005U.phpt
index 9c04b93cef..9a2589cdfe 100644
--- a/ext/phar/tests/phar_oo_005U.phpt
+++ b/ext/phar/tests/phar_oo_005U.phpt
@@ -4,7 +4,7 @@ Phar and RecursiveDirectoryIterator
<?php
if (!extension_loaded("phar")) die("skip");
if (!extension_loaded("spl")) die("skip SPL not available");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip requires Unicode support");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip requires Unicode support");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/pharfileinfo_chmod.phpt b/ext/phar/tests/pharfileinfo_chmod.phpt
index e99be5d6b9..ddc4d37393 100644
--- a/ext/phar/tests/pharfileinfo_chmod.phpt
+++ b/ext/phar/tests/pharfileinfo_chmod.phpt
@@ -29,5 +29,5 @@ $b->chmod(0666);
--EXPECTF--
Phar entry "a" is a temporary directory (not an actual entry in the archive), cannot chmod
-Warning: PharFileInfo::chmod() expects parameter 1 to be long, array given in %spharfileinfo_chmod.php on line %d
+Warning: PharFileInfo::chmod() expects parameter 1 to be integer, array given in %spharfileinfo_chmod.php on line %d
===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/pharfileinfo_compression.phpt b/ext/phar/tests/pharfileinfo_compression.phpt
index fbac499127..2c3bac8863 100644
--- a/ext/phar/tests/pharfileinfo_compression.phpt
+++ b/ext/phar/tests/pharfileinfo_compression.phpt
@@ -76,7 +76,7 @@ var_dump($b->decompress());
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar'); ?>
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar'); ?>
--EXPECTF--
-Warning: PharFileInfo::isCompressed() expects parameter 1 to be long, array given in %spharfileinfo_compression.php on line 11
+Warning: PharFileInfo::isCompressed() expects parameter 1 to be integer, array given in %spharfileinfo_compression.php on line 11
Unknown compression type specified
Unknown compression type specified
Cannot compress with Gzip compression, not possible with tar-based phar archives
diff --git a/ext/phar/tests/pharfileinfo_construct.phpt b/ext/phar/tests/pharfileinfo_construct.phpt
index 6a41a52a30..53ee5143cf 100644
--- a/ext/phar/tests/pharfileinfo_construct.phpt
+++ b/ext/phar/tests/pharfileinfo_construct.phpt
@@ -17,7 +17,11 @@ echo $e->getMessage() . "\n";
unlink($fname);
}
+try {
$a = new PharFileInfo(array());
+} catch (TypeError $e) {
+echo $e->getMessage() . "\n";
+}
$a = new Phar($fname);
$a['a'] = 'hi';
@@ -46,9 +50,8 @@ echo $e->getMessage() . "\n";
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar'); ?>
--EXPECTF--
Cannot open phar file 'phar://%spharfileinfo_construct.phar/oops': internal corruption of phar "%spharfileinfo_construct.phar" (truncated entry)
-
-Warning: PharFileInfo::__construct() expects parameter 1 to be a valid path, array given in %spharfileinfo_construct.php on line %d
-Cannot access phar file entry '/oops/I/do/not/exist' in archive '%spharfileinfo_construct.phar'
+PharFileInfo::__construct() expects parameter 1 to be a valid path, array given
+Cannot access phar file entry '%s' in archive '%s'
Cannot call constructor twice
-'%spharfileinfo_construct.php' is not a valid phar archive URL (must have at least phar://filename.phar)
-===DONE=== \ No newline at end of file
+'%s' is not a valid phar archive URL (must have at least phar://filename.phar)
+===DONE===
diff --git a/ext/phar/tests/phpinfo_004.phpt b/ext/phar/tests/phpinfo_004.phpt
index c57e850d82..b6df340815 100644
--- a/ext/phar/tests/phpinfo_004.phpt
+++ b/ext/phar/tests/phpinfo_004.phpt
@@ -24,7 +24,7 @@ phpinfo(INFO_MODULES);
===DONE===
--EXPECTF--
%a
-<h2><a name="module_Phar">Phar</a></h2>
+<h2><a name="module_phar">Phar</a></h2>
<table>
<tr class="h"><th>Phar: PHP Archive support</th><th>enabled</th></tr>
<tr><td class="e">Phar EXT version </td><td class="v">%s </td></tr>
@@ -48,7 +48,7 @@ Phar based on pear/PHP_Archive, original concept by Davey Shafik.<br />Phar full
<tr><td class="e">phar.require_hash</td><td class="v">Off</td><td class="v">Off</td></tr>
</table>
%a
-<h2><a name="module_Phar">Phar</a></h2>
+<h2><a name="module_phar">Phar</a></h2>
<table>
<tr class="h"><th>Phar: PHP Archive support</th><th>enabled</th></tr>
<tr><td class="e">Phar EXT version </td><td class="v">%s </td></tr>
diff --git a/ext/phar/tests/readfile_edgecasesU.phpt b/ext/phar/tests/readfile_edgecasesU.phpt
index c26b45fc57..905227a242 100644
--- a/ext/phar/tests/readfile_edgecasesU.phpt
+++ b/ext/phar/tests/readfile_edgecasesU.phpt
@@ -2,7 +2,7 @@
Phar: test edge cases of readfile() function interception
--SKIPIF--
<?php if (!extension_loaded("phar")) die("skip");?>
-<?php if (version_compare(PHP_VERSION, "6.0", "<")) die("skip requires php 6.0 or newer"); ?>
+<?php if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip requires php 6.0 or newer"); ?>
--INI--
phar.readonly=0
--FILE--
diff --git a/ext/phar/tests/tar/all.phpt b/ext/phar/tests/tar/all.phpt
index 4dfb65459a..2765263812 100644
--- a/ext/phar/tests/tar/all.phpt
+++ b/ext/phar/tests/tar/all.phpt
@@ -3,7 +3,7 @@ Phar: test that creation of tar-based phar generates valid tar with all bells/wh
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
if (!extension_loaded("spl")) die("skip SPL not available");
if (!extension_loaded("zlib")) die("skip zlib not available");
if (!extension_loaded("bz2")) die("skip bz2 not available");
diff --git a/ext/phar/tests/tar/allU.phpt b/ext/phar/tests/tar/allU.phpt
index 50c7fc711d..65e2c091be 100644
--- a/ext/phar/tests/tar/allU.phpt
+++ b/ext/phar/tests/tar/allU.phpt
@@ -3,7 +3,7 @@ Phar: test that creation of tar-based phar generates valid tar with all bells/wh
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
if (!extension_loaded("spl")) die("skip SPL not available");
if (!extension_loaded("zlib")) die("skip zlib not available");
if (!extension_loaded("bz2")) die("skip bz2 not available");
diff --git a/ext/phar/tests/tar/create_new_and_modify.phpt b/ext/phar/tests/tar/create_new_and_modify.phpt
index 905bfabc82..7d8bcb17da 100644
--- a/ext/phar/tests/tar/create_new_and_modify.phpt
+++ b/ext/phar/tests/tar/create_new_and_modify.phpt
@@ -17,7 +17,7 @@ file_put_contents($pname . '/a.php', "brand new!\n");
if (function_exists("opcache_get_status")) {
$status = opcache_get_status();
- if ($status["opcache_enabled"]) {
+ if ($status["opcache_enabled"] || (isset($status["file_cache_only"]) && $status["file_cache_only"])) {
ini_set("opcache.revalidate_freq", "0");
sleep(2);
}
diff --git a/ext/phar/tests/tar/frontcontroller11.phar.phpt b/ext/phar/tests/tar/frontcontroller11.phar.phpt
index 2b0d15b603..4b8c29dd1b 100644
--- a/ext/phar/tests/tar/frontcontroller11.phar.phpt
+++ b/ext/phar/tests/tar/frontcontroller11.phar.phpt
@@ -14,7 +14,7 @@ files/frontcontroller5.phar.tar
--EXPECTHEADERS--
Content-type: text/html
--EXPECTF--
-Fatal error: Uncaught exception 'PharException' with message 'Key of MIME type overrides array must be a file extension, was "0"' in %sfrontcontroller11.phar.php:2
+Fatal error: Uncaught PharException: Key of MIME type overrides array must be a file extension, was "0" in %sfrontcontroller11.phar.php:2
Stack trace:
#0 %sfrontcontroller11.phar.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
#1 {main}
diff --git a/ext/phar/tests/tar/frontcontroller12.phar.phpt b/ext/phar/tests/tar/frontcontroller12.phar.phpt
index 2086856cf3..53804e476a 100644
--- a/ext/phar/tests/tar/frontcontroller12.phar.phpt
+++ b/ext/phar/tests/tar/frontcontroller12.phar.phpt
@@ -13,7 +13,7 @@ files/frontcontroller6.phar.tar
--EXPECTHEADERS--
Content-type: text/html; charset=UTF-8
--EXPECTF--
-Fatal error: Uncaught exception 'PharException' with message 'Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed' in %sfrontcontroller12.phar.php:2
+Fatal error: Uncaught PharException: Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed in %sfrontcontroller12.phar.php:2
Stack trace:
#0 %sfrontcontroller12.phar.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
#1 {main}
diff --git a/ext/phar/tests/tar/frontcontroller13.phar.phpt b/ext/phar/tests/tar/frontcontroller13.phar.phpt
index ce7620a198..7fc0676aea 100644
--- a/ext/phar/tests/tar/frontcontroller13.phar.phpt
+++ b/ext/phar/tests/tar/frontcontroller13.phar.phpt
@@ -13,7 +13,7 @@ files/frontcontroller7.phar.tar
--EXPECTHEADERS--
Content-type: text/html; charset=UTF-8
--EXPECTF--
-Fatal error: Uncaught exception 'PharException' with message 'Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed' in %sfrontcontroller13.phar.php:2
+Fatal error: Uncaught PharException: Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed in %sfrontcontroller13.phar.php:2
Stack trace:
#0 %sfrontcontroller13.phar.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
#1 {main}
diff --git a/ext/phar/tests/tar/frontcontroller18.phar.phpt b/ext/phar/tests/tar/frontcontroller18.phar.phpt
index c52ce291c7..1dddcef069 100644
--- a/ext/phar/tests/tar/frontcontroller18.phar.phpt
+++ b/ext/phar/tests/tar/frontcontroller18.phar.phpt
@@ -9,7 +9,7 @@ PATH_INFO=/fronk.gronk
--FILE_EXTERNAL--
files/frontcontroller9.phar.tar
--EXPECTF--
-Fatal error: Uncaught exception 'PharException' with message 'No values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller18.phar.php:2
+Fatal error: Uncaught PharException: No values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME in %sfrontcontroller18.phar.php:2
Stack trace:
#0 %sfrontcontroller18.phar.php(2): Phar::mungServer(Array)
#1 {main}
diff --git a/ext/phar/tests/tar/frontcontroller19.phar.phpt b/ext/phar/tests/tar/frontcontroller19.phar.phpt
index 6b07438787..21a173f9be 100644
--- a/ext/phar/tests/tar/frontcontroller19.phar.phpt
+++ b/ext/phar/tests/tar/frontcontroller19.phar.phpt
@@ -9,7 +9,7 @@ PATH_INFO=/
--FILE_EXTERNAL--
files/frontcontroller10.phar.tar
--EXPECTF--
-Fatal error: Uncaught exception 'PharException' with message 'Too many values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller19.phar.php:2
+Fatal error: Uncaught PharException: Too many values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME in %sfrontcontroller19.phar.php:2
Stack trace:
#0 %sfrontcontroller19.phar.php(2): Phar::mungServer(Array)
#1 {main}
diff --git a/ext/phar/tests/tar/frontcontroller20.phar.phpt b/ext/phar/tests/tar/frontcontroller20.phar.phpt
index 3cc470d41b..b88903eb53 100644
--- a/ext/phar/tests/tar/frontcontroller20.phar.phpt
+++ b/ext/phar/tests/tar/frontcontroller20.phar.phpt
@@ -9,7 +9,7 @@ PATH_INFO=/
--FILE_EXTERNAL--
files/frontcontroller11.phar.tar
--EXPECTF--
-Fatal error: Uncaught exception 'PharException' with message 'Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller20.phar.php:2
+Fatal error: Uncaught PharException: Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME in %sfrontcontroller20.phar.php:2
Stack trace:
#0 %sfrontcontroller20.phar.php(2): Phar::mungServer(Array)
#1 {main}
diff --git a/ext/phar/tests/tar/phar_begin_setstub_commit.phpt b/ext/phar/tests/tar/phar_begin_setstub_commit.phpt
index d18f32ed3b..ffbdc2f1a6 100644
--- a/ext/phar/tests/tar/phar_begin_setstub_commit.phpt
+++ b/ext/phar/tests/tar/phar_begin_setstub_commit.phpt
@@ -3,7 +3,7 @@ Phar::startBuffering()/setStub()/stopBuffering() tar-based
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
?>
--INI--
phar.readonly=0
diff --git a/ext/phar/tests/tar/phar_begin_setstub_commitU.phpt b/ext/phar/tests/tar/phar_begin_setstub_commitU.phpt
index d058b36165..02d64a4540 100644
--- a/ext/phar/tests/tar/phar_begin_setstub_commitU.phpt
+++ b/ext/phar/tests/tar/phar_begin_setstub_commitU.phpt
@@ -3,7 +3,7 @@ Phar::startBuffering()/setStub()/stopBuffering() tar-based
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
?>
--INI--
phar.readonly=0
diff --git a/ext/phar/tests/tar/tar_004.phpt b/ext/phar/tests/tar/tar_004.phpt
index bb1d3bf9e1..f6d883888e 100644
--- a/ext/phar/tests/tar/tar_004.phpt
+++ b/ext/phar/tests/tar/tar_004.phpt
@@ -3,7 +3,7 @@ Phar: tar-based phar, tar phar with stub, mapPhar()
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
if (!extension_loaded("spl")) die("skip SPL not available");
?>
--INI--
diff --git a/ext/phar/tests/tar/tar_004U.phpt b/ext/phar/tests/tar/tar_004U.phpt
index 45c77a9240..0584108938 100644
--- a/ext/phar/tests/tar/tar_004U.phpt
+++ b/ext/phar/tests/tar/tar_004U.phpt
@@ -3,7 +3,7 @@ Phar: tar-based phar, tar phar with stub, mapPhar()
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
if (!extension_loaded("spl")) die("skip SPL not available");
?>
--INI--
diff --git a/ext/phar/tests/tar/tar_bz2.phpt b/ext/phar/tests/tar/tar_bz2.phpt
index 6093bb9afb..24bcf0e5d8 100644
--- a/ext/phar/tests/tar/tar_bz2.phpt
+++ b/ext/phar/tests/tar/tar_bz2.phpt
@@ -3,7 +3,7 @@ Phar: tar-based phar, bzipped tar
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
if (!extension_loaded("spl")) die("skip SPL not available");
if (!extension_loaded("bz2")) die("skip bz2 not available");
?>
diff --git a/ext/phar/tests/tar/tar_bz2U.phpt b/ext/phar/tests/tar/tar_bz2U.phpt
index 2f92976509..bdd13f73ab 100644
--- a/ext/phar/tests/tar/tar_bz2U.phpt
+++ b/ext/phar/tests/tar/tar_bz2U.phpt
@@ -3,7 +3,7 @@ Phar: tar-based phar, bzipped tar
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
if (!extension_loaded("spl")) die("skip SPL not available");
if (!extension_loaded("bz2")) die("skip bz2 not available");
?>
diff --git a/ext/phar/tests/tar/tar_gzip.phpt b/ext/phar/tests/tar/tar_gzip.phpt
index d44e1b193c..50019ca580 100644
--- a/ext/phar/tests/tar/tar_gzip.phpt
+++ b/ext/phar/tests/tar/tar_gzip.phpt
@@ -3,7 +3,7 @@ Phar: tar-based phar, gzipped tar
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
if (!extension_loaded("spl")) die("skip SPL not available");
if (!extension_loaded("zlib")) die("skip zlib not available");
if (version_compare(phpversion(), '5.2.6', '<')) die("skip zlib is buggy in PHP < 5.2.6");
diff --git a/ext/phar/tests/tar/tar_gzipU.phpt b/ext/phar/tests/tar/tar_gzipU.phpt
index 4aa348e427..6b2c8a66e9 100644
--- a/ext/phar/tests/tar/tar_gzipU.phpt
+++ b/ext/phar/tests/tar/tar_gzipU.phpt
@@ -3,7 +3,7 @@ Phar: tar-based phar, gzipped tar
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
if (!extension_loaded("spl")) die("skip SPL not available");
if (!extension_loaded("zlib")) die("skip zlib not available");
if (version_compare(phpversion(), '5.2.6', '<')) die("skip zlib is buggy in PHP < 5.2.6");
diff --git a/ext/phar/tests/zip/all.phpt b/ext/phar/tests/zip/all.phpt
index 49d79a44cc..d69b76e1ea 100644
--- a/ext/phar/tests/zip/all.phpt
+++ b/ext/phar/tests/zip/all.phpt
@@ -3,7 +3,7 @@ Phar: test that creation of zip-based phar generates valid zip with all bells/wh
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
if (!extension_loaded("spl")) die("skip SPL not available");
if (!extension_loaded("zlib")) die("skip zlib not available");
if (!extension_loaded("bz2")) die("skip bz2 not available");
diff --git a/ext/phar/tests/zip/allU.phpt b/ext/phar/tests/zip/allU.phpt
index 93fe5da4c0..97a9dd53bd 100644
--- a/ext/phar/tests/zip/allU.phpt
+++ b/ext/phar/tests/zip/allU.phpt
@@ -3,7 +3,7 @@ Phar: test that creation of zip-based phar generates valid zip with all bells/wh
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
if (!extension_loaded("spl")) die("skip SPL not available");
if (!extension_loaded("zlib")) die("skip zlib not available");
if (!extension_loaded("bz2")) die("skip bz2 not available");
diff --git a/ext/phar/tests/zip/create_new_and_modify.phpt b/ext/phar/tests/zip/create_new_and_modify.phpt
index 55d69cca0e..c49ec513ff 100644
--- a/ext/phar/tests/zip/create_new_and_modify.phpt
+++ b/ext/phar/tests/zip/create_new_and_modify.phpt
@@ -17,7 +17,7 @@ file_put_contents($pname . '/a.php', "brand new!\n");
if (function_exists("opcache_get_status")) {
$status = opcache_get_status();
- if ($status["opcache_enabled"]) {
+ if ($status["opcache_enabled"] || (isset($status["file_cache_only"]) && $status["file_cache_only"])) {
ini_set("opcache.revalidate_freq", "0");
sleep(2);
}
diff --git a/ext/phar/tests/zip/frontcontroller11.phar.phpt b/ext/phar/tests/zip/frontcontroller11.phar.phpt
index e4900cd3a5..c0c555a1a4 100644
--- a/ext/phar/tests/zip/frontcontroller11.phar.phpt
+++ b/ext/phar/tests/zip/frontcontroller11.phar.phpt
@@ -15,7 +15,7 @@ files/frontcontroller5.phar.zip
--EXPECTHEADERS--
Content-type: text/html
--EXPECTF--
-Fatal error: Uncaught exception 'PharException' with message 'Key of MIME type overrides array must be a file extension, was "0"' in %sfrontcontroller11.phar.php:2
+Fatal error: Uncaught PharException: Key of MIME type overrides array must be a file extension, was "0" in %sfrontcontroller11.phar.php:2
Stack trace:
#0 %sfrontcontroller11.phar.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
#1 {main}
diff --git a/ext/phar/tests/zip/frontcontroller12.phar.phpt b/ext/phar/tests/zip/frontcontroller12.phar.phpt
index 504d037177..a74a0d5d32 100644
--- a/ext/phar/tests/zip/frontcontroller12.phar.phpt
+++ b/ext/phar/tests/zip/frontcontroller12.phar.phpt
@@ -14,7 +14,7 @@ files/frontcontroller6.phar.zip
--EXPECTHEADERS--
Content-type: text/html; charset=UTF-8
--EXPECTF--
-Fatal error: Uncaught exception 'PharException' with message 'Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed' in %sfrontcontroller12.phar.php:2
+Fatal error: Uncaught PharException: Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed in %sfrontcontroller12.phar.php:2
Stack trace:
#0 %sfrontcontroller12.phar.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
#1 {main}
diff --git a/ext/phar/tests/zip/frontcontroller13.phar.phpt b/ext/phar/tests/zip/frontcontroller13.phar.phpt
index 4b9e910a25..4ed1dc8670 100644
--- a/ext/phar/tests/zip/frontcontroller13.phar.phpt
+++ b/ext/phar/tests/zip/frontcontroller13.phar.phpt
@@ -14,7 +14,7 @@ files/frontcontroller7.phar.zip
--EXPECTHEADERS--
Content-type: text/html; charset=UTF-8
--EXPECTF--
-Fatal error: Uncaught exception 'PharException' with message 'Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed' in %sfrontcontroller13.phar.php:2
+Fatal error: Uncaught PharException: Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed in %sfrontcontroller13.phar.php:2
Stack trace:
#0 %sfrontcontroller13.phar.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
#1 {main}
diff --git a/ext/phar/tests/zip/frontcontroller18.phar.phpt b/ext/phar/tests/zip/frontcontroller18.phar.phpt
index dbd09cab15..3d01527122 100644
--- a/ext/phar/tests/zip/frontcontroller18.phar.phpt
+++ b/ext/phar/tests/zip/frontcontroller18.phar.phpt
@@ -10,7 +10,7 @@ PATH_INFO=/fronk.gronk
--FILE_EXTERNAL--
files/frontcontroller9.phar.zip
--EXPECTF--
-Fatal error: Uncaught exception 'PharException' with message 'No values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller18.phar.php:2
+Fatal error: Uncaught PharException: No values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME in %sfrontcontroller18.phar.php:2
Stack trace:
#0 %sfrontcontroller18.phar.php(2): Phar::mungServer(Array)
#1 {main}
diff --git a/ext/phar/tests/zip/frontcontroller19.phar.phpt b/ext/phar/tests/zip/frontcontroller19.phar.phpt
index 0eb87bfa60..db66ea48b0 100644
--- a/ext/phar/tests/zip/frontcontroller19.phar.phpt
+++ b/ext/phar/tests/zip/frontcontroller19.phar.phpt
@@ -10,7 +10,7 @@ PATH_INFO=/
--FILE_EXTERNAL--
files/frontcontroller10.phar.zip
--EXPECTF--
-Fatal error: Uncaught exception 'PharException' with message 'Too many values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller19.phar.php:2
+Fatal error: Uncaught PharException: Too many values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME in %sfrontcontroller19.phar.php:2
Stack trace:
#0 %sfrontcontroller19.phar.php(2): Phar::mungServer(Array)
#1 {main}
diff --git a/ext/phar/tests/zip/frontcontroller20.phar.phpt b/ext/phar/tests/zip/frontcontroller20.phar.phpt
index b1caf52da8..3bab3bfd80 100644
--- a/ext/phar/tests/zip/frontcontroller20.phar.phpt
+++ b/ext/phar/tests/zip/frontcontroller20.phar.phpt
@@ -10,7 +10,7 @@ PATH_INFO=/
--FILE_EXTERNAL--
files/frontcontroller11.phar.zip
--EXPECTF--
-Fatal error: Uncaught exception 'PharException' with message 'Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller20.phar.php:2
+Fatal error: Uncaught PharException: Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME in %sfrontcontroller20.phar.php:2
Stack trace:
#0 %sfrontcontroller20.phar.php(2): Phar::mungServer(Array)
#1 {main}
diff --git a/ext/phar/tests/zip/metadata_write_commit.phpt b/ext/phar/tests/zip/metadata_write_commit.phpt
index 1629636222..326695f825 100644
--- a/ext/phar/tests/zip/metadata_write_commit.phpt
+++ b/ext/phar/tests/zip/metadata_write_commit.phpt
@@ -3,7 +3,7 @@ Phar with meta-data (write) zip-based
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/zip/metadata_write_commitU.phpt b/ext/phar/tests/zip/metadata_write_commitU.phpt
index bc589af909..9e54ba7f6b 100644
--- a/ext/phar/tests/zip/metadata_write_commitU.phpt
+++ b/ext/phar/tests/zip/metadata_write_commitU.phpt
@@ -3,7 +3,7 @@ Phar with meta-data (write) zip-based
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/zip/phar_begin_setstub_commit.phpt b/ext/phar/tests/zip/phar_begin_setstub_commit.phpt
index dc59f2f3aa..5c42c29962 100644
--- a/ext/phar/tests/zip/phar_begin_setstub_commit.phpt
+++ b/ext/phar/tests/zip/phar_begin_setstub_commit.phpt
@@ -3,7 +3,7 @@ Phar::startBuffering()/setStub()/stopBuffering() zip-based
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
?>
--INI--
phar.readonly=0
diff --git a/ext/phar/tests/zip/phar_begin_setstub_commitU.phpt b/ext/phar/tests/zip/phar_begin_setstub_commitU.phpt
index 2956fc6f4a..ae38d59c5f 100644
--- a/ext/phar/tests/zip/phar_begin_setstub_commitU.phpt
+++ b/ext/phar/tests/zip/phar_begin_setstub_commitU.phpt
@@ -3,7 +3,7 @@ Phar::startBuffering()/setStub()/stopBuffering() zip-based
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
?>
--INI--
phar.readonly=0
diff --git a/ext/phar/tests/zip/phar_magic.phpt b/ext/phar/tests/zip/phar_magic.phpt
index 694f927773..b05e6974a8 100644
--- a/ext/phar/tests/zip/phar_magic.phpt
+++ b/ext/phar/tests/zip/phar_magic.phpt
@@ -3,7 +3,7 @@ Phar: include/fopen magic zip-based
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/zip/phar_magicU.phpt b/ext/phar/tests/zip/phar_magicU.phpt
index f034e4ede7..4f843bc378 100644
--- a/ext/phar/tests/zip/phar_magicU.phpt
+++ b/ext/phar/tests/zip/phar_magicU.phpt
@@ -3,7 +3,7 @@ Phar: include/fopen magic zip-based
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/util.c b/ext/phar/util.c
index 4bbd8676cb..eca33efc38 100644
--- a/ext/phar/util.c
+++ b/ext/phar/util.c
@@ -38,11 +38,11 @@
#include <openssl/ssl.h>
#include <openssl/pkcs12.h>
#else
-static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end, char *key, int key_len, char **signature, int *signature_len TSRMLS_DC);
+static int phar_call_openssl_signverify(int is_sign, php_stream *fp, zend_off_t end, char *key, int key_len, char **signature, int *signature_len);
#endif
/* for links to relative location, prepend cwd of the entry */
-static char *phar_get_link_location(phar_entry_info *entry TSRMLS_DC) /* {{{ */
+static char *phar_get_link_location(phar_entry_info *entry) /* {{{ */
{
char *p, *ret = NULL;
if (!entry->link) {
@@ -61,7 +61,7 @@ static char *phar_get_link_location(phar_entry_info *entry TSRMLS_DC) /* {{{ */
}
/* }}} */
-phar_entry_info *phar_get_link_source(phar_entry_info *entry TSRMLS_DC) /* {{{ */
+phar_entry_info *phar_get_link_source(phar_entry_info *entry) /* {{{ */
{
phar_entry_info *link_entry;
char *link;
@@ -70,13 +70,13 @@ phar_entry_info *phar_get_link_source(phar_entry_info *entry TSRMLS_DC) /* {{{ *
return entry;
}
- link = phar_get_link_location(entry TSRMLS_CC);
- if (SUCCESS == zend_hash_find(&(entry->phar->manifest), entry->link, strlen(entry->link), (void **)&link_entry) ||
- SUCCESS == zend_hash_find(&(entry->phar->manifest), link, strlen(link), (void **)&link_entry)) {
+ link = phar_get_link_location(entry);
+ if (NULL != (link_entry = zend_hash_str_find_ptr(&(entry->phar->manifest), entry->link, strlen(entry->link))) ||
+ NULL != (link_entry = zend_hash_str_find_ptr(&(entry->phar->manifest), link, strlen(link)))) {
if (link != entry->link) {
efree(link);
}
- return phar_get_link_source(link_entry TSRMLS_CC);
+ return phar_get_link_source(link_entry);
} else {
if (link != entry->link) {
efree(link);
@@ -87,24 +87,24 @@ phar_entry_info *phar_get_link_source(phar_entry_info *entry TSRMLS_DC) /* {{{ *
/* }}} */
/* retrieve a phar_entry_info's current file pointer for reading contents */
-php_stream *phar_get_efp(phar_entry_info *entry, int follow_links TSRMLS_DC) /* {{{ */
+php_stream *phar_get_efp(phar_entry_info *entry, int follow_links) /* {{{ */
{
if (follow_links && entry->link) {
- phar_entry_info *link_entry = phar_get_link_source(entry TSRMLS_CC);
+ phar_entry_info *link_entry = phar_get_link_source(entry);
if (link_entry && link_entry != entry) {
- return phar_get_efp(link_entry, 1 TSRMLS_CC);
+ return phar_get_efp(link_entry, 1);
}
}
- if (phar_get_fp_type(entry TSRMLS_CC) == PHAR_FP) {
- if (!phar_get_entrypfp(entry TSRMLS_CC)) {
+ if (phar_get_fp_type(entry) == PHAR_FP) {
+ if (!phar_get_entrypfp(entry)) {
/* re-open just in time for cases where our refcount reached 0 on the phar archive */
- phar_open_archive_fp(entry->phar TSRMLS_CC);
+ phar_open_archive_fp(entry->phar);
}
- return phar_get_entrypfp(entry TSRMLS_CC);
- } else if (phar_get_fp_type(entry TSRMLS_CC) == PHAR_UFP) {
- return phar_get_entrypufp(entry TSRMLS_CC);
+ return phar_get_entrypfp(entry);
+ } else if (phar_get_fp_type(entry) == PHAR_UFP) {
+ return phar_get_entrypufp(entry);
} else if (entry->fp_type == PHAR_MOD) {
return entry->fp;
} else {
@@ -117,10 +117,10 @@ php_stream *phar_get_efp(phar_entry_info *entry, int follow_links TSRMLS_DC) /*
}
/* }}} */
-int phar_seek_efp(phar_entry_info *entry, off_t offset, int whence, off_t position, int follow_links TSRMLS_DC) /* {{{ */
+int phar_seek_efp(phar_entry_info *entry, zend_off_t offset, int whence, zend_off_t position, int follow_links) /* {{{ */
{
- php_stream *fp = phar_get_efp(entry, follow_links TSRMLS_CC);
- off_t temp, eoffset;
+ php_stream *fp = phar_get_efp(entry, follow_links);
+ zend_off_t temp, eoffset;
if (!fp) {
return -1;
@@ -128,7 +128,7 @@ int phar_seek_efp(phar_entry_info *entry, off_t offset, int whence, off_t positi
if (follow_links) {
phar_entry_info *t;
- t = phar_get_link_source(entry TSRMLS_CC);
+ t = phar_get_link_source(entry);
if (t) {
entry = t;
}
@@ -138,7 +138,7 @@ int phar_seek_efp(phar_entry_info *entry, off_t offset, int whence, off_t positi
return 0;
}
- eoffset = phar_get_fp_offset(entry TSRMLS_CC);
+ eoffset = phar_get_fp_offset(entry);
switch (whence) {
case SEEK_END:
@@ -154,7 +154,7 @@ int phar_seek_efp(phar_entry_info *entry, off_t offset, int whence, off_t positi
temp = 0;
}
- if (temp > eoffset + (off_t) entry->uncompressed_filesize) {
+ if (temp > eoffset + (zend_off_t) entry->uncompressed_filesize) {
return -1;
}
@@ -167,7 +167,7 @@ int phar_seek_efp(phar_entry_info *entry, off_t offset, int whence, off_t positi
/* }}} */
/* mount an absolute path or uri to a path internal to the phar archive */
-int phar_mount_entry(phar_archive_data *phar, char *filename, int filename_len, char *path, int path_len TSRMLS_DC) /* {{{ */
+int phar_mount_entry(phar_archive_data *phar, char *filename, int filename_len, char *path, int path_len) /* {{{ */
{
phar_entry_info entry = {0};
php_stream_statbuf ssb;
@@ -194,7 +194,7 @@ int phar_mount_entry(phar_archive_data *phar, char *filename, int filename_len,
if (is_phar) {
entry.tmp = estrndup(filename, filename_len);
} else {
- entry.tmp = expand_filepath(filename, NULL TSRMLS_CC);
+ entry.tmp = expand_filepath(filename, NULL);
if (!entry.tmp) {
entry.tmp = estrndup(filename, filename_len);
}
@@ -209,7 +209,7 @@ int phar_mount_entry(phar_archive_data *phar, char *filename, int filename_len,
filename = entry.tmp;
/* only check openbasedir for files, not for phar streams */
- if (!is_phar && php_check_open_basedir(filename TSRMLS_CC)) {
+ if (!is_phar && php_check_open_basedir(filename)) {
efree(entry.tmp);
efree(entry.filename);
return FAILURE;
@@ -227,7 +227,7 @@ int phar_mount_entry(phar_archive_data *phar, char *filename, int filename_len,
if (ssb.sb.st_mode & S_IFDIR) {
entry.is_dir = 1;
- if (SUCCESS != zend_hash_add(&phar->mounted_dirs, entry.filename, path_len, (void *)&(entry.filename), sizeof(char *), NULL)) {
+ if (NULL == zend_hash_str_add_ptr(&phar->mounted_dirs, entry.filename, path_len, entry.filename)) {
/* directory already mounted */
efree(entry.tmp);
efree(entry.filename);
@@ -240,7 +240,7 @@ int phar_mount_entry(phar_archive_data *phar, char *filename, int filename_len,
entry.flags = ssb.sb.st_mode;
- if (SUCCESS == zend_hash_add(&phar->manifest, entry.filename, path_len, (void*)&entry, sizeof(phar_entry_info), NULL)) {
+ if (NULL != zend_hash_str_add_mem(&phar->manifest, entry.filename, path_len, (void*)&entry, sizeof(phar_entry_info))) {
return SUCCESS;
}
@@ -250,10 +250,11 @@ int phar_mount_entry(phar_archive_data *phar, char *filename, int filename_len,
}
/* }}} */
-char *phar_find_in_include_path(char *filename, int filename_len, phar_archive_data **pphar TSRMLS_DC) /* {{{ */
+zend_string *phar_find_in_include_path(char *filename, int filename_len, phar_archive_data **pphar) /* {{{ */
{
- char *path, *fname, *arch, *entry, *ret, *test;
- int arch_len, entry_len, fname_len, ret_len;
+ zend_string *ret;
+ char *path, *fname, *arch, *entry, *test;
+ int arch_len, entry_len, fname_len;
phar_archive_data *phar;
if (pphar) {
@@ -262,11 +263,11 @@ char *phar_find_in_include_path(char *filename, int filename_len, phar_archive_d
pphar = &phar;
}
- if (!zend_is_executing(TSRMLS_C) || !PHAR_G(cwd)) {
- return phar_save_resolve_path(filename, filename_len TSRMLS_CC);
+ if (!zend_is_executing() || !PHAR_G(cwd)) {
+ return phar_save_resolve_path(filename, filename_len);
}
- fname = (char*)zend_get_executed_filename(TSRMLS_C);
+ fname = (char*)zend_get_executed_filename();
fname_len = strlen(fname);
if (PHAR_G(last_phar) && !memcmp(fname, "phar://", 7) && fname_len - 7 >= PHAR_G(last_phar_name_len) && !memcmp(fname + 7, PHAR_G(last_phar_name), PHAR_G(last_phar_name_len))) {
@@ -276,8 +277,8 @@ char *phar_find_in_include_path(char *filename, int filename_len, phar_archive_d
goto splitted;
}
- if (fname_len < 7 || memcmp(fname, "phar://", 7) || SUCCESS != phar_split_fname(fname, strlen(fname), &arch, &arch_len, &entry, &entry_len, 1, 0 TSRMLS_CC)) {
- return phar_save_resolve_path(filename, filename_len TSRMLS_CC);
+ if (fname_len < 7 || memcmp(fname, "phar://", 7) || SUCCESS != phar_split_fname(fname, strlen(fname), &arch, &arch_len, &entry, &entry_len, 1, 0)) {
+ return phar_save_resolve_path(filename, filename_len);
}
efree(entry);
@@ -285,9 +286,9 @@ char *phar_find_in_include_path(char *filename, int filename_len, phar_archive_d
if (*filename == '.') {
int try_len;
- if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL TSRMLS_CC)) {
+ if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL)) {
efree(arch);
- return phar_save_resolve_path(filename, filename_len TSRMLS_CC);
+ return phar_save_resolve_path(filename, filename_len);
}
splitted:
if (pphar) {
@@ -295,18 +296,18 @@ splitted:
}
try_len = filename_len;
- test = phar_fix_filepath(estrndup(filename, filename_len), &try_len, 1 TSRMLS_CC);
+ test = phar_fix_filepath(estrndup(filename, filename_len), &try_len, 1);
if (*test == '/') {
- if (zend_hash_exists(&(phar->manifest), test + 1, try_len - 1)) {
- spprintf(&ret, 0, "phar://%s%s", arch, test);
+ if (zend_hash_str_exists(&(phar->manifest), test + 1, try_len - 1)) {
+ ret = strpprintf(0, "phar://%s%s", arch, test);
efree(arch);
efree(test);
return ret;
}
} else {
- if (zend_hash_exists(&(phar->manifest), test, try_len)) {
- spprintf(&ret, 0, "phar://%s/%s", arch, test);
+ if (zend_hash_str_exists(&(phar->manifest), test, try_len)) {
+ ret = strpprintf(0, "phar://%s/%s", arch, test);
efree(arch);
efree(test);
return ret;
@@ -317,21 +318,19 @@ splitted:
spprintf(&path, MAXPATHLEN, "phar://%s/%s%c%s", arch, PHAR_G(cwd), DEFAULT_DIR_SEPARATOR, PG(include_path));
efree(arch);
- ret = php_resolve_path(filename, filename_len, path TSRMLS_CC);
+ ret = php_resolve_path(filename, filename_len, path);
efree(path);
- if (ret && strlen(ret) > 8 && !strncmp(ret, "phar://", 7)) {
- ret_len = strlen(ret);
+ if (ret && ZSTR_LEN(ret) > 8 && !strncmp(ZSTR_VAL(ret), "phar://", 7)) {
/* found phar:// */
-
- if (SUCCESS != phar_split_fname(ret, ret_len, &arch, &arch_len, &entry, &entry_len, 1, 0 TSRMLS_CC)) {
+ if (SUCCESS != phar_split_fname(ZSTR_VAL(ret), ZSTR_LEN(ret), &arch, &arch_len, &entry, &entry_len, 1, 0)) {
return ret;
}
- zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), arch, arch_len, (void **) &pphar);
+ *pphar = zend_hash_str_find_ptr(&(PHAR_G(phar_fname_map)), arch, arch_len);
- if (!pphar && PHAR_G(manifest_cached)) {
- zend_hash_find(&cached_phars, arch, arch_len, (void **) &pphar);
+ if (!*pphar && PHAR_G(manifest_cached)) {
+ *pphar = zend_hash_str_find_ptr(&cached_phars, arch, arch_len);
}
efree(arch);
@@ -350,7 +349,7 @@ splitted:
* appended, truncated, or read. For read, if the entry is marked unmodified, it is
* assumed that the file pointer, if present, is opened for reading
*/
-int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len, char *path, int path_len, const char *mode, char allow_dir, char **error, int security TSRMLS_DC) /* {{{ */
+int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len, char *path, int path_len, const char *mode, char allow_dir, char **error, int security) /* {{{ */
{
phar_archive_data *phar;
phar_entry_info *entry;
@@ -369,7 +368,7 @@ int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len, char
*error = NULL;
}
- if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, error TSRMLS_CC)) {
+ if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, error)) {
return FAILURE;
}
@@ -388,14 +387,14 @@ int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len, char
}
really_get_entry:
if (allow_dir) {
- if ((entry = phar_get_entry_info_dir(phar, path, path_len, allow_dir, for_create && !PHAR_G(readonly) && !phar->is_data ? NULL : error, security TSRMLS_CC)) == NULL) {
+ if ((entry = phar_get_entry_info_dir(phar, path, path_len, allow_dir, for_create && !PHAR_G(readonly) && !phar->is_data ? NULL : error, security)) == NULL) {
if (for_create && (!PHAR_G(readonly) || phar->is_data)) {
return SUCCESS;
}
return FAILURE;
}
} else {
- if ((entry = phar_get_entry_info(phar, path, path_len, for_create && !PHAR_G(readonly) && !phar->is_data ? NULL : error, security TSRMLS_CC)) == NULL) {
+ if ((entry = phar_get_entry_info(phar, path, path_len, for_create && !PHAR_G(readonly) && !phar->is_data ? NULL : error, security)) == NULL) {
if (for_create && (!PHAR_G(readonly) || phar->is_data)) {
return SUCCESS;
}
@@ -404,7 +403,7 @@ really_get_entry:
}
if (for_write && phar->is_persistent) {
- if (FAILURE == phar_copy_on_write(&phar TSRMLS_CC)) {
+ if (FAILURE == phar_copy_on_write(&phar)) {
if (error) {
spprintf(error, 4096, "phar error: file \"%s\" in phar \"%s\" cannot be opened for writing, could not make cached phar writeable", path, fname);
}
@@ -455,11 +454,11 @@ really_get_entry:
if (entry->fp_type == PHAR_MOD) {
if (for_trunc) {
- if (FAILURE == phar_create_writeable_entry(phar, entry, error TSRMLS_CC)) {
+ if (FAILURE == phar_create_writeable_entry(phar, entry, error)) {
return FAILURE;
}
} else if (for_append) {
- phar_seek_efp(entry, 0, SEEK_END, 0, 0 TSRMLS_CC);
+ phar_seek_efp(entry, 0, SEEK_END, 0, 0);
}
} else {
if (for_write) {
@@ -470,16 +469,16 @@ really_get_entry:
}
if (for_trunc) {
- if (FAILURE == phar_create_writeable_entry(phar, entry, error TSRMLS_CC)) {
+ if (FAILURE == phar_create_writeable_entry(phar, entry, error)) {
return FAILURE;
}
} else {
- if (FAILURE == phar_separate_entry_fp(entry, error TSRMLS_CC)) {
+ if (FAILURE == phar_separate_entry_fp(entry, error)) {
return FAILURE;
}
}
} else {
- if (FAILURE == phar_open_entry_fp(entry, error, 1 TSRMLS_CC)) {
+ if (FAILURE == phar_open_entry_fp(entry, error, 1)) {
return FAILURE;
}
}
@@ -492,16 +491,16 @@ really_get_entry:
(*ret)->internal_file = entry;
(*ret)->is_zip = entry->is_zip;
(*ret)->is_tar = entry->is_tar;
- (*ret)->fp = phar_get_efp(entry, 1 TSRMLS_CC);
+ (*ret)->fp = phar_get_efp(entry, 1);
if (entry->link) {
- phar_entry_info *link = phar_get_link_source(entry TSRMLS_CC);
+ phar_entry_info *link = phar_get_link_source(entry);
if(!link) {
efree(*ret);
return FAILURE;
}
- (*ret)->zero = phar_get_fp_offset(link TSRMLS_CC);
+ (*ret)->zero = phar_get_fp_offset(link);
} else {
- (*ret)->zero = phar_get_fp_offset(entry TSRMLS_CC);
+ (*ret)->zero = phar_get_fp_offset(entry);
}
if (!phar->is_persistent) {
@@ -516,7 +515,7 @@ really_get_entry:
/**
* Create a new dummy file slot within a writeable phar for a newly created file
*/
-phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char *path, int path_len, const char *mode, char allow_dir, char **error, int security TSRMLS_DC) /* {{{ */
+phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char *path, int path_len, const char *mode, char allow_dir, char **error, int security) /* {{{ */
{
phar_archive_data *phar;
phar_entry_info *entry, etemp;
@@ -530,11 +529,11 @@ phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char
is_dir = (path_len && path[path_len - 1] == '/') ? 1 : 0;
- if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, error TSRMLS_CC)) {
+ if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, error)) {
return NULL;
}
- if (FAILURE == phar_get_entry_data(&ret, fname, fname_len, path, path_len, mode, allow_dir, error, security TSRMLS_CC)) {
+ if (FAILURE == phar_get_entry_data(&ret, fname, fname_len, path, path_len, mode, allow_dir, error, security)) {
return NULL;
} else if (ret) {
return ret;
@@ -547,7 +546,7 @@ phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char
return NULL;
}
- if (phar->is_persistent && FAILURE == phar_copy_on_write(&phar TSRMLS_CC)) {
+ if (phar->is_persistent && FAILURE == phar_copy_on_write(&phar)) {
if (error) {
spprintf(error, 4096, "phar error: file \"%s\" in phar \"%s\" cannot be created, could not make cached phar writeable", path, fname);
}
@@ -584,7 +583,7 @@ phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char
path_len--;
}
- phar_add_virtual_dirs(phar, path, path_len TSRMLS_CC);
+ phar_add_virtual_dirs(phar, path, path_len);
etemp.is_modified = 1;
etemp.timestamp = time(0);
etemp.is_crc_checked = 1;
@@ -597,7 +596,7 @@ phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char
etemp.tar_type = etemp.is_dir ? TAR_DIR : TAR_FILE;
}
- if (FAILURE == zend_hash_add(&phar->manifest, etemp.filename, path_len, (void*)&etemp, sizeof(phar_entry_info), (void **) &entry)) {
+ if (NULL == (entry = zend_hash_str_add_mem(&phar->manifest, etemp.filename, path_len, (void*)&etemp, sizeof(phar_entry_info)))) {
php_stream_close(etemp.fp);
if (error) {
spprintf(error, 0, "phar error: unable to add new entry \"%s\" to phar \"%s\"", etemp.filename, phar->fname);
@@ -628,19 +627,19 @@ phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char
/* }}} */
/* initialize a phar_archive_data's read-only fp for existing phar data */
-int phar_open_archive_fp(phar_archive_data *phar TSRMLS_DC) /* {{{ */
+int phar_open_archive_fp(phar_archive_data *phar) /* {{{ */
{
- if (phar_get_pharfp(phar TSRMLS_CC)) {
+ if (phar_get_pharfp(phar)) {
return SUCCESS;
}
- if (php_check_open_basedir(phar->fname TSRMLS_CC)) {
+ if (php_check_open_basedir(phar->fname)) {
return FAILURE;
}
- phar_set_pharfp(phar, php_stream_open_wrapper(phar->fname, "rb", IGNORE_URL|STREAM_MUST_SEEK|0, NULL) TSRMLS_CC);
+ phar_set_pharfp(phar, php_stream_open_wrapper(phar->fname, "rb", IGNORE_URL|STREAM_MUST_SEEK|0, NULL));
- if (!phar_get_pharfp(phar TSRMLS_CC)) {
+ if (!phar_get_pharfp(phar)) {
return FAILURE;
}
@@ -649,11 +648,11 @@ int phar_open_archive_fp(phar_archive_data *phar TSRMLS_DC) /* {{{ */
/* }}} */
/* copy file data from an existing to a new phar_entry_info that is not in the manifest */
-int phar_copy_entry_fp(phar_entry_info *source, phar_entry_info *dest, char **error TSRMLS_DC) /* {{{ */
+int phar_copy_entry_fp(phar_entry_info *source, phar_entry_info *dest, char **error) /* {{{ */
{
phar_entry_info *link;
- if (FAILURE == phar_open_entry_fp(source, error, 1 TSRMLS_CC)) {
+ if (FAILURE == phar_open_entry_fp(source, error, 1)) {
return FAILURE;
}
@@ -671,14 +670,14 @@ int phar_copy_entry_fp(phar_entry_info *source, phar_entry_info *dest, char **er
spprintf(error, 0, "phar error: unable to create temporary file");
return EOF;
}
- phar_seek_efp(source, 0, SEEK_SET, 0, 1 TSRMLS_CC);
- link = phar_get_link_source(source TSRMLS_CC);
+ phar_seek_efp(source, 0, SEEK_SET, 0, 1);
+ link = phar_get_link_source(source);
if (!link) {
link = source;
}
- if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(link, 0 TSRMLS_CC), dest->fp, link->uncompressed_filesize, NULL)) {
+ if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(link, 0), dest->fp, link->uncompressed_filesize, NULL)) {
php_stream_close(dest->fp);
dest->fp_type = PHAR_FP;
if (error) {
@@ -693,19 +692,19 @@ int phar_copy_entry_fp(phar_entry_info *source, phar_entry_info *dest, char **er
/* open and decompress a compressed phar entry
*/
-int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TSRMLS_DC) /* {{{ */
+int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links) /* {{{ */
{
php_stream_filter *filter;
phar_archive_data *phar = entry->phar;
char *filtername;
- off_t loc;
+ zend_off_t loc;
php_stream *ufp;
phar_entry_data dummy;
if (follow_links && entry->link) {
- phar_entry_info *link_entry = phar_get_link_source(entry TSRMLS_CC);
+ phar_entry_info *link_entry = phar_get_link_source(entry);
if (link_entry && link_entry != entry) {
- return phar_open_entry_fp(link_entry, error, 1 TSRMLS_CC);
+ return phar_open_entry_fp(link_entry, error, 1);
}
}
@@ -725,8 +724,8 @@ int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TS
return SUCCESS;
}
- if (!phar_get_pharfp(phar TSRMLS_CC)) {
- if (FAILURE == phar_open_archive_fp(phar TSRMLS_CC)) {
+ if (!phar_get_pharfp(phar)) {
+ if (FAILURE == phar_open_archive_fp(phar)) {
spprintf(error, 4096, "phar error: Cannot open phar archive \"%s\" for reading", phar->fname);
return FAILURE;
}
@@ -736,16 +735,16 @@ int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TS
dummy.internal_file = entry;
dummy.phar = phar;
dummy.zero = entry->offset;
- dummy.fp = phar_get_pharfp(phar TSRMLS_CC);
- if (FAILURE == phar_postprocess_file(&dummy, entry->crc32, error, 1 TSRMLS_CC)) {
+ dummy.fp = phar_get_pharfp(phar);
+ if (FAILURE == phar_postprocess_file(&dummy, entry->crc32, error, 1)) {
return FAILURE;
}
return SUCCESS;
}
- if (!phar_get_entrypufp(entry TSRMLS_CC)) {
- phar_set_entrypufp(entry, php_stream_fopen_tmpfile() TSRMLS_CC);
- if (!phar_get_entrypufp(entry TSRMLS_CC)) {
+ if (!phar_get_entrypufp(entry)) {
+ phar_set_entrypufp(entry, php_stream_fopen_tmpfile());
+ if (!phar_get_entrypufp(entry)) {
spprintf(error, 4096, "phar error: Cannot open temporary file for decompressing phar archive \"%s\" file \"%s\"", phar->fname, entry->filename);
return FAILURE;
}
@@ -754,15 +753,15 @@ int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TS
dummy.internal_file = entry;
dummy.phar = phar;
dummy.zero = entry->offset;
- dummy.fp = phar_get_pharfp(phar TSRMLS_CC);
- if (FAILURE == phar_postprocess_file(&dummy, entry->crc32, error, 1 TSRMLS_CC)) {
+ dummy.fp = phar_get_pharfp(phar);
+ if (FAILURE == phar_postprocess_file(&dummy, entry->crc32, error, 1)) {
return FAILURE;
}
- ufp = phar_get_entrypufp(entry TSRMLS_CC);
+ ufp = phar_get_entrypufp(entry);
if ((filtername = phar_decompress_filter(entry, 0)) != NULL) {
- filter = php_stream_filter_create(filtername, NULL, 0 TSRMLS_CC);
+ filter = php_stream_filter_create(filtername, NULL, 0);
} else {
filter = NULL;
}
@@ -777,21 +776,21 @@ int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TS
php_stream_seek(ufp, 0, SEEK_END);
loc = php_stream_tell(ufp);
php_stream_filter_append(&ufp->writefilters, filter);
- php_stream_seek(phar_get_entrypfp(entry TSRMLS_CC), phar_get_fp_offset(entry TSRMLS_CC), SEEK_SET);
+ php_stream_seek(phar_get_entrypfp(entry), phar_get_fp_offset(entry), SEEK_SET);
if (entry->uncompressed_filesize) {
- if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_entrypfp(entry TSRMLS_CC), ufp, entry->compressed_filesize, NULL)) {
+ if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_entrypfp(entry), ufp, entry->compressed_filesize, NULL)) {
spprintf(error, 4096, "phar error: internal corruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", phar->fname, entry->filename);
- php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ php_stream_filter_remove(filter, 1);
return FAILURE;
}
}
php_stream_filter_flush(filter, 1);
php_stream_flush(ufp);
- php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ php_stream_filter_remove(filter, 1);
- if (php_stream_tell(ufp) - loc != (off_t) entry->uncompressed_filesize) {
+ if (php_stream_tell(ufp) - loc != (zend_off_t) entry->uncompressed_filesize) {
spprintf(error, 4096, "phar error: internal corruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", phar->fname, entry->filename);
return FAILURE;
}
@@ -799,17 +798,17 @@ int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TS
entry->old_flags = entry->flags;
/* this is now the new location of the file contents within this fp */
- phar_set_fp_type(entry, PHAR_UFP, loc TSRMLS_CC);
+ phar_set_fp_type(entry, PHAR_UFP, loc);
dummy.zero = entry->offset;
dummy.fp = ufp;
- if (FAILURE == phar_postprocess_file(&dummy, entry->crc32, error, 0 TSRMLS_CC)) {
+ if (FAILURE == phar_postprocess_file(&dummy, entry->crc32, error, 0)) {
return FAILURE;
}
return SUCCESS;
}
/* }}} */
-int phar_create_writeable_entry(phar_archive_data *phar, phar_entry_info *entry, char **error TSRMLS_DC) /* {{{ */
+int phar_create_writeable_entry(phar_archive_data *phar, phar_entry_info *entry, char **error) /* {{{ */
{
if (entry->fp_type == PHAR_MOD) {
/* already newly created, truncate */
@@ -862,12 +861,12 @@ int phar_create_writeable_entry(phar_archive_data *phar, phar_entry_info *entry,
}
/* }}} */
-int phar_separate_entry_fp(phar_entry_info *entry, char **error TSRMLS_DC) /* {{{ */
+int phar_separate_entry_fp(phar_entry_info *entry, char **error) /* {{{ */
{
php_stream *fp;
phar_entry_info *link;
- if (FAILURE == phar_open_entry_fp(entry, error, 1 TSRMLS_CC)) {
+ if (FAILURE == phar_open_entry_fp(entry, error, 1)) {
return FAILURE;
}
@@ -880,14 +879,14 @@ int phar_separate_entry_fp(phar_entry_info *entry, char **error TSRMLS_DC) /* {{
spprintf(error, 0, "phar error: unable to create temporary file");
return FAILURE;
}
- phar_seek_efp(entry, 0, SEEK_SET, 0, 1 TSRMLS_CC);
- link = phar_get_link_source(entry TSRMLS_CC);
+ phar_seek_efp(entry, 0, SEEK_SET, 0, 1);
+ link = phar_get_link_source(entry);
if (!link) {
link = entry;
}
- if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(link, 0 TSRMLS_CC), fp, link->uncompressed_filesize, NULL)) {
+ if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(link, 0), fp, link->uncompressed_filesize, NULL)) {
if (error) {
spprintf(error, 4096, "phar error: cannot separate entry file \"%s\" contents in phar archive \"%s\" for write access", entry->filename, entry->phar->fname);
}
@@ -911,16 +910,16 @@ int phar_separate_entry_fp(phar_entry_info *entry, char **error TSRMLS_DC) /* {{
/**
* helper function to open an internal file's fp just-in-time
*/
-phar_entry_info * phar_open_jit(phar_archive_data *phar, phar_entry_info *entry, char **error TSRMLS_DC) /* {{{ */
+phar_entry_info * phar_open_jit(phar_archive_data *phar, phar_entry_info *entry, char **error) /* {{{ */
{
if (error) {
*error = NULL;
}
/* seek to start of internal file and read it */
- if (FAILURE == phar_open_entry_fp(entry, error, 1 TSRMLS_CC)) {
+ if (FAILURE == phar_open_entry_fp(entry, error, 1)) {
return NULL;
}
- if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 1 TSRMLS_CC)) {
+ if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 1)) {
spprintf(error, 4096, "phar error: cannot seek to start of file \"%s\" in phar \"%s\"", entry->filename, phar->fname);
return NULL;
}
@@ -928,26 +927,26 @@ phar_entry_info * phar_open_jit(phar_archive_data *phar, phar_entry_info *entry,
}
/* }}} */
-PHP_PHAR_API int phar_resolve_alias(char *alias, int alias_len, char **filename, int *filename_len TSRMLS_DC) /* {{{ */ {
- phar_archive_data **fd_ptr;
- if (PHAR_GLOBALS->phar_alias_map.arBuckets
- && SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void**)&fd_ptr)) {
- *filename = (*fd_ptr)->fname;
- *filename_len = (*fd_ptr)->fname_len;
+PHP_PHAR_API int phar_resolve_alias(char *alias, int alias_len, char **filename, int *filename_len) /* {{{ */ {
+ phar_archive_data *fd_ptr;
+ if (PHAR_G(phar_alias_map.u.flags)
+ && NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len))) {
+ *filename = fd_ptr->fname;
+ *filename_len = fd_ptr->fname_len;
return SUCCESS;
}
return FAILURE;
}
/* }}} */
-int phar_free_alias(phar_archive_data *phar, char *alias, int alias_len TSRMLS_DC) /* {{{ */
+int phar_free_alias(phar_archive_data *phar, char *alias, int alias_len) /* {{{ */
{
if (phar->refcount || phar->is_persistent) {
return FAILURE;
}
/* this archive has no open references, so emit an E_STRICT and remove it */
- if (zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), phar->fname, phar->fname_len) != SUCCESS) {
+ if (zend_hash_str_del(&(PHAR_G(phar_fname_map)), phar->fname, phar->fname_len) != SUCCESS) {
return FAILURE;
}
@@ -963,14 +962,13 @@ int phar_free_alias(phar_archive_data *phar, char *alias, int alias_len TSRMLS_D
* Looks up a phar archive in the filename map, connecting it to the alias
* (if any) or returns null
*/
-int phar_get_archive(phar_archive_data **archive, char *fname, int fname_len, char *alias, int alias_len, char **error TSRMLS_DC) /* {{{ */
+int phar_get_archive(phar_archive_data **archive, char *fname, int fname_len, char *alias, int alias_len, char **error) /* {{{ */
{
- phar_archive_data *fd, **fd_ptr;
+ phar_archive_data *fd, *fd_ptr;
char *my_realpath, *save;
int save_len;
- ulong fhash, ahash = 0;
- phar_request_initialize(TSRMLS_C);
+ phar_request_initialize();
if (error) {
*error = NULL;
@@ -990,11 +988,11 @@ int phar_get_archive(phar_archive_data **archive, char *fname, int fname_len, ch
return FAILURE;
}
- if (PHAR_G(last_phar)->alias_len && SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), PHAR_G(last_phar)->alias, PHAR_G(last_phar)->alias_len, (void**)&fd_ptr)) {
- zend_hash_del(&(PHAR_GLOBALS->phar_alias_map), PHAR_G(last_phar)->alias, PHAR_G(last_phar)->alias_len);
+ if (PHAR_G(last_phar)->alias_len && NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), PHAR_G(last_phar)->alias, PHAR_G(last_phar)->alias_len))) {
+ zend_hash_str_del(&(PHAR_G(phar_alias_map)), PHAR_G(last_phar)->alias, PHAR_G(last_phar)->alias_len);
}
- zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void*)&(*archive), sizeof(phar_archive_data*), NULL);
+ zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len, *archive);
PHAR_G(last_alias) = alias;
PHAR_G(last_alias_len) = alias_len;
}
@@ -1004,19 +1002,18 @@ int phar_get_archive(phar_archive_data **archive, char *fname, int fname_len, ch
if (alias && alias_len && PHAR_G(last_phar) && alias_len == PHAR_G(last_alias_len) && !memcmp(alias, PHAR_G(last_alias), alias_len)) {
fd = PHAR_G(last_phar);
- fd_ptr = &fd;
+ fd_ptr = fd;
goto alias_success;
}
if (alias && alias_len) {
- ahash = zend_inline_hash_func(alias, alias_len);
- if (SUCCESS == zend_hash_quick_find(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, ahash, (void**)&fd_ptr)) {
+ if (NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len))) {
alias_success:
- if (fname && (fname_len != (*fd_ptr)->fname_len || strncmp(fname, (*fd_ptr)->fname, fname_len))) {
+ if (fname && (fname_len != fd_ptr->fname_len || strncmp(fname, fd_ptr->fname, fname_len))) {
if (error) {
- spprintf(error, 0, "alias \"%s\" is already used for archive \"%s\" cannot be overloaded with \"%s\"", alias, (*fd_ptr)->fname, fname);
+ spprintf(error, 0, "alias \"%s\" is already used for archive \"%s\" cannot be overloaded with \"%s\"", alias, fd_ptr->fname, fname);
}
- if (SUCCESS == phar_free_alias(*fd_ptr, alias, alias_len TSRMLS_CC)) {
+ if (SUCCESS == phar_free_alias(fd_ptr, alias, alias_len)) {
if (error) {
efree(*error);
*error = NULL;
@@ -1025,8 +1022,8 @@ alias_success:
return FAILURE;
}
- *archive = *fd_ptr;
- fd = *fd_ptr;
+ *archive = fd_ptr;
+ fd = fd_ptr;
PHAR_G(last_phar) = fd;
PHAR_G(last_phar_name) = fd->fname;
PHAR_G(last_phar_name_len) = fd->fname_len;
@@ -1036,34 +1033,33 @@ alias_success:
return SUCCESS;
}
- if (PHAR_G(manifest_cached) && SUCCESS == zend_hash_quick_find(&cached_alias, alias, alias_len, ahash, (void **)&fd_ptr)) {
+ if (PHAR_G(manifest_cached) && NULL != (fd_ptr = zend_hash_str_find_ptr(&cached_alias, alias, alias_len))) {
goto alias_success;
}
}
- fhash = zend_inline_hash_func(fname, fname_len);
my_realpath = NULL;
save = fname;
save_len = fname_len;
if (fname && fname_len) {
- if (SUCCESS == zend_hash_quick_find(&(PHAR_GLOBALS->phar_fname_map), fname, fname_len, fhash, (void**)&fd_ptr)) {
- *archive = *fd_ptr;
- fd = *fd_ptr;
+ if (NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_fname_map)), fname, fname_len))) {
+ *archive = fd_ptr;
+ fd = fd_ptr;
if (alias && alias_len) {
if (!fd->is_temporary_alias && (alias_len != fd->alias_len || memcmp(fd->alias, alias, alias_len))) {
if (error) {
- spprintf(error, 0, "alias \"%s\" is already used for archive \"%s\" cannot be overloaded with \"%s\"", alias, (*fd_ptr)->fname, fname);
+ spprintf(error, 0, "alias \"%s\" is already used for archive \"%s\" cannot be overloaded with \"%s\"", alias, fd_ptr->fname, fname);
}
return FAILURE;
}
- if (fd->alias_len && SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), fd->alias, fd->alias_len, (void**)&fd_ptr)) {
- zend_hash_del(&(PHAR_GLOBALS->phar_alias_map), fd->alias, fd->alias_len);
+ if (fd->alias_len && NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), fd->alias, fd->alias_len))) {
+ zend_hash_str_del(&(PHAR_G(phar_alias_map)), fd->alias, fd->alias_len);
}
- zend_hash_quick_add(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, ahash, (void*)&fd, sizeof(phar_archive_data*), NULL);
+ zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len, fd);
}
PHAR_G(last_phar) = fd;
@@ -1075,16 +1071,16 @@ alias_success:
return SUCCESS;
}
- if (PHAR_G(manifest_cached) && SUCCESS == zend_hash_quick_find(&cached_phars, fname, fname_len, fhash, (void**)&fd_ptr)) {
- *archive = *fd_ptr;
- fd = *fd_ptr;
+ if (PHAR_G(manifest_cached) && NULL != (fd_ptr = zend_hash_str_find_ptr(&cached_phars, fname, fname_len))) {
+ *archive = fd_ptr;
+ fd = fd_ptr;
/* this could be problematic - alias should never be different from manifest alias
for cached phars */
if (!fd->is_temporary_alias && alias && alias_len) {
if (alias_len != fd->alias_len || memcmp(fd->alias, alias, alias_len)) {
if (error) {
- spprintf(error, 0, "alias \"%s\" is already used for archive \"%s\" cannot be overloaded with \"%s\"", alias, (*fd_ptr)->fname, fname);
+ spprintf(error, 0, "alias \"%s\" is already used for archive \"%s\" cannot be overloaded with \"%s\"", alias, fd_ptr->fname, fname);
}
return FAILURE;
}
@@ -1099,8 +1095,8 @@ alias_success:
return SUCCESS;
}
- if (SUCCESS == zend_hash_quick_find(&(PHAR_GLOBALS->phar_alias_map), save, save_len, fhash, (void**)&fd_ptr)) {
- fd = *archive = *fd_ptr;
+ if (NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), save, save_len))) {
+ fd = *archive = fd_ptr;
PHAR_G(last_phar) = fd;
PHAR_G(last_phar_name) = fd->fname;
@@ -1111,8 +1107,8 @@ alias_success:
return SUCCESS;
}
- if (PHAR_G(manifest_cached) && SUCCESS == zend_hash_quick_find(&cached_alias, save, save_len, fhash, (void**)&fd_ptr)) {
- fd = *archive = *fd_ptr;
+ if (PHAR_G(manifest_cached) && NULL != (fd_ptr = zend_hash_str_find_ptr(&cached_alias, save, save_len))) {
+ fd = *archive = fd_ptr;
PHAR_G(last_phar) = fd;
PHAR_G(last_phar_name) = fd->fname;
@@ -1124,7 +1120,7 @@ alias_success:
}
/* not found, try converting \ to / */
- my_realpath = expand_filepath(fname, my_realpath TSRMLS_CC);
+ my_realpath = expand_filepath(fname, my_realpath);
if (my_realpath) {
fname_len = strlen(my_realpath);
@@ -1135,15 +1131,14 @@ alias_success:
#ifdef PHP_WIN32
phar_unixify_path_separators(fname, fname_len);
#endif
- fhash = zend_inline_hash_func(fname, fname_len);
- if (SUCCESS == zend_hash_quick_find(&(PHAR_GLOBALS->phar_fname_map), fname, fname_len, fhash, (void**)&fd_ptr)) {
+ if (NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_fname_map)), fname, fname_len))) {
realpath_success:
- *archive = *fd_ptr;
- fd = *fd_ptr;
+ *archive = fd_ptr;
+ fd = fd_ptr;
if (alias && alias_len) {
- zend_hash_quick_add(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, ahash, (void*)&fd, sizeof(phar_archive_data*), NULL);
+ zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len, fd);
}
efree(my_realpath);
@@ -1157,7 +1152,7 @@ realpath_success:
return SUCCESS;
}
- if (PHAR_G(manifest_cached) && SUCCESS == zend_hash_quick_find(&cached_phars, fname, fname_len, fhash, (void**)&fd_ptr)) {
+ if (PHAR_G(manifest_cached) && NULL != (fd_ptr = zend_hash_str_find_ptr(&cached_phars, fname, fname_len))) {
goto realpath_success;
}
@@ -1211,9 +1206,9 @@ char * phar_decompress_filter(phar_entry_info * entry, int return_unknown) /* {{
/**
* retrieve information on a file contained within a phar, or null if it ain't there
*/
-phar_entry_info *phar_get_entry_info(phar_archive_data *phar, char *path, int path_len, char **error, int security TSRMLS_DC) /* {{{ */
+phar_entry_info *phar_get_entry_info(phar_archive_data *phar, char *path, int path_len, char **error, int security) /* {{{ */
{
- return phar_get_entry_info_dir(phar, path, path_len, 0, error, security TSRMLS_CC);
+ return phar_get_entry_info_dir(phar, path, path_len, 0, error, security);
}
/* }}} */
/**
@@ -1221,7 +1216,7 @@ phar_entry_info *phar_get_entry_info(phar_archive_data *phar, char *path, int pa
* allow_dir is 0 for none, 1 for both empty directories in the phar and temp directories, and 2 for only
* valid pre-existing empty directory entries
*/
-phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, int path_len, char dir, char **error, int security TSRMLS_DC) /* {{{ */
+phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, int path_len, char dir, char **error, int security) /* {{{ */
{
const char *pcr_error;
phar_entry_info *entry;
@@ -1258,7 +1253,7 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in
return NULL;
}
- if (!phar->manifest.arBuckets) {
+ if (!phar->manifest.u.flags) {
return NULL;
}
@@ -1269,7 +1264,7 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in
path_len--;
}
- if (SUCCESS == zend_hash_find(&phar->manifest, path, path_len, (void**)&entry)) {
+ if (NULL != (entry = zend_hash_str_find_ptr(&phar->manifest, path, path_len))) {
if (entry->is_deleted) {
/* entry is deleted, but has not been flushed to disk yet */
return NULL;
@@ -1291,7 +1286,7 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in
}
if (dir) {
- if (zend_hash_exists(&phar->virtual_dirs, path, path_len)) {
+ if (zend_hash_str_exists(&phar->virtual_dirs, path, path_len)) {
/* a file or directory exists in a sub-directory of this path */
entry = (phar_entry_info *) ecalloc(1, sizeof(phar_entry_info));
/* this next line tells PharFileInfo->__destruct() to efree the filename */
@@ -1303,39 +1298,32 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in
}
}
- if (phar->mounted_dirs.arBuckets && zend_hash_num_elements(&phar->mounted_dirs)) {
- char *str_key;
- ulong unused;
- uint keylen;
-
- zend_hash_internal_pointer_reset(&phar->mounted_dirs);
- while (FAILURE != zend_hash_has_more_elements(&phar->mounted_dirs)) {
- if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(&phar->mounted_dirs, &str_key, &keylen, &unused, 0, NULL)) {
- break;
- }
+ if (phar->mounted_dirs.u.flags && zend_hash_num_elements(&phar->mounted_dirs)) {
+ zend_string *str_key;
- if ((int)keylen >= path_len || strncmp(str_key, path, keylen)) {
+ ZEND_HASH_FOREACH_STR_KEY(&phar->mounted_dirs, str_key) {
+ if ((int)ZSTR_LEN(str_key) >= path_len || strncmp(ZSTR_VAL(str_key), path, ZSTR_LEN(str_key))) {
continue;
} else {
char *test;
int test_len;
php_stream_statbuf ssb;
- if (SUCCESS != zend_hash_find(&phar->manifest, str_key, keylen, (void **) &entry)) {
+ if (NULL == (entry = zend_hash_find_ptr(&phar->manifest, str_key))) {
if (error) {
- spprintf(error, 4096, "phar internal error: mounted path \"%s\" could not be retrieved from manifest", str_key);
+ spprintf(error, 4096, "phar internal error: mounted path \"%s\" could not be retrieved from manifest", ZSTR_VAL(str_key));
}
return NULL;
}
if (!entry->tmp || !entry->is_mounted) {
if (error) {
- spprintf(error, 4096, "phar internal error: mounted path \"%s\" is not properly initialized as a mounted path", str_key);
+ spprintf(error, 4096, "phar internal error: mounted path \"%s\" is not properly initialized as a mounted path", ZSTR_VAL(str_key));
}
return NULL;
}
- test_len = spprintf(&test, MAXPATHLEN, "%s%s", entry->tmp, path + keylen);
+ test_len = spprintf(&test, MAXPATHLEN, "%s%s", entry->tmp, path + ZSTR_LEN(str_key));
if (SUCCESS != php_stream_stat_path(test, &ssb)) {
efree(test);
@@ -1360,7 +1348,7 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in
}
/* mount the file just in time */
- if (SUCCESS != phar_mount_entry(phar, test, test_len, path, path_len TSRMLS_CC)) {
+ if (SUCCESS != phar_mount_entry(phar, test, test_len, path, path_len)) {
efree(test);
if (error) {
spprintf(error, 4096, "phar error: path \"%s\" exists as file \"%s\" and could not be mounted", path, test);
@@ -1370,7 +1358,7 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in
efree(test);
- if (SUCCESS != zend_hash_find(&phar->manifest, path, path_len, (void**)&entry)) {
+ if (NULL == (entry = zend_hash_str_find_ptr(&phar->manifest, path, path_len))) {
if (error) {
spprintf(error, 4096, "phar error: path \"%s\" exists as file \"%s\" and could not be retrieved after being mounted", path, test);
}
@@ -1378,7 +1366,7 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in
}
return entry;
}
- }
+ } ZEND_HASH_FOREACH_END();
}
return NULL;
@@ -1387,7 +1375,7 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in
static const char hexChars[] = "0123456789ABCDEF";
-static int phar_hex_str(const char *digest, size_t digest_len, char **signature TSRMLS_DC) /* {{{ */
+static int phar_hex_str(const char *digest, size_t digest_len, char **signature) /* {{{ */
{
int pos = -1;
size_t len = 0;
@@ -1404,123 +1392,98 @@ static int phar_hex_str(const char *digest, size_t digest_len, char **signature
/* }}} */
#ifndef PHAR_HAVE_OPENSSL
-static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end, char *key, int key_len, char **signature, int *signature_len TSRMLS_DC) /* {{{ */
+static int phar_call_openssl_signverify(int is_sign, php_stream *fp, zend_off_t end, char *key, int key_len, char **signature, int *signature_len) /* {{{ */
{
zend_fcall_info fci;
zend_fcall_info_cache fcc;
- zval *zdata, *zsig, *zkey, *retval_ptr, **zp[3], *openssl;
-
- MAKE_STD_ZVAL(zdata);
- MAKE_STD_ZVAL(openssl);
- ZVAL_STRINGL(openssl, is_sign ? "openssl_sign" : "openssl_verify", is_sign ? sizeof("openssl_sign")-1 : sizeof("openssl_verify")-1, 1);
- MAKE_STD_ZVAL(zsig);
- ZVAL_STRINGL(zsig, *signature, *signature_len, 1);
- MAKE_STD_ZVAL(zkey);
- ZVAL_STRINGL(zkey, key, key_len, 1);
- zp[0] = &zdata;
- zp[1] = &zsig;
- zp[2] = &zkey;
+ zval retval, zp[3], openssl;
+ zend_string *str;
+ ZVAL_STRINGL(&openssl, is_sign ? "openssl_sign" : "openssl_verify", is_sign ? sizeof("openssl_sign")-1 : sizeof("openssl_verify")-1);
+ ZVAL_STRINGL(&zp[1], *signature, *signature_len);
+ ZVAL_STRINGL(&zp[2], key, key_len);
php_stream_rewind(fp);
- Z_TYPE_P(zdata) = IS_STRING;
- Z_STRLEN_P(zdata) = end;
-
- if (end != (off_t) php_stream_copy_to_mem(fp, &(Z_STRVAL_P(zdata)), (size_t) end, 0)) {
- zval_dtor(zdata);
- zval_dtor(zsig);
- zval_dtor(zkey);
- zval_dtor(openssl);
- efree(openssl);
- efree(zdata);
- efree(zkey);
- efree(zsig);
+ str = php_stream_copy_to_mem(fp, (size_t) end, 0);
+ if (str) {
+ ZVAL_STR(&zp[0], str);
+ } else {
+ ZVAL_EMPTY_STRING(&zp[0]);
+ }
+
+ if (end != Z_STRLEN(zp[0])) {
+ zval_dtor(&zp[0]);
+ zval_dtor(&zp[1]);
+ zval_dtor(&zp[2]);
+ zval_dtor(&openssl);
return FAILURE;
}
- if (FAILURE == zend_fcall_info_init(openssl, 0, &fci, &fcc, NULL, NULL TSRMLS_CC)) {
- zval_dtor(zdata);
- zval_dtor(zsig);
- zval_dtor(zkey);
- zval_dtor(openssl);
- efree(openssl);
- efree(zdata);
- efree(zkey);
- efree(zsig);
+ if (FAILURE == zend_fcall_info_init(&openssl, 0, &fci, &fcc, NULL, NULL)) {
+ zval_dtor(&zp[0]);
+ zval_dtor(&zp[1]);
+ zval_dtor(&zp[2]);
+ zval_dtor(&openssl);
return FAILURE;
}
fci.param_count = 3;
fci.params = zp;
- Z_ADDREF_P(zdata);
+ Z_ADDREF(zp[0]);
if (is_sign) {
- Z_SET_ISREF_P(zsig);
+ ZVAL_NEW_REF(&zp[1], &zp[1]);
} else {
- Z_ADDREF_P(zsig);
+ Z_ADDREF(zp[1]);
}
- Z_ADDREF_P(zkey);
+ Z_ADDREF(zp[2]);
- fci.retval_ptr_ptr = &retval_ptr;
+ fci.retval = &retval;
- if (FAILURE == zend_call_function(&fci, &fcc TSRMLS_CC)) {
- zval_dtor(zdata);
- zval_dtor(zsig);
- zval_dtor(zkey);
- zval_dtor(openssl);
- efree(openssl);
- efree(zdata);
- efree(zkey);
- efree(zsig);
+ if (FAILURE == zend_call_function(&fci, &fcc)) {
+ zval_dtor(&zp[0]);
+ zval_dtor(&zp[1]);
+ zval_dtor(&zp[2]);
+ zval_dtor(&openssl);
return FAILURE;
}
- zval_dtor(openssl);
- efree(openssl);
- Z_DELREF_P(zdata);
+ zval_dtor(&openssl);
+ Z_DELREF(zp[0]);
if (is_sign) {
- Z_UNSET_ISREF_P(zsig);
+ ZVAL_UNREF(&zp[1]);
} else {
- Z_DELREF_P(zsig);
+ Z_DELREF(zp[1]);
}
- Z_DELREF_P(zkey);
+ Z_DELREF(zp[2]);
- zval_dtor(zdata);
- efree(zdata);
- zval_dtor(zkey);
- efree(zkey);
+ zval_dtor(&zp[0]);
+ zval_dtor(&zp[2]);
- switch (Z_TYPE_P(retval_ptr)) {
+ switch (Z_TYPE(retval)) {
default:
case IS_LONG:
- zval_dtor(zsig);
- efree(zsig);
- if (1 == Z_LVAL_P(retval_ptr)) {
- efree(retval_ptr);
+ zval_dtor(&zp[1]);
+ if (1 == Z_LVAL(retval)) {
return SUCCESS;
}
- efree(retval_ptr);
return FAILURE;
- case IS_BOOL:
- efree(retval_ptr);
- if (Z_BVAL_P(retval_ptr)) {
- *signature = estrndup(Z_STRVAL_P(zsig), Z_STRLEN_P(zsig));
- *signature_len = Z_STRLEN_P(zsig);
- zval_dtor(zsig);
- efree(zsig);
- return SUCCESS;
- }
- zval_dtor(zsig);
- efree(zsig);
+ case IS_TRUE:
+ *signature = estrndup(Z_STRVAL(zp[1]), Z_STRLEN(zp[1]));
+ *signature_len = Z_STRLEN(zp[1]);
+ zval_dtor(&zp[1]);
+ return SUCCESS;
+ case IS_FALSE:
+ zval_dtor(&zp[1]);
return FAILURE;
}
}
/* }}} */
#endif /* #ifndef PHAR_HAVE_OPENSSL */
-int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_type, char *sig, int sig_len, char *fname, char **signature, int *signature_len, char **error TSRMLS_DC) /* {{{ */
+int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_type, char *sig, int sig_len, char *fname, char **signature, int *signature_len, char **error) /* {{{ */
{
int read_size, len;
- off_t read_len;
+ zend_off_t read_len;
unsigned char buf[1024];
php_stream_rewind(fp);
@@ -1535,11 +1498,11 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
#else
int tempsig;
#endif
- php_uint32 pubkey_len;
- char *pubkey = NULL, *pfile;
+ zend_string *pubkey = NULL;
+ char *pfile;
php_stream *pfp;
#ifndef PHAR_HAVE_OPENSSL
- if (!zend_hash_exists(&module_registry, "openssl", sizeof("openssl"))) {
+ if (!zend_hash_str_exists(&module_registry, "openssl", sizeof("openssl")-1)) {
if (error) {
spprintf(error, 0, "openssl not loaded");
}
@@ -1551,11 +1514,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
pfp = php_stream_open_wrapper(pfile, "rb", 0, NULL);
efree(pfile);
-#if PHP_MAJOR_VERSION > 5
- if (!pfp || !(pubkey_len = php_stream_copy_to_mem(pfp, (void **) &pubkey, PHP_STREAM_COPY_ALL, 0)) || !pubkey) {
-#else
- if (!pfp || !(pubkey_len = php_stream_copy_to_mem(pfp, &pubkey, PHP_STREAM_COPY_ALL, 0)) || !pubkey) {
-#endif
+ if (!pfp || !(pubkey = php_stream_copy_to_mem(pfp, PHP_STREAM_COPY_ALL, 0)) || !ZSTR_LEN(pubkey)) {
if (pfp) {
php_stream_close(pfp);
}
@@ -1569,9 +1528,9 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
#ifndef PHAR_HAVE_OPENSSL
tempsig = sig_len;
- if (FAILURE == phar_call_openssl_signverify(0, fp, end_of_phar, pubkey, pubkey_len, &sig, &tempsig TSRMLS_CC)) {
+ if (FAILURE == phar_call_openssl_signverify(0, fp, end_of_phar, pubkey ? ZSTR_VAL(pubkey) : NULL, pubkey ? ZSTR_LEN(pubkey) : 0, &sig, &tempsig)) {
if (pubkey) {
- efree(pubkey);
+ zend_string_release(pubkey);
}
if (error) {
@@ -1582,15 +1541,15 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
}
if (pubkey) {
- efree(pubkey);
+ zend_string_release(pubkey);
}
sig_len = tempsig;
#else
- in = BIO_new_mem_buf(pubkey, pubkey_len);
+ in = BIO_new_mem_buf(pubkey ? ZSTR_VAL(pubkey) : NULL, pubkey ? ZSTR_LEN(pubkey) : 0);
if (NULL == in) {
- efree(pubkey);
+ zend_string_release(pubkey);
if (error) {
spprintf(error, 0, "openssl signature could not be processed");
}
@@ -1599,7 +1558,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
key = PEM_read_bio_PUBKEY(in, NULL,NULL, NULL);
BIO_free(in);
- efree(pubkey);
+ zend_string_release(pubkey);
if (NULL == key) {
if (error) {
@@ -1621,7 +1580,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
while (read_size && (len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
EVP_VerifyUpdate (&md_ctx, buf, len);
- read_len -= (off_t)len;
+ read_len -= (zend_off_t)len;
if (read_len < read_size) {
read_size = (int)read_len;
@@ -1642,7 +1601,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
EVP_MD_CTX_cleanup(&md_ctx);
#endif
- *signature_len = phar_hex_str((const char*)sig, sig_len, signature TSRMLS_CC);
+ *signature_len = phar_hex_str((const char*)sig, sig_len, signature);
}
break;
#ifdef PHAR_HASH_OK
@@ -1661,7 +1620,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
PHP_SHA512Update(&context, buf, len);
- read_len -= (off_t)len;
+ read_len -= (zend_off_t)len;
if (read_len < read_size) {
read_size = (int)read_len;
}
@@ -1676,7 +1635,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
return FAILURE;
}
- *signature_len = phar_hex_str((const char*)digest, sizeof(digest), signature TSRMLS_CC);
+ *signature_len = phar_hex_str((const char*)digest, sizeof(digest), signature);
break;
}
case PHAR_SIG_SHA256: {
@@ -1694,7 +1653,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
PHP_SHA256Update(&context, buf, len);
- read_len -= (off_t)len;
+ read_len -= (zend_off_t)len;
if (read_len < read_size) {
read_size = (int)read_len;
}
@@ -1709,7 +1668,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
return FAILURE;
}
- *signature_len = phar_hex_str((const char*)digest, sizeof(digest), signature TSRMLS_CC);
+ *signature_len = phar_hex_str((const char*)digest, sizeof(digest), signature);
break;
}
#else
@@ -1735,7 +1694,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
PHP_SHA1Update(&context, buf, len);
- read_len -= (off_t)len;
+ read_len -= (zend_off_t)len;
if (read_len < read_size) {
read_size = (int)read_len;
}
@@ -1750,7 +1709,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
return FAILURE;
}
- *signature_len = phar_hex_str((const char*)digest, sizeof(digest), signature TSRMLS_CC);
+ *signature_len = phar_hex_str((const char*)digest, sizeof(digest), signature);
break;
}
case PHAR_SIG_MD5: {
@@ -1768,7 +1727,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
PHP_MD5Update(&context, buf, len);
- read_len -= (off_t)len;
+ read_len -= (zend_off_t)len;
if (read_len < read_size) {
read_size = (int)read_len;
}
@@ -1783,7 +1742,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
return FAILURE;
}
- *signature_len = phar_hex_str((const char*)digest, sizeof(digest), signature TSRMLS_CC);
+ *signature_len = phar_hex_str((const char*)digest, sizeof(digest), signature);
break;
}
default:
@@ -1796,7 +1755,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
}
/* }}} */
-int phar_create_signature(phar_archive_data *phar, php_stream *fp, char **signature, int *signature_length, char **error TSRMLS_DC) /* {{{ */
+int phar_create_signature(phar_archive_data *phar, php_stream *fp, char **signature, int *signature_length, char **error) /* {{{ */
{
unsigned char buf[1024];
int sig_len;
@@ -1914,7 +1873,7 @@ int phar_create_signature(phar_archive_data *phar, php_stream *fp, char **signat
siglen = 0;
php_stream_seek(fp, 0, SEEK_END);
- if (FAILURE == phar_call_openssl_signverify(1, fp, php_stream_tell(fp), PHAR_G(openssl_privatekey), PHAR_G(openssl_privatekey_len), (char **)&sigbuf, &siglen TSRMLS_CC)) {
+ if (FAILURE == phar_call_openssl_signverify(1, fp, php_stream_tell(fp), PHAR_G(openssl_privatekey), PHAR_G(openssl_privatekey_len), (char **)&sigbuf, &siglen)) {
if (error) {
spprintf(error, 0, "unable to write phar \"%s\" with requested openssl signature", phar->fname);
}
@@ -1959,28 +1918,27 @@ int phar_create_signature(phar_archive_data *phar, php_stream *fp, char **signat
}
}
- phar->sig_len = phar_hex_str((const char *)*signature, *signature_length, &phar->signature TSRMLS_CC);
+ phar->sig_len = phar_hex_str((const char *)*signature, *signature_length, &phar->signature);
return SUCCESS;
}
/* }}} */
-void phar_add_virtual_dirs(phar_archive_data *phar, char *filename, int filename_len TSRMLS_DC) /* {{{ */
+void phar_add_virtual_dirs(phar_archive_data *phar, char *filename, int filename_len) /* {{{ */
{
const char *s;
while ((s = zend_memrchr(filename, '/', filename_len))) {
filename_len = s - filename;
- if (!filename_len || FAILURE == zend_hash_add_empty_element(&phar->virtual_dirs, filename, filename_len)) {
+ if (!filename_len || NULL == zend_hash_str_add_empty_element(&phar->virtual_dirs, filename, filename_len)) {
break;
}
}
}
/* }}} */
-static int phar_update_cached_entry(void *data, void *argument) /* {{{ */
+static int phar_update_cached_entry(zval *data, void *argument) /* {{{ */
{
- phar_entry_info *entry = (phar_entry_info *)data;
- TSRMLS_FETCH();
+ phar_entry_info *entry = (phar_entry_info *)Z_PTR_P(data);
entry->phar = (phar_archive_data *)argument;
@@ -1992,38 +1950,39 @@ static int phar_update_cached_entry(void *data, void *argument) /* {{{ */
entry->tmp = estrdup(entry->tmp);
}
- entry->metadata_str.c = 0;
+ entry->metadata_str.s = NULL;
entry->filename = estrndup(entry->filename, entry->filename_len);
entry->is_persistent = 0;
- if (entry->metadata) {
+ if (Z_TYPE(entry->metadata) != IS_UNDEF) {
if (entry->metadata_len) {
- char *buf = estrndup((char *) entry->metadata, entry->metadata_len);
+ char *buf = estrndup((char *) Z_PTR(entry->metadata), entry->metadata_len);
/* assume success, we would have failed before */
- phar_parse_metadata((char **) &buf, &entry->metadata, entry->metadata_len TSRMLS_CC);
+ phar_parse_metadata((char **) &buf, &entry->metadata, entry->metadata_len);
efree(buf);
} else {
- zval *t;
-
- t = entry->metadata;
- ALLOC_ZVAL(entry->metadata);
- *entry->metadata = *t;
- zval_copy_ctor(entry->metadata);
- Z_SET_REFCOUNT_P(entry->metadata, 1);
- entry->metadata_str.c = NULL;
- entry->metadata_str.len = 0;
+ zval_copy_ctor(&entry->metadata);
+ entry->metadata_str.s = NULL;
}
}
return ZEND_HASH_APPLY_KEEP;
}
/* }}} */
-static void phar_copy_cached_phar(phar_archive_data **pphar TSRMLS_DC) /* {{{ */
+static void phar_manifest_copy_ctor(zval *zv) /* {{{ */
+{
+ phar_entry_info *info = emalloc(sizeof(phar_entry_info));
+ memcpy(info, Z_PTR_P(zv), sizeof(phar_entry_info));
+ Z_PTR_P(zv) = info;
+}
+/* }}} */
+
+static void phar_copy_cached_phar(phar_archive_data **pphar) /* {{{ */
{
phar_archive_data *phar;
HashTable newmanifest;
char *fname;
- phar_archive_object **objphar;
+ phar_archive_object *objphar;
phar = (phar_archive_data *) emalloc(sizeof(phar_archive_data));
*phar = **pphar;
@@ -2040,66 +1999,60 @@ static void phar_copy_cached_phar(phar_archive_data **pphar TSRMLS_DC) /* {{{ */
phar->signature = estrdup(phar->signature);
}
- if (phar->metadata) {
+ if (Z_TYPE(phar->metadata) != IS_UNDEF) {
/* assume success, we would have failed before */
if (phar->metadata_len) {
- char *buf = estrndup((char *) phar->metadata, phar->metadata_len);
- phar_parse_metadata(&buf, &phar->metadata, phar->metadata_len TSRMLS_CC);
+ char *buf = estrndup((char *) Z_PTR(phar->metadata), phar->metadata_len);
+ phar_parse_metadata(&buf, &phar->metadata, phar->metadata_len);
efree(buf);
} else {
- zval *t;
-
- t = phar->metadata;
- ALLOC_ZVAL(phar->metadata);
- *phar->metadata = *t;
- zval_copy_ctor(phar->metadata);
- Z_SET_REFCOUNT_P(phar->metadata, 1);
+ zval_copy_ctor(&phar->metadata);
}
}
zend_hash_init(&newmanifest, sizeof(phar_entry_info),
zend_get_hash_value, destroy_phar_manifest_entry, 0);
- zend_hash_copy(&newmanifest, &(*pphar)->manifest, NULL, NULL, sizeof(phar_entry_info));
- zend_hash_apply_with_argument(&newmanifest, (apply_func_arg_t) phar_update_cached_entry, (void *)phar TSRMLS_CC);
+ zend_hash_copy(&newmanifest, &(*pphar)->manifest, phar_manifest_copy_ctor);
+ zend_hash_apply_with_argument(&newmanifest, phar_update_cached_entry, (void *)phar);
phar->manifest = newmanifest;
zend_hash_init(&phar->mounted_dirs, sizeof(char *),
zend_get_hash_value, NULL, 0);
zend_hash_init(&phar->virtual_dirs, sizeof(char *),
zend_get_hash_value, NULL, 0);
- zend_hash_copy(&phar->virtual_dirs, &(*pphar)->virtual_dirs, NULL, NULL, sizeof(void *));
+ zend_hash_copy(&phar->virtual_dirs, &(*pphar)->virtual_dirs, NULL);
*pphar = phar;
/* now, scan the list of persistent Phar objects referencing this phar and update the pointers */
- for (zend_hash_internal_pointer_reset(&PHAR_GLOBALS->phar_persist_map);
- SUCCESS == zend_hash_get_current_data(&PHAR_GLOBALS->phar_persist_map, (void **) &objphar);
- zend_hash_move_forward(&PHAR_GLOBALS->phar_persist_map)) {
- if (objphar[0]->arc.archive->fname_len == phar->fname_len && !memcmp(objphar[0]->arc.archive->fname, phar->fname, phar->fname_len)) {
- objphar[0]->arc.archive = phar;
+ ZEND_HASH_FOREACH_PTR(&PHAR_G(phar_persist_map), objphar) {
+ if (objphar->archive->fname_len == phar->fname_len && !memcmp(objphar->archive->fname, phar->fname, phar->fname_len)) {
+ objphar->archive = phar;
}
- }
+ } ZEND_HASH_FOREACH_END();
}
/* }}} */
-int phar_copy_on_write(phar_archive_data **pphar TSRMLS_DC) /* {{{ */
+int phar_copy_on_write(phar_archive_data **pphar) /* {{{ */
{
- phar_archive_data **newpphar, *newphar = NULL;
+ zval zv, *pzv;
+ phar_archive_data *newpphar;
- if (SUCCESS != zend_hash_add(&(PHAR_GLOBALS->phar_fname_map), (*pphar)->fname, (*pphar)->fname_len, (void *)&newphar, sizeof(phar_archive_data *), (void **)&newpphar)) {
+ ZVAL_PTR(&zv, *pphar);
+ if (NULL == (pzv = zend_hash_str_add(&(PHAR_G(phar_fname_map)), (*pphar)->fname, (*pphar)->fname_len, &zv))) {
return FAILURE;
}
- *newpphar = *pphar;
- phar_copy_cached_phar(newpphar TSRMLS_CC);
+ phar_copy_cached_phar((phar_archive_data **)&Z_PTR_P(pzv));
+ newpphar = Z_PTR_P(pzv);
/* invalidate phar cache */
PHAR_G(last_phar) = NULL;
PHAR_G(last_phar_name) = PHAR_G(last_alias) = NULL;
- if (newpphar[0]->alias_len && FAILURE == zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), newpphar[0]->alias, newpphar[0]->alias_len, (void*)newpphar, sizeof(phar_archive_data*), NULL)) {
- zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), (*pphar)->fname, (*pphar)->fname_len);
+ if (newpphar->alias_len && NULL == zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), newpphar->alias, newpphar->alias_len, newpphar)) {
+ zend_hash_str_del(&(PHAR_G(phar_fname_map)), (*pphar)->fname, (*pphar)->fname_len);
return FAILURE;
}
- *pphar = *newpphar;
+ *pphar = newpphar;
return SUCCESS;
}
/* }}} */
diff --git a/ext/phar/zip.c b/ext/phar/zip.c
index 2f1d915146..764f2b133d 100644
--- a/ext/phar/zip.c
+++ b/ext/phar/zip.c
@@ -39,7 +39,7 @@ static inline void phar_write_16(char buffer[2], php_uint32 value)
# define PHAR_SET_32(var, value) phar_write_32(var, (php_uint32) (value));
# define PHAR_SET_16(var, value) phar_write_16(var, (php_uint16) (value));
-static int phar_zip_process_extra(php_stream *fp, phar_entry_info *entry, php_uint16 len TSRMLS_DC) /* {{{ */
+static int phar_zip_process_extra(php_stream *fp, phar_entry_info *entry, php_uint16 len) /* {{{ */
{
union {
phar_zip_extra_field_header header;
@@ -163,11 +163,11 @@ static void phar_zip_u2d_time(time_t time, char *dtime, char *ddate) /* {{{ */
* This is used by phar_open_from_fp to process a zip-based phar, but can be called
* directly.
*/
-int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias, int alias_len, phar_archive_data** pphar, char **error TSRMLS_DC) /* {{{ */
+int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias, int alias_len, phar_archive_data** pphar, char **error) /* {{{ */
{
phar_zip_dir_end locator;
char buf[sizeof(locator) + 65536];
- long size;
+ zend_long size;
php_uint16 i;
phar_archive_data *mydata = NULL;
phar_entry_info entry = {0};
@@ -237,22 +237,14 @@ int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias,
mydata->metadata_len = PHAR_GET_16(locator.comment_len);
- if (phar_parse_metadata(&metadata, &mydata->metadata, PHAR_GET_16(locator.comment_len) TSRMLS_CC) == FAILURE) {
+ if (phar_parse_metadata(&metadata, &mydata->metadata, PHAR_GET_16(locator.comment_len)) == FAILURE) {
mydata->metadata_len = 0;
/* if not valid serialized data, it is a regular string */
- if (entry.is_persistent) {
- ALLOC_PERMANENT_ZVAL(mydata->metadata);
- } else {
- ALLOC_ZVAL(mydata->metadata);
- }
-
- INIT_ZVAL(*mydata->metadata);
- metadata = pestrndup(metadata, PHAR_GET_16(locator.comment_len), mydata->is_persistent);
- ZVAL_STRINGL(mydata->metadata, metadata, PHAR_GET_16(locator.comment_len), 0);
+ ZVAL_NEW_STR(&mydata->metadata, zend_string_init(metadata, PHAR_GET_16(locator.comment_len), mydata->is_persistent));
}
} else {
- mydata->metadata = NULL;
+ ZVAL_UNDEF(&mydata->metadata);
}
goto foundit;
@@ -301,15 +293,13 @@ foundit:
entry.is_persistent = mydata->is_persistent;
#define PHAR_ZIP_FAIL_FREE(errmsg, save) \
zend_hash_destroy(&mydata->manifest); \
- mydata->manifest.arBuckets = 0; \
+ mydata->manifest.u.flags = 0; \
zend_hash_destroy(&mydata->mounted_dirs); \
- mydata->mounted_dirs.arBuckets = 0; \
+ mydata->mounted_dirs.u.flags = 0; \
zend_hash_destroy(&mydata->virtual_dirs); \
- mydata->virtual_dirs.arBuckets = 0; \
+ mydata->virtual_dirs.u.flags = 0; \
php_stream_close(fp); \
- if (mydata->metadata) { \
- zval_dtor(mydata->metadata); \
- } \
+ zval_dtor(&mydata->metadata); \
if (mydata->signature) { \
efree(mydata->signature); \
} \
@@ -325,15 +315,13 @@ foundit:
return FAILURE;
#define PHAR_ZIP_FAIL(errmsg) \
zend_hash_destroy(&mydata->manifest); \
- mydata->manifest.arBuckets = 0; \
+ mydata->manifest.u.flags = 0; \
zend_hash_destroy(&mydata->mounted_dirs); \
- mydata->mounted_dirs.arBuckets = 0; \
+ mydata->mounted_dirs.u.flags = 0; \
zend_hash_destroy(&mydata->virtual_dirs); \
- mydata->virtual_dirs.arBuckets = 0; \
+ mydata->virtual_dirs.u.flags = 0; \
php_stream_close(fp); \
- if (mydata->metadata) { \
- zval_dtor(mydata->metadata); \
- } \
+ zval_dtor(&mydata->metadata); \
if (mydata->signature) { \
efree(mydata->signature); \
} \
@@ -350,7 +338,7 @@ foundit:
/* add each central directory item to the manifest */
for (i = 0; i < PHAR_GET_16(locator.count); ++i) {
phar_zip_central_dir_file zipentry;
- off_t beforeus = php_stream_tell(fp);
+ zend_off_t beforeus = php_stream_tell(fp);
if (sizeof(zipentry) != php_stream_read(fp, (char *) &zipentry, sizeof(zipentry))) {
PHAR_ZIP_FAIL("unable to read central directory entry, truncated");
@@ -407,7 +395,7 @@ foundit:
if (entry.filename_len == sizeof(".phar/signature.bin")-1 && !strncmp(entry.filename, ".phar/signature.bin", sizeof(".phar/signature.bin")-1)) {
size_t read;
php_stream *sigfile;
- off_t now;
+ zend_off_t now;
char *sig;
now = php_stream_tell(fp);
@@ -436,7 +424,7 @@ foundit:
PHAR_ZIP_FAIL("signature cannot be read");
}
mydata->sig_flags = PHAR_GET_32(sig);
- if (FAILURE == phar_verify_signature(sigfile, php_stream_tell(sigfile), mydata->sig_flags, sig + 8, entry.uncompressed_filesize - 8, fname, &mydata->signature, &mydata->sig_len, error TSRMLS_CC)) {
+ if (FAILURE == phar_verify_signature(sigfile, php_stream_tell(sigfile), mydata->sig_flags, sig + 8, entry.uncompressed_filesize - 8, fname, &mydata->signature, &mydata->sig_len, error)) {
efree(sig);
if (error) {
char *save;
@@ -459,11 +447,11 @@ foundit:
continue;
}
- phar_add_virtual_dirs(mydata, entry.filename, entry.filename_len TSRMLS_CC);
+ phar_add_virtual_dirs(mydata, entry.filename, entry.filename_len);
if (PHAR_GET_16(zipentry.extra_len)) {
- off_t loc = php_stream_tell(fp);
- if (FAILURE == phar_zip_process_extra(fp, &entry, PHAR_GET_16(zipentry.extra_len) TSRMLS_CC)) {
+ zend_off_t loc = php_stream_tell(fp);
+ if (FAILURE == phar_zip_process_extra(fp, &entry, PHAR_GET_16(zipentry.extra_len))) {
pefree(entry.filename, entry.is_persistent);
PHAR_ZIP_FAIL("Unable to process extra field header for file in central directory");
}
@@ -539,26 +527,19 @@ foundit:
p = buf;
entry.metadata_len = PHAR_GET_16(zipentry.comment_len);
- if (phar_parse_metadata(&p, &(entry.metadata), PHAR_GET_16(zipentry.comment_len) TSRMLS_CC) == FAILURE) {
+ if (phar_parse_metadata(&p, &(entry.metadata), PHAR_GET_16(zipentry.comment_len)) == FAILURE) {
entry.metadata_len = 0;
/* if not valid serialized data, it is a regular string */
- if (entry.is_persistent) {
- ALLOC_PERMANENT_ZVAL(entry.metadata);
- } else {
- ALLOC_ZVAL(entry.metadata);
- }
-
- INIT_ZVAL(*entry.metadata);
- ZVAL_STRINGL(entry.metadata, pestrndup(buf, PHAR_GET_16(zipentry.comment_len), entry.is_persistent), PHAR_GET_16(zipentry.comment_len), 0);
+ ZVAL_NEW_STR(&entry.metadata, zend_string_init(buf, PHAR_GET_16(zipentry.comment_len), entry.is_persistent));
}
} else {
- entry.metadata = NULL;
+ ZVAL_UNDEF(&entry.metadata);
}
if (!actual_alias && entry.filename_len == sizeof(".phar/alias.txt")-1 && !strncmp(entry.filename, ".phar/alias.txt", sizeof(".phar/alias.txt")-1)) {
php_stream_filter *filter;
- off_t saveloc;
+ zend_off_t saveloc;
/* verify local file header */
phar_zip_file_header local;
@@ -590,9 +571,8 @@ foundit:
/* the above lines should be for php < 5.2.6 after 5.3 filters are fixed */
mydata->alias_len = entry.uncompressed_filesize;
-
if (entry.flags & PHAR_ENT_COMPRESSED_GZ) {
- filter = php_stream_filter_create("zlib.inflate", NULL, php_stream_is_persistent(fp) TSRMLS_CC);
+ filter = php_stream_filter_create("zlib.inflate", NULL, php_stream_is_persistent(fp));
if (!filter) {
pefree(entry.filename, entry.is_persistent);
@@ -601,16 +581,30 @@ foundit:
php_stream_filter_append(&fp->readfilters, filter);
- if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
+ // TODO: refactor to avoid reallocation ???
+//??? entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)
+ {
+ zend_string *str = php_stream_copy_to_mem(fp, entry.uncompressed_filesize, 0);
+ if (str) {
+ entry.uncompressed_filesize = ZSTR_LEN(str);
+ actual_alias = estrndup(ZSTR_VAL(str), ZSTR_LEN(str));
+ zend_string_release(str);
+ } else {
+ actual_alias = NULL;
+ entry.uncompressed_filesize = 0;
+ }
+ }
+
+ if (!entry.uncompressed_filesize || !actual_alias) {
pefree(entry.filename, entry.is_persistent);
PHAR_ZIP_FAIL("unable to read in alias, truncated");
}
php_stream_filter_flush(filter, 1);
- php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ php_stream_filter_remove(filter, 1);
} else if (entry.flags & PHAR_ENT_COMPRESSED_BZ2) {
- filter = php_stream_filter_create("bzip2.decompress", NULL, php_stream_is_persistent(fp) TSRMLS_CC);
+ filter = php_stream_filter_create("bzip2.decompress", NULL, php_stream_is_persistent(fp));
if (!filter) {
pefree(entry.filename, entry.is_persistent);
@@ -619,15 +613,43 @@ foundit:
php_stream_filter_append(&fp->readfilters, filter);
- if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
+ // TODO: refactor to avoid reallocation ???
+//??? entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)
+ {
+ zend_string *str = php_stream_copy_to_mem(fp, entry.uncompressed_filesize, 0);
+ if (str) {
+ entry.uncompressed_filesize = ZSTR_LEN(str);
+ actual_alias = estrndup(ZSTR_VAL(str), ZSTR_LEN(str));
+ zend_string_release(str);
+ } else {
+ actual_alias = NULL;
+ entry.uncompressed_filesize = 0;
+ }
+ }
+
+ if (!entry.uncompressed_filesize || !actual_alias) {
pefree(entry.filename, entry.is_persistent);
PHAR_ZIP_FAIL("unable to read in alias, truncated");
}
php_stream_filter_flush(filter, 1);
- php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ php_stream_filter_remove(filter, 1);
} else {
- if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
+ // TODO: refactor to avoid reallocation ???
+//??? entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)
+ {
+ zend_string *str = php_stream_copy_to_mem(fp, entry.uncompressed_filesize, 0);
+ if (str) {
+ entry.uncompressed_filesize = ZSTR_LEN(str);
+ actual_alias = estrndup(ZSTR_VAL(str), ZSTR_LEN(str));
+ zend_string_release(str);
+ } else {
+ actual_alias = NULL;
+ entry.uncompressed_filesize = 0;
+ }
+ }
+
+ if (!entry.uncompressed_filesize || !actual_alias) {
pefree(entry.filename, entry.is_persistent);
PHAR_ZIP_FAIL("unable to read in alias, truncated");
}
@@ -637,41 +659,41 @@ foundit:
php_stream_seek(fp, saveloc, SEEK_SET);
}
- phar_set_inode(&entry TSRMLS_CC);
- zend_hash_add(&mydata->manifest, entry.filename, entry.filename_len, (void *)&entry,sizeof(phar_entry_info), NULL);
+ phar_set_inode(&entry);
+ zend_hash_str_add_mem(&mydata->manifest, entry.filename, entry.filename_len, (void *)&entry, sizeof(phar_entry_info));
}
mydata->fp = fp;
- if (zend_hash_exists(&(mydata->manifest), ".phar/stub.php", sizeof(".phar/stub.php")-1)) {
+ if (zend_hash_str_exists(&(mydata->manifest), ".phar/stub.php", sizeof(".phar/stub.php")-1)) {
mydata->is_data = 0;
} else {
mydata->is_data = 1;
}
- zend_hash_add(&(PHAR_GLOBALS->phar_fname_map), mydata->fname, fname_len, (void*)&mydata, sizeof(phar_archive_data*), NULL);
+ zend_hash_str_add_ptr(&(PHAR_G(phar_fname_map)), mydata->fname, fname_len, mydata);
if (actual_alias) {
- phar_archive_data **fd_ptr;
+ phar_archive_data *fd_ptr;
if (!phar_validate_alias(actual_alias, mydata->alias_len)) {
if (error) {
spprintf(error, 4096, "phar error: invalid alias \"%s\" in zip-based phar \"%s\"", actual_alias, fname);
}
efree(actual_alias);
- zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), mydata->fname, fname_len);
+ zend_hash_str_del(&(PHAR_G(phar_fname_map)), mydata->fname, fname_len);
return FAILURE;
}
mydata->is_temporary_alias = 0;
- if (SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), actual_alias, mydata->alias_len, (void **)&fd_ptr)) {
- if (SUCCESS != phar_free_alias(*fd_ptr, actual_alias, mydata->alias_len TSRMLS_CC)) {
+ if (NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), actual_alias, mydata->alias_len))) {
+ if (SUCCESS != phar_free_alias(fd_ptr, actual_alias, mydata->alias_len)) {
if (error) {
spprintf(error, 4096, "phar error: Unable to add zip-based phar \"%s\" with implicit alias, alias is already in use", fname);
}
efree(actual_alias);
- zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), mydata->fname, fname_len);
+ zend_hash_str_del(&(PHAR_G(phar_fname_map)), mydata->fname, fname_len);
return FAILURE;
}
}
@@ -682,22 +704,22 @@ foundit:
efree(actual_alias);
}
- zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), actual_alias, mydata->alias_len, (void*)&mydata, sizeof(phar_archive_data*), NULL);
+ zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), actual_alias, mydata->alias_len, mydata);
} else {
- phar_archive_data **fd_ptr;
+ phar_archive_data *fd_ptr;
if (alias_len) {
- if (SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void **)&fd_ptr)) {
- if (SUCCESS != phar_free_alias(*fd_ptr, alias, alias_len TSRMLS_CC)) {
+ if (NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len))) {
+ if (SUCCESS != phar_free_alias(fd_ptr, alias, alias_len)) {
if (error) {
spprintf(error, 4096, "phar error: Unable to add zip-based phar \"%s\" with explicit alias, alias is already in use", fname);
}
- zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), mydata->fname, fname_len);
+ zend_hash_str_del(&(PHAR_G(phar_fname_map)), mydata->fname, fname_len);
return FAILURE;
}
}
- zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), actual_alias, mydata->alias_len, (void*)&mydata, sizeof(phar_archive_data*), NULL);
+ zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), actual_alias, mydata->alias_len, mydata);
mydata->alias = pestrndup(alias, alias_len, mydata->is_persistent);
mydata->alias_len = alias_len;
} else {
@@ -719,10 +741,10 @@ foundit:
/**
* Create or open a zip-based phar for writing
*/
-int phar_open_or_create_zip(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC) /* {{{ */
+int phar_open_or_create_zip(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error) /* {{{ */
{
phar_archive_data *phar;
- int ret = phar_create_or_parse_filename(fname, fname_len, alias, alias_len, is_data, options, &phar, error TSRMLS_CC);
+ int ret = phar_create_or_parse_filename(fname, fname_len, alias, alias_len, is_data, options, &phar, error);
if (FAILURE == ret) {
return FAILURE;
@@ -763,17 +785,15 @@ struct _phar_zip_pass {
char **error;
};
/* perform final modification of zip contents for each file in the manifest before saving */
-static int phar_zip_changed_apply(void *data, void *arg TSRMLS_DC) /* {{{ */
+static int phar_zip_changed_apply_int(phar_entry_info *entry, void *arg) /* {{{ */
{
- phar_entry_info *entry;
phar_zip_file_header local;
phar_zip_unix3 perms;
phar_zip_central_dir_file central;
struct _phar_zip_pass *p;
php_uint32 newcrc32;
- off_t offset;
+ zend_off_t offset;
int not_really_modified = 0;
- entry = (phar_entry_info *)data;
p = (struct _phar_zip_pass*) arg;
if (entry->is_mounted) {
@@ -789,7 +809,7 @@ static int phar_zip_changed_apply(void *data, void *arg TSRMLS_DC) /* {{{ */
}
}
- phar_add_virtual_dirs(entry->phar, entry->filename, entry->filename_len TSRMLS_CC);
+ phar_add_virtual_dirs(entry->phar, entry->filename, entry->filename_len);
memset(&local, 0, sizeof(local));
memset(&central, 0, sizeof(central));
memset(&perms, 0, sizeof(perms));
@@ -842,7 +862,7 @@ static int phar_zip_changed_apply(void *data, void *arg TSRMLS_DC) /* {{{ */
goto continue_dir;
}
- if (FAILURE == phar_open_entry_fp(entry, p->error, 0 TSRMLS_CC)) {
+ if (FAILURE == phar_open_entry_fp(entry, p->error, 0)) {
spprintf(p->error, 0, "unable to open file contents of file \"%s\" in zip-based phar \"%s\"", entry->filename, entry->phar->fname);
return ZEND_HASH_APPLY_STOP;
}
@@ -853,12 +873,12 @@ static int phar_zip_changed_apply(void *data, void *arg TSRMLS_DC) /* {{{ */
goto is_compressed;
}
- if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0 TSRMLS_CC)) {
+ if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0)) {
spprintf(p->error, 0, "unable to seek to start of file \"%s\" to zip-based phar \"%s\"", entry->filename, entry->phar->fname);
return ZEND_HASH_APPLY_STOP;
}
- efp = phar_get_efp(entry, 0 TSRMLS_CC);
+ efp = phar_get_efp(entry, 0);
newcrc32 = ~0;
for (loc = 0;loc < entry->uncompressed_filesize; ++loc) {
@@ -877,7 +897,7 @@ static int phar_zip_changed_apply(void *data, void *arg TSRMLS_DC) /* {{{ */
goto not_compressed;
}
- filter = php_stream_filter_create(phar_compress_filter(entry, 0), NULL, 0 TSRMLS_CC);
+ filter = php_stream_filter_create(phar_compress_filter(entry, 0), NULL, 0);
if (!filter) {
if (entry->flags & PHAR_ENT_COMPRESSED_GZ) {
@@ -900,7 +920,7 @@ static int phar_zip_changed_apply(void *data, void *arg TSRMLS_DC) /* {{{ */
php_stream_flush(efp);
- if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0 TSRMLS_CC)) {
+ if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0)) {
spprintf(p->error, 0, "unable to seek to start of file \"%s\" to zip-based phar \"%s\"", entry->filename, entry->phar->fname);
return ZEND_HASH_APPLY_STOP;
}
@@ -914,7 +934,7 @@ static int phar_zip_changed_apply(void *data, void *arg TSRMLS_DC) /* {{{ */
php_stream_filter_flush(filter, 1);
php_stream_flush(entry->cfp);
- php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ php_stream_filter_remove(filter, 1);
php_stream_seek(entry->cfp, 0, SEEK_END);
entry->compressed_filesize = (php_uint32) php_stream_tell(entry->cfp);
PHAR_SET_32(central.compsize, entry->compressed_filesize);
@@ -941,18 +961,17 @@ not_compressed:
PHAR_SET_32(local.crc32, entry->crc32);
continue_dir:
/* set file metadata */
- if (entry->metadata) {
+ if (Z_TYPE(entry->metadata) != IS_UNDEF) {
php_serialize_data_t metadata_hash;
- if (entry->metadata_str.c) {
+ if (entry->metadata_str.s) {
smart_str_free(&entry->metadata_str);
}
- entry->metadata_str.c = 0;
- entry->metadata_str.len = 0;
+ entry->metadata_str.s = NULL;
PHP_VAR_SERIALIZE_INIT(metadata_hash);
- php_var_serialize(&entry->metadata_str, &entry->metadata, &metadata_hash TSRMLS_CC);
+ php_var_serialize(&entry->metadata_str, &entry->metadata, &metadata_hash);
PHP_VAR_SERIALIZE_DESTROY(metadata_hash);
- PHAR_SET_16(central.comment_len, entry->metadata_str.len);
+ PHAR_SET_16(central.comment_len, ZSTR_LEN(entry->metadata_str.s));
}
entry->header_offset = php_stream_tell(p->filefp);
@@ -1020,13 +1039,13 @@ continue_dir:
php_stream_close(entry->cfp);
entry->cfp = NULL;
} else {
- if (FAILURE == phar_open_entry_fp(entry, p->error, 0 TSRMLS_CC)) {
+ if (FAILURE == phar_open_entry_fp(entry, p->error, 0)) {
return ZEND_HASH_APPLY_STOP;
}
- phar_seek_efp(entry, 0, SEEK_SET, 0, 0 TSRMLS_CC);
+ phar_seek_efp(entry, 0, SEEK_SET, 0, 0);
- if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, 0 TSRMLS_CC), p->filefp, entry->uncompressed_filesize, NULL)) {
+ if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, 0), p->filefp, entry->uncompressed_filesize, NULL)) {
spprintf(p->error, 0, "unable to write contents of file \"%s\" in zip-based phar \"%s\"", entry->filename, entry->phar->fname);
return ZEND_HASH_APPLY_STOP;
}
@@ -1062,8 +1081,8 @@ continue_dir:
entry->offset = entry->offset_abs = offset;
entry->fp_type = PHAR_FP;
- if (entry->metadata_str.c) {
- if (entry->metadata_str.len != php_stream_write(p->centralfp, entry->metadata_str.c, entry->metadata_str.len)) {
+ if (entry->metadata_str.s) {
+ if (ZSTR_LEN(entry->metadata_str.s) != php_stream_write(p->centralfp, ZSTR_VAL(entry->metadata_str.s), ZSTR_LEN(entry->metadata_str.s))) {
spprintf(p->error, 0, "unable to write metadata as file comment for file \"%s\" while creating zip-based phar \"%s\"", entry->filename, entry->phar->fname);
smart_str_free(&entry->metadata_str);
return ZEND_HASH_APPLY_STOP;
@@ -1076,8 +1095,14 @@ continue_dir:
}
/* }}} */
+static int phar_zip_changed_apply(zval *zv, void *arg) /* {{{ */
+{
+ return phar_zip_changed_apply_int(Z_PTR_P(zv), arg);
+}
+/* }}} */
+
static int phar_zip_applysignature(phar_archive_data *phar, struct _phar_zip_pass *pass,
- smart_str *metadata TSRMLS_DC) /* {{{ */
+ smart_str *metadata) /* {{{ */
{
/* add signature for executable tars or tars explicitly set with setSignatureAlgorithm */
if (!phar->is_data || phar->sig_flags) {
@@ -1085,7 +1110,7 @@ static int phar_zip_applysignature(phar_archive_data *phar, struct _phar_zip_pas
char *signature, sigbuf[8];
phar_entry_info entry = {0};
php_stream *newfile;
- off_t tell, st;
+ zend_off_t tell, st;
newfile = php_stream_fopen_tmpfile();
if (newfile == NULL) {
@@ -1099,11 +1124,11 @@ static int phar_zip_applysignature(phar_archive_data *phar, struct _phar_zip_pas
tell = php_stream_tell(pass->centralfp);
php_stream_seek(pass->centralfp, 0, SEEK_SET);
php_stream_copy_to_stream_ex(pass->centralfp, newfile, tell, NULL);
- if (metadata->c) {
- php_stream_write(newfile, metadata->c, metadata->len);
+ if (metadata->s) {
+ php_stream_write(newfile, ZSTR_VAL(metadata->s), ZSTR_LEN(metadata->s));
}
- if (FAILURE == phar_create_signature(phar, newfile, &signature, &signature_length, pass->error TSRMLS_CC)) {
+ if (FAILURE == phar_create_signature(phar, newfile, &signature, &signature_length, pass->error)) {
if (pass->error) {
char *save = *(pass->error);
spprintf(pass->error, 0, "phar error: unable to write signature to zip-based phar: %s", save);
@@ -1141,7 +1166,7 @@ static int phar_zip_applysignature(phar_archive_data *phar, struct _phar_zip_pas
entry.uncompressed_filesize = entry.compressed_filesize = signature_length + 8;
entry.phar = phar;
/* throw out return value and write the signature */
- phar_zip_changed_apply((void *)&entry, (void *)pass TSRMLS_CC);
+ phar_zip_changed_apply_int(&entry, (void *)pass);
php_stream_close(newfile);
if (pass->error && *(pass->error)) {
@@ -1154,7 +1179,7 @@ static int phar_zip_applysignature(phar_archive_data *phar, struct _phar_zip_pas
}
/* }}} */
-int phar_zip_flush(phar_archive_data *phar, char *user_stub, long len, int defaultstub, char **error TSRMLS_DC) /* {{{ */
+int phar_zip_flush(phar_archive_data *phar, char *user_stub, zend_long len, int defaultstub, char **error) /* {{{ */
{
char *pos;
smart_str main_metadata_str = {0};
@@ -1208,19 +1233,19 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, long len, int defau
entry.filename = estrndup(".phar/alias.txt", sizeof(".phar/alias.txt")-1);
entry.filename_len = sizeof(".phar/alias.txt")-1;
- if (SUCCESS != zend_hash_update(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info), NULL)) {
+ if (NULL == zend_hash_str_update_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info))) {
if (error) {
spprintf(error, 0, "unable to set alias in zip-based phar \"%s\"", phar->fname);
}
return EOF;
}
} else {
- zend_hash_del(&phar->manifest, ".phar/alias.txt", sizeof(".phar/alias.txt")-1);
+ zend_hash_str_del(&phar->manifest, ".phar/alias.txt", sizeof(".phar/alias.txt")-1);
}
/* register alias */
if (phar->alias_len) {
- if (FAILURE == phar_get_archive(&phar, phar->fname, phar->fname_len, phar->alias, phar->alias_len, error TSRMLS_CC)) {
+ if (FAILURE == phar_get_archive(&phar, phar->fname, phar->fname_len, phar->alias, phar->alias_len, error)) {
return EOF;
}
}
@@ -1229,7 +1254,7 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, long len, int defau
if (user_stub && !defaultstub) {
if (len < 0) {
/* resource passed in */
- if (!(php_stream_from_zval_no_verify(stubfile, (zval **)user_stub))) {
+ if (!(php_stream_from_zval_no_verify(stubfile, (zval *)user_stub))) {
if (error) {
spprintf(error, 0, "unable to access resource to copy stub to new zip-based phar \"%s\"", phar->fname);
}
@@ -1244,7 +1269,21 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, long len, int defau
user_stub = 0;
- if (!(len = php_stream_copy_to_mem(stubfile, &user_stub, len, 0)) || !user_stub) {
+ // TODO: refactor to avoid reallocation ???
+//??? len = php_stream_copy_to_mem(stubfile, &user_stub, len, 0)
+ {
+ zend_string *str = php_stream_copy_to_mem(stubfile, len, 0);
+ if (str) {
+ len = ZSTR_LEN(str);
+ user_stub = estrndup(ZSTR_VAL(str), ZSTR_LEN(str));
+ zend_string_release(str);
+ } else {
+ user_stub = NULL;
+ len = 0;
+ }
+ }
+
+ if (!len || !user_stub) {
if (error) {
spprintf(error, 0, "unable to read resource to copy stub to new zip-based phar \"%s\"", phar->fname);
}
@@ -1292,7 +1331,7 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, long len, int defau
entry.filename = estrndup(".phar/stub.php", sizeof(".phar/stub.php")-1);
entry.filename_len = sizeof(".phar/stub.php")-1;
- if (SUCCESS != zend_hash_update(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info), NULL)) {
+ if (NULL == zend_hash_str_update_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info))) {
if (free_user_stub) {
efree(user_stub);
}
@@ -1325,8 +1364,8 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, long len, int defau
entry.filename_len = sizeof(".phar/stub.php")-1;
if (!defaultstub) {
- if (!zend_hash_exists(&phar->manifest, ".phar/stub.php", sizeof(".phar/stub.php")-1)) {
- if (SUCCESS != zend_hash_add(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info), NULL)) {
+ if (!zend_hash_str_exists(&phar->manifest, ".phar/stub.php", sizeof(".phar/stub.php")-1)) {
+ if (NULL == zend_hash_str_add_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info))) {
php_stream_close(entry.fp);
efree(entry.filename);
if (error) {
@@ -1339,7 +1378,7 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, long len, int defau
efree(entry.filename);
}
} else {
- if (SUCCESS != zend_hash_update(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info), NULL)) {
+ if (NULL == zend_hash_str_update_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info))) {
php_stream_close(entry.fp);
efree(entry.filename);
if (error) {
@@ -1394,12 +1433,12 @@ fperror:
PHAR_SET_16(eocd.counthere, zend_hash_num_elements(&phar->manifest));
PHAR_SET_16(eocd.count, zend_hash_num_elements(&phar->manifest));
}
- zend_hash_apply_with_argument(&phar->manifest, phar_zip_changed_apply, (void *) &pass TSRMLS_CC);
+ zend_hash_apply_with_argument(&phar->manifest, phar_zip_changed_apply, (void *) &pass);
- if (phar->metadata) {
+ if (Z_TYPE(phar->metadata) != IS_UNDEF) {
/* set phar metadata */
PHP_VAR_SERIALIZE_INIT(metadata_hash);
- php_var_serialize(&main_metadata_str, &phar->metadata, &metadata_hash TSRMLS_CC);
+ php_var_serialize(&main_metadata_str, &phar->metadata, &metadata_hash);
PHP_VAR_SERIALIZE_DESTROY(metadata_hash);
}
if (temperr) {
@@ -1410,7 +1449,7 @@ fperror:
temperror:
php_stream_close(pass.centralfp);
nocentralerror:
- if (phar->metadata) {
+ if (Z_TYPE(phar->metadata) != IS_UNDEF) {
smart_str_free(&main_metadata_str);
}
php_stream_close(pass.filefp);
@@ -1420,7 +1459,7 @@ nocentralerror:
return EOF;
}
- if (FAILURE == phar_zip_applysignature(phar, &pass, &main_metadata_str TSRMLS_CC)) {
+ if (FAILURE == phar_zip_applysignature(phar, &pass, &main_metadata_str)) {
goto temperror;
}
@@ -1444,9 +1483,9 @@ nocentralerror:
php_stream_close(pass.centralfp);
- if (phar->metadata) {
+ if (Z_TYPE(phar->metadata) != IS_UNDEF) {
/* set phar metadata */
- PHAR_SET_16(eocd.comment_len, main_metadata_str.len);
+ PHAR_SET_16(eocd.comment_len, ZSTR_LEN(main_metadata_str.s));
if (sizeof(eocd) != php_stream_write(pass.filefp, (char *)&eocd, sizeof(eocd))) {
if (error) {
@@ -1455,7 +1494,7 @@ nocentralerror:
goto nocentralerror;
}
- if (main_metadata_str.len != php_stream_write(pass.filefp, main_metadata_str.c, main_metadata_str.len)) {
+ if (ZSTR_LEN(main_metadata_str.s) != php_stream_write(pass.filefp, ZSTR_VAL(main_metadata_str.s), ZSTR_LEN(main_metadata_str.s))) {
if (error) {
spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to write metadata to zip comment", phar->fname);
}