com php-src: Turn "php_stream_wrapper"s into consta nts Keep non-constant "php_stream_wrapper"s in API functions and callbacks for compatibility. :
ext/bz2/bz2.c ext/phar/phar_internal.h ext/ phar/stream.c ext/standard/ftp_fopen_wrapper.c ext/ standard/http_fopen_wrapper.c ext/standard/php_fopen
_wrapper.c ext/standard/php_fopen_wrappers.h ext/ zip/php_zip.h ext/zip/zip_stream.c ext/zlib/php_z lib.h ext/zlib/zlib_fopen_wrapper.c main/php_memo
ry_streams.
| From: | Dmitry Stogov | Date: | Thu, 14 Dec 2017 19:46:22 +0000 |
| Subject: | com php-src: Turn "php_stream_wrapper"s into consta nts Keep non-constant "php_stream_wrapper"s in API functions and callbacks for compatibility. : ext/bz2/bz2.c ext/phar/phar_internal.h ext/ phar/stream.c ext/standard/ftp_fopen_wrapper.c ext/ standard/http_fopen_wrapper.c ext/standard/php_fopen _wrapper.c ext/standard/php_fopen_wrappers.h ext/ zip/php_zip.h ext/zip/zip_stream.c ext/zlib/php_z lib.h ext/zlib/zlib_fopen_wrapper.c main/php_memo ry_streams. |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-100585@lists.php.net to get a copy of this message | ||
Commit: 0f06df310c879e3506409277831c4cba7d4d9af7
Author: Dmitry Stogov <dmitry@zend.com> Thu, 14 Dec 2017 22:46:22 +0300
Parents: 83e495e0fdc0c59b449bd173d0c8df1999239634
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0f06df310c879e3506409277831c4cba7d4d9af7
Log:
Turn "php_stream_wrapper"s into constants
Keep non-constant "php_stream_wrapper"s in API functions and callbacks for compatibility.
Changed paths:
M ext/bz2/bz2.c
M ext/phar/phar_internal.h
M ext/phar/stream.c
M ext/standard/ftp_fopen_wrapper.c
M ext/standard/http_fopen_wrapper.c
M ext/standard/php_fopen_wrapper.c
M ext/standard/php_fopen_wrappers.h
M ext/zip/php_zip.h
M ext/zip/zip_stream.c
M ext/zlib/php_zlib.h
M ext/zlib/zlib_fopen_wrapper.c
M main/php_memory_streams.h
M main/php_streams.h
M main/streams/glob_wrapper.c
M main/streams/memory.c
M main/streams/php_stream_glob_wrapper.h
M main/streams/php_stream_plain_wrapper.h
M main/streams/plain_wrapper.c
M main/streams/streams.c
diff --git a/ext/bz2/bz2.c b/ext/bz2/bz2.c index 5250bf4..5d25f38 100644 --- a/ext/bz2/bz2.c +++ b/ext/bz2/bz2.c @@ -331,7 +331,7 @@ static const php_stream_wrapper_ops bzip2_stream_wops = { NULL }; -static php_stream_wrapper php_stream_bzip2_wrapper = { +static const php_stream_wrapper php_stream_bzip2_wrapper = { &bzip2_stream_wops, NULL, 0 /* is_url */ diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h index c08c88d..88bad68 100644 --- a/ext/phar/phar_internal.h +++ b/ext/phar/phar_internal.h @@ -576,7 +576,7 @@ int phar_zip_flush(phar_archive_data *archive, char *user_stub, zend_long len, i #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); -extern php_stream_wrapper php_stream_phar_wrapper; +extern const php_stream_wrapper php_stream_phar_wrapper; #else extern HashTable cached_phars; extern HashTable cached_alias; diff --git a/ext/phar/stream.c b/ext/phar/stream.c index 3ef4952..63703dd 100644 --- a/ext/phar/stream.c +++ b/ext/phar/stream.c @@ -48,7 +48,7 @@ const php_stream_wrapper_ops phar_stream_wops = { NULL }; -php_stream_wrapper php_stream_phar_wrapper = { +const php_stream_wrapper php_stream_phar_wrapper = { &phar_stream_wops, NULL, 0 /* is_url */ diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c index f8491cc..8565acc 100644 --- a/ext/standard/ftp_fopen_wrapper.c +++ b/ext/standard/ftp_fopen_wrapper.c @@ -1184,7 +1184,7 @@ static const php_stream_wrapper_ops ftp_stream_wops = { NULL }; -PHPAPI php_stream_wrapper php_stream_ftp_wrapper = { +PHPAPI const php_stream_wrapper php_stream_ftp_wrapper = { &ftp_stream_wops, NULL, 1 /* is_url */ diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index c9cb035..6c20b54 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -1017,7 +1017,7 @@ static const php_stream_wrapper_ops http_stream_wops = { NULL }; -PHPAPI php_stream_wrapper php_stream_http_wrapper = { +PHPAPI const php_stream_wrapper php_stream_http_wrapper = { &http_stream_wops, NULL, 1 /* is_url */ diff --git a/ext/standard/php_fopen_wrapper.c b/ext/standard/php_fopen_wrapper.c index 9ac006b..47d4c40 100644 --- a/ext/standard/php_fopen_wrapper.c +++ b/ext/standard/php_fopen_wrapper.c @@ -437,7 +437,7 @@ static const php_stream_wrapper_ops php_stdio_wops = { NULL }; -PHPAPI php_stream_wrapper php_stream_php_wrapper = { +PHPAPI const php_stream_wrapper php_stream_php_wrapper = { &php_stdio_wops, NULL, 0, /* is_url */ diff --git a/ext/standard/php_fopen_wrappers.h b/ext/standard/php_fopen_wrappers.h index b5a5381..189496f 100644 --- a/ext/standard/php_fopen_wrappers.h +++ b/ext/standard/php_fopen_wrappers.h @@ -25,9 +25,9 @@ php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC); php_stream *php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC); -extern PHPAPI php_stream_wrapper php_stream_http_wrapper; -extern PHPAPI php_stream_wrapper php_stream_ftp_wrapper; -extern PHPAPI php_stream_wrapper php_stream_php_wrapper; -extern PHPAPI php_stream_wrapper php_plain_files_wrapper; +extern PHPAPI const php_stream_wrapper php_stream_http_wrapper; +extern PHPAPI const php_stream_wrapper php_stream_ftp_wrapper; +extern PHPAPI const php_stream_wrapper php_stream_php_wrapper; +extern PHPAPI const php_stream_wrapper php_plain_files_wrapper; #endif diff --git a/ext/zip/php_zip.h b/ext/zip/php_zip.h index 5853097..bc41502 100644 --- a/ext/zip/php_zip.h +++ b/ext/zip/php_zip.h @@ -77,7 +77,7 @@ static inline ze_zip_object *php_zip_fetch_object(zend_object *obj) { php_stream *php_stream_zip_opener(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC); php_stream *php_stream_zip_open(const char *filename, const char *path, const char *mode STREAMS_DC); -extern php_stream_wrapper php_stream_zip_wrapper; +extern const php_stream_wrapper php_stream_zip_wrapper; #endif /* PHP_ZIP_H */ diff --git a/ext/zip/zip_stream.c b/ext/zip/zip_stream.c index d4c9d93..04e4198 100644 --- a/ext/zip/zip_stream.c +++ b/ext/zip/zip_stream.c @@ -362,7 +362,7 @@ static const php_stream_wrapper_ops zip_stream_wops = { NULL /* metadata */ }; -php_stream_wrapper php_stream_zip_wrapper = { +const php_stream_wrapper php_stream_zip_wrapper = { &zip_stream_wops, NULL, 0 /* is_url */ diff --git a/ext/zlib/php_zlib.h b/ext/zlib/php_zlib.h index cf79ccd..8b085f7 100644 --- a/ext/zlib/php_zlib.h +++ b/ext/zlib/php_zlib.h @@ -68,7 +68,7 @@ ZEND_END_MODULE_GLOBALS(zlib); php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC); extern const php_stream_ops php_stream_gzio_ops; -extern php_stream_wrapper php_stream_gzip_wrapper; +extern const php_stream_wrapper php_stream_gzip_wrapper; extern const php_stream_filter_factory php_zlib_filter_factory; extern zend_module_entry php_zlib_module_entry; #define zlib_module_ptr &php_zlib_module_entry diff --git a/ext/zlib/zlib_fopen_wrapper.c b/ext/zlib/zlib_fopen_wrapper.c index aea7d2d..e6e4bab 100644 --- a/ext/zlib/zlib_fopen_wrapper.c +++ b/ext/zlib/zlib_fopen_wrapper.c @@ -181,7 +181,7 @@ static const php_stream_wrapper_ops gzip_stream_wops = { NULL }; -php_stream_wrapper php_stream_gzip_wrapper = { +const php_stream_wrapper php_stream_gzip_wrapper = { &gzip_stream_wops, NULL, 0, /* is_url */ diff --git a/main/php_memory_streams.h b/main/php_memory_streams.h index b7f0ce8..21cb856 100644 --- a/main/php_memory_streams.h +++ b/main/php_memory_streams.h @@ -59,7 +59,7 @@ END_EXTERN_C() extern PHPAPI const php_stream_ops php_stream_memory_ops; extern PHPAPI const php_stream_ops php_stream_temp_ops; extern PHPAPI const php_stream_ops php_stream_rfc2397_ops; -extern PHPAPI php_stream_wrapper php_stream_rfc2397_wrapper; +extern PHPAPI const php_stream_wrapper php_stream_rfc2397_wrapper; #define PHP_STREAM_IS_MEMORY &php_stream_memory_ops #define PHP_STREAM_IS_TEMP &php_stream_temp_ops diff --git a/main/php_streams.h b/main/php_streams.h index ecc63ca..beb65f0 100644 --- a/main/php_streams.h +++ b/main/php_streams.h @@ -561,7 +561,7 @@ void php_shutdown_stream_hashes(void); PHP_RSHUTDOWN_FUNCTION(streams); BEGIN_EXTERN_C() -PHPAPI int php_register_url_stream_wrapper(const char *protocol, php_stream_wrapper *wrapper); +PHPAPI int php_register_url_stream_wrapper(const char *protocol, const php_stream_wrapper *wrapper); PHPAPI int php_unregister_url_stream_wrapper(const char *protocol); PHPAPI int php_register_url_stream_wrapper_volatile(zend_string *protocol, php_stream_wrapper *wrapper); PHPAPI int php_unregister_url_stream_wrapper_volatile(zend_string *protocol); @@ -573,7 +573,7 @@ PHPAPI const char *php_stream_locate_eol(php_stream *stream, zend_string *buf); #define php_stream_open_wrapper_ex(path, mode, options, opened, context) _php_stream_open_wrapper_ex((path), (mode), (options), (opened), (context) STREAMS_CC) /* pushes an error message onto the stack for a wrapper instance */ -PHPAPI void php_stream_wrapper_log_error(php_stream_wrapper *wrapper, int options, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4); +PHPAPI void php_stream_wrapper_log_error(const php_stream_wrapper *wrapper, int options, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4); #define PHP_STREAM_UNCHANGED 0 /* orig stream was seekable anyway */ #define PHP_STREAM_RELEASED 1 /* newstream should be used; origstream is no longer valid */ diff --git a/main/streams/glob_wrapper.c b/main/streams/glob_wrapper.c index 0b992a1..ad6b5a1 100644 --- a/main/streams/glob_wrapper.c +++ b/main/streams/glob_wrapper.c @@ -275,7 +275,7 @@ static const php_stream_wrapper_ops php_glob_stream_wrapper_ops = { NULL }; -php_stream_wrapper php_glob_stream_wrapper = { +const php_stream_wrapper php_glob_stream_wrapper = { &php_glob_stream_wrapper_ops, NULL, 0 diff --git a/main/streams/memory.c b/main/streams/memory.c index c1ef32f..89fb99b 100644 --- a/main/streams/memory.c +++ b/main/streams/memory.c @@ -786,7 +786,7 @@ PHPAPI const php_stream_wrapper_ops php_stream_rfc2397_wops = { NULL, /* stream_metadata */ }; -PHPAPI php_stream_wrapper php_stream_rfc2397_wrapper = { +PHPAPI const php_stream_wrapper php_stream_rfc2397_wrapper = { &php_stream_rfc2397_wops, NULL, 1, /* is_url */ diff --git a/main/streams/php_stream_glob_wrapper.h b/main/streams/php_stream_glob_wrapper.h index 1eb2d8b..3cc303d 100644 --- a/main/streams/php_stream_glob_wrapper.h +++ b/main/streams/php_stream_glob_wrapper.h @@ -18,8 +18,8 @@ /* $Id$ */ -PHPAPI extern php_stream_wrapper php_glob_stream_wrapper; -PHPAPI extern const php_stream_ops php_glob_stream_ops; +PHPAPI extern const php_stream_wrapper php_glob_stream_wrapper; +PHPAPI extern const php_stream_ops php_glob_stream_ops; BEGIN_EXTERN_C() diff --git a/main/streams/php_stream_plain_wrapper.h b/main/streams/php_stream_plain_wrapper.h index e2e51aa..42f1c02 100644 --- a/main/streams/php_stream_plain_wrapper.h +++ b/main/streams/php_stream_plain_wrapper.h @@ -22,7 +22,7 @@ /* operations for a plain file; use the php_stream_fopen_XXX funcs below */ PHPAPI extern php_stream_ops php_stream_stdio_ops; -PHPAPI extern php_stream_wrapper php_plain_files_wrapper; +PHPAPI extern const php_stream_wrapper php_plain_files_wrapper; BEGIN_EXTERN_C() diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 33f425f..53e677d 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -221,7 +221,7 @@ PHPAPI php_stream *_php_stream_fopen_temporary_file(const char *dir, const char stream = php_stream_fopen_from_fd_int_rel(fd, "r+b", NULL); if (stream) { php_stdio_stream_data *self = (php_stdio_stream_data*)stream->abstract; - stream->wrapper = &php_plain_files_wrapper; + stream->wrapper = (php_stream_wrapper*)&php_plain_files_wrapper; stream->orig_path = estrndup(ZSTR_VAL(opened_path), ZSTR_LEN(opened_path)); self->temp_name = opened_path; @@ -942,7 +942,7 @@ static php_stream *php_plain_files_dir_opener(php_stream_wrapper *wrapper, const #ifdef HAVE_GLOB if (options & STREAM_USE_GLOB_DIR_OPEN) { - return php_glob_stream_wrapper.wops->dir_opener(&php_glob_stream_wrapper, path, mode, options, opened_path, context STREAMS_REL_CC); + return php_glob_stream_wrapper.wops->dir_opener((php_stream_wrapper*)&php_glob_stream_wrapper, path, mode, options, opened_path, context STREAMS_REL_CC); } #endif @@ -1424,7 +1424,7 @@ static const php_stream_wrapper_ops php_plain_files_wrapper_ops = { php_plain_files_metadata }; -PHPAPI php_stream_wrapper php_plain_files_wrapper = { +PHPAPI const php_stream_wrapper php_plain_files_wrapper = { &php_plain_files_wrapper_ops, NULL, 0 diff --git a/main/streams/streams.c b/main/streams/streams.c index cf334cb..e92de7a 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -230,7 +230,7 @@ static void wrapper_list_dtor(zval *item) { efree(list); } -PHPAPI void php_stream_wrapper_log_error(php_stream_wrapper *wrapper, int options, const char *fmt, ...) +PHPAPI void php_stream_wrapper_log_error(const php_stream_wrapper *wrapper, int options, const char *fmt, ...) { va_list args; char *buffer = NULL; @@ -1665,7 +1665,7 @@ static inline int php_stream_wrapper_scheme_validate(const char *protocol, unsig } /* API for registering GLOBAL wrappers */ -PHPAPI int php_register_url_stream_wrapper(const char *protocol, php_stream_wrapper *wrapper) +PHPAPI int php_register_url_stream_wrapper(const char *protocol, const php_stream_wrapper *wrapper) { unsigned int protocol_len = (unsigned int)strlen(protocol); int ret; @@ -1676,7 +1676,7 @@ PHPAPI int php_register_url_stream_wrapper(const char *protocol, php_stream_wrap } str = zend_string_init_interned(protocol, protocol_len, 1); - ret = zend_hash_add_ptr(&url_stream_wrappers_hash, str, wrapper) ? SUCCESS : FAILURE; + ret = zend_hash_add_ptr(&url_stream_wrappers_hash, str, (void*)wrapper) ? SUCCESS : FAILURE; zend_string_release(str); return ret; } @@ -1730,7 +1730,7 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, const } if (options & IGNORE_URL) { - return (options & STREAM_LOCATE_WRAPPERS_ONLY) ? NULL : &php_plain_files_wrapper; + return (php_stream_wrapper*)((options & STREAM_LOCATE_WRAPPERS_ONLY) ? NULL : &php_plain_files_wrapper); } for (p = path; isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'; p++) { @@ -1765,7 +1765,7 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, const /* TODO: curl based streams probably support file:// properly */ if (!protocol || !strncasecmp(protocol, "file", n)) { /* fall back on regular file access */ - php_stream_wrapper *plain_files_wrapper = &php_plain_files_wrapper; + php_stream_wrapper *plain_files_wrapper = (php_stream_wrapper*)&php_plain_files_wrapper; if (protocol) { int localhost = 0;
diff --git a/ext/bz2/bz2.c b/ext/bz2/bz2.c index 5250bf4..5d25f38 100644 --- a/ext/bz2/bz2.c +++ b/ext/bz2/bz2.c @@ -331,7 +331,7 @@ static const php_stream_wrapper_ops bzip2_stream_wops = { NULL }; -static php_stream_wrapper php_stream_bzip2_wrapper = { +static const php_stream_wrapper php_stream_bzip2_wrapper = { &bzip2_stream_wops, NULL, 0 /* is_url */ diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h index c08c88d..88bad68 100644 --- a/ext/phar/phar_internal.h +++ b/ext/phar/phar_internal.h @@ -576,7 +576,7 @@ int phar_zip_flush(phar_archive_data *archive, char *user_stub, zend_long len, i #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); -extern php_stream_wrapper php_stream_phar_wrapper; +extern const php_stream_wrapper php_stream_phar_wrapper; #else extern HashTable cached_phars; extern HashTable cached_alias; diff --git a/ext/phar/stream.c b/ext/phar/stream.c index 3ef4952..63703dd 100644 --- a/ext/phar/stream.c +++ b/ext/phar/stream.c @@ -48,7 +48,7 @@ const php_stream_wrapper_ops phar_stream_wops = { NULL }; -php_stream_wrapper php_stream_phar_wrapper = { +const php_stream_wrapper php_stream_phar_wrapper = { &phar_stream_wops, NULL, 0 /* is_url */ diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c index f8491cc..8565acc 100644 --- a/ext/standard/ftp_fopen_wrapper.c +++ b/ext/standard/ftp_fopen_wrapper.c @@ -1184,7 +1184,7 @@ static const php_stream_wrapper_ops ftp_stream_wops = { NULL }; -PHPAPI php_stream_wrapper php_stream_ftp_wrapper = { +PHPAPI const php_stream_wrapper php_stream_ftp_wrapper = { &ftp_stream_wops, NULL, 1 /* is_url */ diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index c9cb035..6c20b54 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -1017,7 +1017,7 @@ static const php_stream_wrapper_ops http_stream_wops = { NULL }; -PHPAPI php_stream_wrapper php_stream_http_wrapper = { +PHPAPI const php_stream_wrapper php_stream_http_wrapper = { &http_stream_wops, NULL, 1 /* is_url */ diff --git a/ext/standard/php_fopen_wrapper.c b/ext/standard/php_fopen_wrapper.c index 9ac006b..47d4c40 100644 --- a/ext/standard/php_fopen_wrapper.c +++ b/ext/standard/php_fopen_wrapper.c @@ -437,7 +437,7 @@ static const php_stream_wrapper_ops php_stdio_wops = { NULL }; -PHPAPI php_stream_wrapper php_stream_php_wrapper = { +PHPAPI const php_stream_wrapper php_stream_php_wrapper = { &php_stdio_wops, NULL, 0, /* is_url */ diff --git a/ext/standard/php_fopen_wrappers.h b/ext/standard/php_fopen_wrappers.h index b5a5381..189496f 100644 --- a/ext/standard/php_fopen_wrappers.h +++ b/ext/standard/php_fopen_wrappers.h @@ -25,9 +25,9 @@ php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC); php_stream *php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC); -extern PHPAPI php_stream_wrapper php_stream_http_wrapper; -extern PHPAPI php_stream_wrapper php_stream_ftp_wrapper; -extern PHPAPI php_stream_wrapper php_stream_php_wrapper; -extern PHPAPI php_stream_wrapper php_plain_files_wrapper; +extern PHPAPI const php_stream_wrapper php_stream_http_wrapper; +extern PHPAPI const php_stream_wrapper php_stream_ftp_wrapper; +extern PHPAPI const php_stream_wrapper php_stream_php_wrapper; +extern PHPAPI const php_stream_wrapper php_plain_files_wrapper; #endif diff --git a/ext/zip/php_zip.h b/ext/zip/php_zip.h index 5853097..bc41502 100644 --- a/ext/zip/php_zip.h +++ b/ext/zip/php_zip.h @@ -77,7 +77,7 @@ static inline ze_zip_object *php_zip_fetch_object(zend_object *obj) { php_stream *php_stream_zip_opener(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC); php_stream *php_stream_zip_open(const char *filename, const char *path, const char *mode STREAMS_DC); -extern php_stream_wrapper php_stream_zip_wrapper; +extern const php_stream_wrapper php_stream_zip_wrapper; #endif /* PHP_ZIP_H */ diff --git a/ext/zip/zip_stream.c b/ext/zip/zip_stream.c index d4c9d93..04e4198 100644 --- a/ext/zip/zip_stream.c +++ b/ext/zip/zip_stream.c @@ -362,7 +362,7 @@ static const php_stream_wrapper_ops zip_stream_wops = { NULL /* metadata */ }; -php_stream_wrapper php_stream_zip_wrapper = { +const php_stream_wrapper php_stream_zip_wrapper = { &zip_stream_wops, NULL, 0 /* is_url */ diff --git a/ext/zlib/php_zlib.h b/ext/zlib/php_zlib.h index cf79ccd..8b085f7 100644 --- a/ext/zlib/php_zlib.h +++ b/ext/zlib/php_zlib.h @@ -68,7 +68,7 @@ ZEND_END_MODULE_GLOBALS(zlib); php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC); extern const php_stream_ops php_stream_gzio_ops; -extern php_stream_wrapper php_stream_gzip_wrapper; +extern const php_stream_wrapper php_stream_gzip_wrapper; extern const php_stream_filter_factory php_zlib_filter_factory; extern zend_module_entry php_zlib_module_entry; #define zlib_module_ptr &php_zlib_module_entry diff --git a/ext/zlib/zlib_fopen_wrapper.c b/ext/zlib/zlib_fopen_wrapper.c index aea7d2d..e6e4bab 100644 --- a/ext/zlib/zlib_fopen_wrapper.c +++ b/ext/zlib/zlib_fopen_wrapper.c @@ -181,7 +181,7 @@ static const php_stream_wrapper_ops gzip_stream_wops = { NULL }; -php_stream_wrapper php_stream_gzip_wrapper = { +const php_stream_wrapper php_stream_gzip_wrapper = { &gzip_stream_wops, NULL, 0, /* is_url */ diff --git a/main/php_memory_streams.h b/main/php_memory_streams.h index b7f0ce8..21cb856 100644 --- a/main/php_memory_streams.h +++ b/main/php_memory_streams.h @@ -59,7 +59,7 @@ END_EXTERN_C() extern PHPAPI const php_stream_ops php_stream_memory_ops; extern PHPAPI const php_stream_ops php_stream_temp_ops; extern PHPAPI const php_stream_ops php_stream_rfc2397_ops; -extern PHPAPI php_stream_wrapper php_stream_rfc2397_wrapper; +extern PHPAPI const php_stream_wrapper php_stream_rfc2397_wrapper; #define PHP_STREAM_IS_MEMORY &php_stream_memory_ops #define PHP_STREAM_IS_TEMP &php_stream_temp_ops diff --git a/main/php_streams.h b/main/php_streams.h index ecc63ca..beb65f0 100644 --- a/main/php_streams.h +++ b/main/php_streams.h @@ -561,7 +561,7 @@ void php_shutdown_stream_hashes(void); PHP_RSHUTDOWN_FUNCTION(streams); BEGIN_EXTERN_C() -PHPAPI int php_register_url_stream_wrapper(const char *protocol, php_stream_wrapper *wrapper); +PHPAPI int php_register_url_stream_wrapper(const char *protocol, const php_stream_wrapper *wrapper); PHPAPI int php_unregister_url_stream_wrapper(const char *protocol); PHPAPI int php_register_url_stream_wrapper_volatile(zend_string *protocol, php_stream_wrapper *wrapper); PHPAPI int php_unregister_url_stream_wrapper_volatile(zend_string *protocol); @@ -573,7 +573,7 @@ PHPAPI const char *php_stream_locate_eol(php_stream *stream, zend_string *buf); #define php_stream_open_wrapper_ex(path, mode, options, opened, context) _php_stream_open_wrapper_ex((path), (mode), (options), (opened), (context) STREAMS_CC) /* pushes an error message onto the stack for a wrapper instance */ -PHPAPI void php_stream_wrapper_log_error(php_stream_wrapper *wrapper, int options, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4); +PHPAPI void php_stream_wrapper_log_error(const php_stream_wrapper *wrapper, int options, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4); #define PHP_STREAM_UNCHANGED 0 /* orig stream was seekable anyway */ #define PHP_STREAM_RELEASED 1 /* newstream should be used; origstream is no longer valid */ diff --git a/main/streams/glob_wrapper.c b/main/streams/glob_wrapper.c index 0b992a1..ad6b5a1 100644 --- a/main/streams/glob_wrapper.c +++ b/main/streams/glob_wrapper.c @@ -275,7 +275,7 @@ static const php_stream_wrapper_ops php_glob_stream_wrapper_ops = { NULL }; -php_stream_wrapper php_glob_stream_wrapper = { +const php_stream_wrapper php_glob_stream_wrapper = { &php_glob_stream_wrapper_ops, NULL, 0 diff --git a/main/streams/memory.c b/main/streams/memory.c index c1ef32f..89fb99b 100644 --- a/main/streams/memory.c +++ b/main/streams/memory.c @@ -786,7 +786,7 @@ PHPAPI const php_stream_wrapper_ops php_stream_rfc2397_wops = { NULL, /* stream_metadata */ }; -PHPAPI php_stream_wrapper php_stream_rfc2397_wrapper = { +PHPAPI const php_stream_wrapper php_stream_rfc2397_wrapper = { &php_stream_rfc2397_wops, NULL, 1, /* is_url */ diff --git a/main/streams/php_stream_glob_wrapper.h b/main/streams/php_stream_glob_wrapper.h index 1eb2d8b..3cc303d 100644 --- a/main/streams/php_stream_glob_wrapper.h +++ b/main/streams/php_stream_glob_wrapper.h @@ -18,8 +18,8 @@ /* $Id$ */ -PHPAPI extern php_stream_wrapper php_glob_stream_wrapper; -PHPAPI extern const php_stream_ops php_glob_stream_ops; +PHPAPI extern const php_stream_wrapper php_glob_stream_wrapper; +PHPAPI extern const php_stream_ops php_glob_stream_ops; BEGIN_EXTERN_C() diff --git a/main/streams/php_stream_plain_wrapper.h b/main/streams/php_stream_plain_wrapper.h index e2e51aa..42f1c02 100644 --- a/main/streams/php_stream_plain_wrapper.h +++ b/main/streams/php_stream_plain_wrapper.h @@ -22,7 +22,7 @@ /* operations for a plain file; use the php_stream_fopen_XXX funcs below */ PHPAPI extern php_stream_ops php_stream_stdio_ops; -PHPAPI extern php_stream_wrapper php_plain_files_wrapper; +PHPAPI extern const php_stream_wrapper php_plain_files_wrapper; BEGIN_EXTERN_C() diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 33f425f..53e677d 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -221,7 +221,7 @@ PHPAPI php_stream *_php_stream_fopen_temporary_file(const char *dir, const char stream = php_stream_fopen_from_fd_int_rel(fd, "r+b", NULL); if (stream) { php_stdio_stream_data *self = (php_stdio_stream_data*)stream->abstract; - stream->wrapper = &php_plain_files_wrapper; + stream->wrapper = (php_stream_wrapper*)&php_plain_files_wrapper; stream->orig_path = estrndup(ZSTR_VAL(opened_path), ZSTR_LEN(opened_path)); self->temp_name = opened_path; @@ -942,7 +942,7 @@ static php_stream *php_plain_files_dir_opener(php_stream_wrapper *wrapper, const #ifdef HAVE_GLOB if (options & STREAM_USE_GLOB_DIR_OPEN) { - return php_glob_stream_wrapper.wops->dir_opener(&php_glob_stream_wrapper, path, mode, options, opened_path, context STREAMS_REL_CC); + return php_glob_stream_wrapper.wops->dir_opener((php_stream_wrapper*)&php_glob_stream_wrapper, path, mode, options, opened_path, context STREAMS_REL_CC); } #endif @@ -1424,7 +1424,7 @@ static const php_stream_wrapper_ops php_plain_files_wrapper_ops = { php_plain_files_metadata }; -PHPAPI php_stream_wrapper php_plain_files_wrapper = { +PHPAPI const php_stream_wrapper php_plain_files_wrapper = { &php_plain_files_wrapper_ops, NULL, 0 diff --git a/main/streams/streams.c b/main/streams/streams.c index cf334cb..e92de7a 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -230,7 +230,7 @@ static void wrapper_list_dtor(zval *item) { efree(list); } -PHPAPI void php_stream_wrapper_log_error(php_stream_wrapper *wrapper, int options, const char *fmt, ...) +PHPAPI void php_stream_wrapper_log_error(const php_stream_wrapper *wrapper, int options, const char *fmt, ...) { va_list args; char *buffer = NULL; @@ -1665,7 +1665,7 @@ static inline int php_stream_wrapper_scheme_validate(const char *protocol, unsig } /* API for registering GLOBAL wrappers */ -PHPAPI int php_register_url_stream_wrapper(const char *protocol, php_stream_wrapper *wrapper) +PHPAPI int php_register_url_stream_wrapper(const char *protocol, const php_stream_wrapper *wrapper) { unsigned int protocol_len = (unsigned int)strlen(protocol); int ret; @@ -1676,7 +1676,7 @@ PHPAPI int php_register_url_stream_wrapper(const char *protocol, php_stream_wrap } str = zend_string_init_interned(protocol, protocol_len, 1); - ret = zend_hash_add_ptr(&url_stream_wrappers_hash, str, wrapper) ? SUCCESS : FAILURE; + ret = zend_hash_add_ptr(&url_stream_wrappers_hash, str, (void*)wrapper) ? SUCCESS : FAILURE; zend_string_release(str); return ret; } @@ -1730,7 +1730,7 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, const } if (options & IGNORE_URL) { - return (options & STREAM_LOCATE_WRAPPERS_ONLY) ? NULL : &php_plain_files_wrapper; + return (php_stream_wrapper*)((options & STREAM_LOCATE_WRAPPERS_ONLY) ? NULL : &php_plain_files_wrapper); } for (p = path; isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'; p++) { @@ -1765,7 +1765,7 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, const /* TODO: curl based streams probably support file:// properly */ if (!protocol || !strncasecmp(protocol, "file", n)) { /* fall back on regular file access */ - php_stream_wrapper *plain_files_wrapper = &php_plain_files_wrapper; + php_stream_wrapper *plain_files_wrapper = (php_stream_wrapper*)&php_plain_files_wrapper; if (protocol) { int localhost = 0;