/* Reset magic_quotes_runtime */
PG(magic_quotes_runtime) = INI_BOOL("magic_quotes_runtime");
+ /* Default to global wrappers only */
+ FG(stream_wrappers) = NULL;
+
return SUCCESS;
}
}
STR_FREE(BG(locale_string));
+ if (FG(stream_wrappers)) {
+ zend_hash_destroy(FG(stream_wrappers));
+ efree(FG(stream_wrappers));
+ FG(stream_wrappers) = NULL;
+ }
+
PHP_RSHUTDOWN(fsock) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
PHP_RSHUTDOWN(filestat) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
PHP_RSHUTDOWN(syslog) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
PHPAPI int php_register_url_stream_wrapper(char *protocol, php_stream_wrapper *wrapper TSRMLS_DC);
PHPAPI int php_unregister_url_stream_wrapper(char *protocol TSRMLS_DC);
+PHPAPI int php_register_url_stream_wrapper_volatile(char *protocol, php_stream_wrapper *wrapper TSRMLS_DC);
PHPAPI php_stream *_php_stream_open_wrapper_ex(char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, char **path_for_open, int options TSRMLS_DC);
PHPAPI char *php_stream_locate_eol(php_stream *stream, char *buf, size_t buf_len TSRMLS_DC);
/* Give other modules access to the url_stream_wrappers_hash */
-PHPAPI HashTable *php_stream_get_url_stream_wrappers_hash();
+PHPAPI HashTable *_php_stream_get_url_stream_wrappers_hash(TSRMLS_D);
+#define php_stream_get_url_stream_wrappers_hash() _php_stream_get_url_stream_wrappers_hash(TSRMLS_C)
#endif
# define PHP_STREAM_COOKIE_FUNCTIONS stream_cookie_functions
#endif
+/* Global wrapper hash, copied to FG(stream_wrappers) on registration of volatile wrapper */
static HashTable url_stream_wrappers_hash;
static int le_stream = FAILURE; /* true global */
static int le_pstream = FAILURE; /* true global */
return SUCCESS;
}
+/* API for registering GLOBAL wrappers */
PHPAPI int php_register_url_stream_wrapper(char *protocol, php_stream_wrapper *wrapper TSRMLS_DC)
{
return zend_hash_add(&url_stream_wrappers_hash, protocol, strlen(protocol), wrapper, sizeof(*wrapper), NULL);
{
return zend_hash_del(&url_stream_wrappers_hash, protocol, strlen(protocol));
}
+
+/* API for registering VOLATILE wrappers */
+PHPAPI int php_register_url_stream_wrapper_volatile(char *protocol, php_stream_wrapper *wrapper TSRMLS_DC)
+{
+ if (!FG(stream_wrappers)) {
+ php_stream_wrapper tmpwrapper;
+
+ FG(stream_wrappers) = emalloc(sizeof(HashTable));
+ zend_hash_init(FG(stream_wrappers), 0, NULL, NULL, 1);
+ zend_hash_copy(FG(stream_wrappers), &url_stream_wrappers_hash, NULL, &tmpwrapper, sizeof(php_stream_wrapper));
+ }
+
+ return zend_hash_add(FG(stream_wrappers), protocol, strlen(protocol), wrapper, sizeof(*wrapper), NULL);
+}
/* }}} */
PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, char **path_for_open, int options TSRMLS_DC)
{
+ HashTable *wrapper_hash = (FG(stream_wrappers) ? FG(stream_wrappers) : &url_stream_wrappers_hash);
php_stream_wrapper *wrapper = NULL;
const char *p, *protocol = NULL;
int n = 0;
}
if (protocol) {
- if (FAILURE == zend_hash_find(&url_stream_wrappers_hash, (char*)protocol, n, (void**)&wrapper)) {
+ if (FAILURE == zend_hash_find(wrapper_hash, (char*)protocol, n, (void**)&wrapper)) {
char wrapper_name[32];
if (options & REPORT_ERRORS) {
return zend_hash_update(Z_ARRVAL_PP(wrapperhash), (char*)optionname, strlen(optionname)+1, (void**)&copied_val, sizeof(zval *), NULL);
}
-PHPAPI HashTable *php_stream_get_url_stream_wrappers_hash()
+PHPAPI HashTable *_php_stream_get_url_stream_wrappers_hash(TSRMLS_D)
{
- return &url_stream_wrappers_hash;
+ return (FG(stream_wrappers) ? FG(stream_wrappers) : &url_stream_wrappers_hash);
}
/*