From 32a4f35580436c0c7e74499b78f2390ab7fe367b Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Tue, 19 Mar 2002 14:35:55 +0000 Subject: [PATCH] register some constants for user streams --- ext/standard/basic_functions.c | 2 ++ ext/standard/file.h | 1 + main/php_streams.h | 1 - main/streams.c | 4 +--- main/user_streams.c | 14 ++++++++++++-- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 410b8152e9..5dbc1a1a02 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -1004,6 +1004,8 @@ PHP_MINIT_FUNCTION(basic) if (PG(allow_url_fopen)) { + PHP_MINIT(user_streams) (INIT_FUNC_ARGS_PASSTHRU); + if (FAILURE == php_register_url_stream_wrapper("http", &php_stream_http_wrapper TSRMLS_CC)) return FAILURE; if (FAILURE == php_register_url_stream_wrapper("php", &php_stream_php_wrapper TSRMLS_CC)) diff --git a/ext/standard/file.h b/ext/standard/file.h index d3230fbc35..ba9fb54dae 100644 --- a/ext/standard/file.h +++ b/ext/standard/file.h @@ -72,6 +72,7 @@ PHP_NAMED_FUNCTION(php_if_fstat); PHP_FUNCTION(file_get_wrapper_data); PHP_FUNCTION(file_register_wrapper); +PHP_MINIT_FUNCTION(user_streams); PHPAPI int php_set_sock_blocking(int socketd, int block); PHPAPI int php_file_le_stream(void); diff --git a/main/php_streams.h b/main/php_streams.h index 4a46902536..8d264f021d 100755 --- a/main/php_streams.h +++ b/main/php_streams.h @@ -254,7 +254,6 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show # define IGNORE_URL_WIN 0 #endif -int php_init_user_streams(TSRMLS_D); int php_init_stream_wrappers(TSRMLS_D); int php_shutdown_stream_wrappers(TSRMLS_D); PHPAPI int php_register_url_stream_wrapper(char *protocol, php_stream_wrapper *wrapper TSRMLS_DC); diff --git a/main/streams.c b/main/streams.c index 2cdbd6f27a..24393fed1d 100755 --- a/main/streams.c +++ b/main/streams.c @@ -891,9 +891,7 @@ exit_success: int php_init_stream_wrappers(TSRMLS_D) { if (PG(allow_url_fopen)) { - if (zend_hash_init(&url_stream_wrappers_hash, 0, NULL, NULL, 1) == SUCCESS) - return php_init_user_streams(TSRMLS_C); - return FAILURE; + return zend_hash_init(&url_stream_wrappers_hash, 0, NULL, NULL, 1); } return SUCCESS; } diff --git a/main/user_streams.c b/main/user_streams.c index 226e42192c..99c2079df0 100644 --- a/main/user_streams.c +++ b/main/user_streams.c @@ -41,10 +41,20 @@ static void stream_wrapper_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) efree(uwrap); } -int php_init_user_streams(TSRMLS_D) + +PHP_MINIT_FUNCTION(user_streams) { le_protocols = zend_register_list_destructors_ex(stream_wrapper_dtor, NULL, "stream factory", 0); - return le_protocols == FAILURE ? FAILURE : SUCCESS; + if (le_protocols == FAILURE) + return FAILURE; + + REGISTER_LONG_CONSTANT("STREAM_USE_PATH", USE_PATH, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("STREAM_IGNORE_URL", IGNORE_URL, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("STREAM_ENFORCE_SAFE_MODE", ENFORCE_SAFE_MODE, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("STREAM_REPORT_ERRORS", REPORT_ERRORS, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("STREAM_MUST_SEEK", STREAM_MUST_SEEK, CONST_CS|CONST_PERSISTENT); + + return SUCCESS; } struct _php_userstream_data { -- 2.50.1