}
/* }}} */
+static struct _phar_orig_functions {
+ void (*orig_fopen)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_file_get_contents)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_is_file)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_is_link)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_is_dir)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_opendir)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_file_exists)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_fileperms)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_fileinode)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_filesize)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_fileowner)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_filegroup)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_fileatime)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_filemtime)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_filectime)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_filetype)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_is_writable)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_is_readable)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_is_executable)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_lstat)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_readfile)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_stat)(INTERNAL_FUNCTION_PARAMETERS);
+} phar_orig_functions = {NULL};
+
+void phar_save_orig_functions(TSRMLS_D) /* {{{ */
+{
+ phar_orig_functions.orig_fopen = PHAR_G(orig_fopen);
+ phar_orig_functions.orig_file_get_contents = PHAR_G(orig_file_get_contents);
+ phar_orig_functions.orig_is_file = PHAR_G(orig_is_file);
+ phar_orig_functions.orig_is_link = PHAR_G(orig_is_link);
+ phar_orig_functions.orig_is_dir = PHAR_G(orig_is_dir);
+ phar_orig_functions.orig_opendir = PHAR_G(orig_opendir);
+ phar_orig_functions.orig_file_exists = PHAR_G(orig_file_exists);
+ phar_orig_functions.orig_fileperms = PHAR_G(orig_fileperms);
+ phar_orig_functions.orig_fileinode = PHAR_G(orig_fileinode);
+ phar_orig_functions.orig_filesize = PHAR_G(orig_filesize);
+ phar_orig_functions.orig_fileowner = PHAR_G(orig_fileowner);
+ phar_orig_functions.orig_filegroup = PHAR_G(orig_filegroup);
+ phar_orig_functions.orig_fileatime = PHAR_G(orig_fileatime);
+ phar_orig_functions.orig_filemtime = PHAR_G(orig_filemtime);
+ phar_orig_functions.orig_filectime = PHAR_G(orig_filectime);
+ phar_orig_functions.orig_filetype = PHAR_G(orig_filetype);
+ phar_orig_functions.orig_is_writable = PHAR_G(orig_is_writable);
+ phar_orig_functions.orig_is_readable = PHAR_G(orig_is_readable);
+ phar_orig_functions.orig_is_executable = PHAR_G(orig_is_executable);
+ phar_orig_functions.orig_lstat = PHAR_G(orig_lstat);
+ phar_orig_functions.orig_readfile = PHAR_G(orig_readfile);
+ phar_orig_functions.orig_stat = PHAR_G(orig_stat);
+}
+/* }}} */
+
+void phar_restore_orig_functions(TSRMLS_D) /* {{{ */
+{
+ PHAR_G(orig_fopen) = phar_orig_functions.orig_fopen;
+ PHAR_G(orig_file_get_contents) = phar_orig_functions.orig_file_get_contents;
+ PHAR_G(orig_is_file) = phar_orig_functions.orig_is_file;
+ PHAR_G(orig_is_link) = phar_orig_functions.orig_is_link;
+ PHAR_G(orig_is_dir) = phar_orig_functions.orig_is_dir;
+ PHAR_G(orig_opendir) = phar_orig_functions.orig_opendir;
+ PHAR_G(orig_file_exists) = phar_orig_functions.orig_file_exists;
+ PHAR_G(orig_fileperms) = phar_orig_functions.orig_fileperms;
+ PHAR_G(orig_fileinode) = phar_orig_functions.orig_fileinode;
+ PHAR_G(orig_filesize) = phar_orig_functions.orig_filesize;
+ PHAR_G(orig_fileowner) = phar_orig_functions.orig_fileowner;
+ PHAR_G(orig_filegroup) = phar_orig_functions.orig_filegroup;
+ PHAR_G(orig_fileatime) = phar_orig_functions.orig_fileatime;
+ PHAR_G(orig_filemtime) = phar_orig_functions.orig_filemtime;
+ PHAR_G(orig_filectime) = phar_orig_functions.orig_filectime;
+ PHAR_G(orig_filetype) = phar_orig_functions.orig_filetype;
+ PHAR_G(orig_is_writable) = phar_orig_functions.orig_is_writable;
+ PHAR_G(orig_is_readable) = phar_orig_functions.orig_is_readable;
+ PHAR_G(orig_is_executable) = phar_orig_functions.orig_is_executable;
+ PHAR_G(orig_lstat) = phar_orig_functions.orig_lstat;
+ PHAR_G(orig_readfile) = phar_orig_functions.orig_readfile;
+ PHAR_G(orig_stat) = phar_orig_functions.orig_stat;
+}
+/* }}} */
+
/*
* Local variables:
* tab-width: 4
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
+
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);
END_EXTERN_C()
/*
};
/* }}}*/
-/* {{{ php_phar_init_globals
- */
-static void php_phar_init_globals_module(zend_phar_globals *phar_globals)
-{
- memset(phar_globals, 0, sizeof(zend_phar_globals));
- phar_globals->readonly = 1;
-}
-/* }}} */
-
static size_t phar_zend_stream_reader(void *handle, char *buf, size_t len TSRMLS_DC) /* {{{ */
{
return php_stream_read(phar_get_pharfp((phar_archive_data*)handle TSRMLS_CC), buf, len);
typedef zend_op_array* (zend_compile_t)(zend_file_handle*, int TSRMLS_DC);
typedef zend_compile_t* (compile_hook)(zend_compile_t *ptr);
-PHP_MINIT_FUNCTION(phar) /* {{{ */
+PHP_GINIT_FUNCTION(phar) /* {{{ */
{
phar_mime_type mime;
- ZEND_INIT_MODULE_GLOBALS(phar, php_phar_init_globals_module, NULL);
- REGISTER_INI_ENTRIES();
-
- phar_orig_compile_file = zend_compile_file;
- zend_compile_file = phar_compile_file;
-
-#if PHP_VERSION_ID >= 50300
- phar_save_resolve_path = zend_resolve_path;
- zend_resolve_path = phar_resolve_path;
-#else
- phar_orig_zend_open = zend_stream_open_function;
- zend_stream_open_function = phar_zend_open;
-#endif
-
- phar_object_init(TSRMLS_C);
-
- phar_intercept_functions_init(TSRMLS_C);
+ memset(phar_globals, 0, sizeof(zend_phar_globals));
+ phar_globals->readonly = 1;
- zend_hash_init(&PHAR_G(mime_types), 0, NULL, NULL, 1);
+ zend_hash_init(&phar_globals->mime_types, 0, NULL, NULL, 1);
#define PHAR_SET_MIME(mimetype, ret, fileext) \
mime.mime = mimetype; \
mime.len = sizeof((mimetype))+1; \
mime.type = ret; \
- zend_hash_add(&PHAR_G(mime_types), fileext, sizeof(fileext)-1, (void *)&mime, sizeof(phar_mime_type), NULL); \
+ zend_hash_add(&phar_globals->mime_types, fileext, sizeof(fileext)-1, (void *)&mime, sizeof(phar_mime_type), NULL); \
PHAR_SET_MIME("text/html", PHAR_MIME_PHPS, "phps")
PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "c")
PHAR_SET_MIME("image/xbm", PHAR_MIME_OTHER, "xbm")
PHAR_SET_MIME("text/xml", PHAR_MIME_OTHER, "xml")
+ phar_restore_orig_functions(TSRMLS_C);
+}
+/* }}} */
+
+PHP_GSHUTDOWN_FUNCTION(phar) /* {{{ */
+{
+ zend_hash_destroy(&phar_globals->mime_types);
+}
+/* }}} */
+
+PHP_MINIT_FUNCTION(phar) /* {{{ */
+{
+ REGISTER_INI_ENTRIES();
+
+ phar_orig_compile_file = zend_compile_file;
+ zend_compile_file = phar_compile_file;
+
+#if PHP_VERSION_ID >= 50300
+ phar_save_resolve_path = zend_resolve_path;
+ zend_resolve_path = phar_resolve_path;
+#else
+ phar_orig_zend_open = zend_stream_open_function;
+ zend_stream_open_function = phar_zend_open;
+#endif
+
+ phar_object_init(TSRMLS_C);
+
+ phar_intercept_functions_init(TSRMLS_C);
+ phar_save_orig_functions(TSRMLS_C);
+
return php_register_url_stream_wrapper("phar", &php_stream_phar_wrapper TSRMLS_CC);
}
/* }}} */
{
php_unregister_url_stream_wrapper("phar" TSRMLS_CC);
- zend_hash_destroy(&PHAR_G(mime_types));
-
phar_intercept_functions_shutdown(TSRMLS_C);
if (zend_compile_file == phar_compile_file) {
PHP_RSHUTDOWN(phar),
PHP_MINFO(phar),
PHP_PHAR_VERSION,
- STANDARD_MODULE_PROPERTIES
+ PHP_MODULE_GLOBALS(phar), /* globals descriptor */
+ PHP_GINIT(phar), /* globals ctor */
+ PHP_GSHUTDOWN(phar), /* globals dtor */
+ NULL, /* post deactivate */
+ STANDARD_MODULE_PROPERTIES_EX
};
/* }}} */