diff options
Diffstat (limited to 'main/streams/userspace.c')
| -rw-r--r-- | main/streams/userspace.c | 70 |
1 files changed, 32 insertions, 38 deletions
diff --git a/main/streams/userspace.c b/main/streams/userspace.c index 4925e41ac3..3b513cb7f1 100644 --- a/main/streams/userspace.c +++ b/main/streams/userspace.c @@ -17,8 +17,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #include "php.h" #include "php_globals.h" #include "ext/standard/file.h" @@ -55,7 +53,7 @@ static int user_wrapper_metadata(php_stream_wrapper *wrapper, const char *url, i static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, const char *filename, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC); -static php_stream_wrapper_ops user_stream_wops = { +static const php_stream_wrapper_ops user_stream_wops = { user_wrapper_opener, NULL, /* close - the streams themselves know how */ NULL, /* stat - the streams themselves know how */ @@ -296,7 +294,7 @@ static void user_stream_create_object(struct php_user_stream_wrapper *uwrap, php if (context) { add_property_resource(object, "context", context->res); - GC_REFCOUNT(context->res)++; + GC_ADDREF(context->res); } else { add_property_null(object, "context"); } @@ -314,15 +312,13 @@ static void user_stream_create_object(struct php_user_stream_wrapper *uwrap, php fci.params = NULL; fci.no_separation = 1; - fcc.initialized = 1; fcc.function_handler = uwrap->ce->constructor; - fcc.calling_scope = zend_get_executed_scope(); fcc.called_scope = Z_OBJCE_P(object); fcc.object = Z_OBJ_P(object); if (zend_call_function(&fci, &fcc) == FAILURE) { php_error_docref(NULL, E_WARNING, "Could not execute %s::%s()", ZSTR_VAL(uwrap->ce->name), ZSTR_VAL(uwrap->ce->constructor->common.function_name)); - zval_dtor(object); + zval_ptr_dtor(object); ZVAL_UNDEF(object); } else { zval_ptr_dtor(&retval); @@ -494,7 +490,7 @@ static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, const char } -/* {{{ proto bool stream_wrapper_register(string protocol, string classname[, integer flags]) +/* {{{ proto bool stream_wrapper_register(string protocol, string classname[, int flags]) Registers a custom URL protocol handler class */ PHP_FUNCTION(stream_wrapper_register) { @@ -517,7 +513,7 @@ PHP_FUNCTION(stream_wrapper_register) rsrc = zend_register_resource(uwrap, le_protocols); if ((uwrap->ce = zend_lookup_class(classname)) != NULL) { - if (php_register_url_stream_wrapper_volatile(ZSTR_VAL(protocol), &uwrap->wrapper) == SUCCESS) { + if (php_register_url_stream_wrapper_volatile(protocol, &uwrap->wrapper) == SUCCESS) { RETURN_TRUE; } else { /* We failed. But why? */ @@ -541,16 +537,15 @@ PHP_FUNCTION(stream_wrapper_register) Unregister a wrapper for the life of the current request. */ PHP_FUNCTION(stream_wrapper_unregister) { - char *protocol; - size_t protocol_len; + zend_string *protocol; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &protocol, &protocol_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &protocol) == FAILURE) { RETURN_FALSE; } if (php_unregister_url_stream_wrapper_volatile(protocol) == FAILURE) { /* We failed */ - php_error_docref(NULL, E_WARNING, "Unable to unregister protocol %s://", protocol); + php_error_docref(NULL, E_WARNING, "Unable to unregister protocol %s://", ZSTR_VAL(protocol)); RETURN_FALSE; } @@ -582,9 +577,9 @@ PHP_FUNCTION(stream_wrapper_restore) } /* A failure here could be okay given that the protocol might have been merely unregistered */ - php_unregister_url_stream_wrapper_volatile(ZSTR_VAL(protocol)); + php_unregister_url_stream_wrapper_volatile(protocol); - if (php_register_url_stream_wrapper_volatile(ZSTR_VAL(protocol), wrapper) == FAILURE) { + if (php_register_url_stream_wrapper_volatile(protocol, wrapper) == FAILURE) { php_error_docref(NULL, E_WARNING, "Unable to restore original %s:// wrapper", ZSTR_VAL(protocol)); RETURN_FALSE; } @@ -695,11 +690,11 @@ static size_t php_userstreamop_read(php_stream *stream, char *buf, size_t count) ZVAL_STRINGL(&func_name, USERSTREAM_EOF, sizeof(USERSTREAM_EOF)-1); - call_result = call_user_function_ex(NULL, + call_result = call_user_function(NULL, Z_ISUNDEF(us->object)? NULL : &us->object, &func_name, &retval, - 0, NULL, 0, NULL); + 0, NULL); if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF && zval_is_true(&retval)) { stream->eof = 1; @@ -727,11 +722,11 @@ static int php_userstreamop_close(php_stream *stream, int close_handle) ZVAL_STRINGL(&func_name, USERSTREAM_CLOSE, sizeof(USERSTREAM_CLOSE)-1); - call_user_function_ex(NULL, + call_user_function(NULL, Z_ISUNDEF(us->object)? NULL : &us->object, &func_name, &retval, - 0, NULL, 0, NULL); + 0, NULL); zval_ptr_dtor(&retval); zval_ptr_dtor(&func_name); @@ -755,11 +750,11 @@ static int php_userstreamop_flush(php_stream *stream) ZVAL_STRINGL(&func_name, USERSTREAM_FLUSH, sizeof(USERSTREAM_FLUSH)-1); - call_result = call_user_function_ex(NULL, + call_result = call_user_function(NULL, Z_ISUNDEF(us->object)? NULL : &us->object, &func_name, &retval, - 0, NULL, 0, NULL); + 0, NULL); if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF && zval_is_true(&retval)) call_result = 0; @@ -822,11 +817,11 @@ static int php_userstreamop_seek(php_stream *stream, zend_off_t offset, int when /* now determine where we are */ ZVAL_STRINGL(&func_name, USERSTREAM_TELL, sizeof(USERSTREAM_TELL)-1); - call_result = call_user_function_ex(NULL, + call_result = call_user_function(NULL, Z_ISUNDEF(us->object)? NULL : &us->object, &func_name, &retval, - 0, NULL, 0, NULL); + 0, NULL); if (call_result == SUCCESS && Z_TYPE(retval) == IS_LONG) { *newoffs = Z_LVAL(retval); @@ -863,14 +858,14 @@ static int statbuf_from_array(zval *array, php_stream_statbuf *ssb) STAT_PROP_ENTRY(nlink); STAT_PROP_ENTRY(uid); STAT_PROP_ENTRY(gid); -#if HAVE_ST_RDEV +#if HAVE_STRUCT_STAT_ST_RDEV STAT_PROP_ENTRY(rdev); #endif STAT_PROP_ENTRY(size); STAT_PROP_ENTRY(atime); STAT_PROP_ENTRY(mtime); STAT_PROP_ENTRY(ctime); -#ifdef HAVE_ST_BLKSIZE +#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE STAT_PROP_ENTRY(blksize); #endif #ifdef HAVE_ST_BLOCKS @@ -892,11 +887,11 @@ static int php_userstreamop_stat(php_stream *stream, php_stream_statbuf *ssb) ZVAL_STRINGL(&func_name, USERSTREAM_STAT, sizeof(USERSTREAM_STAT)-1); - call_result = call_user_function_ex(NULL, + call_result = call_user_function(NULL, Z_ISUNDEF(us->object)? NULL : &us->object, &func_name, &retval, - 0, NULL, 0, NULL); + 0, NULL); if (call_result == SUCCESS && Z_TYPE(retval) == IS_ARRAY) { if (SUCCESS == statbuf_from_array(&retval, ssb)) @@ -926,7 +921,7 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value switch (option) { case PHP_STREAM_OPTION_CHECK_LIVENESS: ZVAL_STRINGL(&func_name, USERSTREAM_EOF, sizeof(USERSTREAM_EOF)-1); - call_result = call_user_function_ex(NULL, Z_ISUNDEF(us->object)? NULL : &us->object, &func_name, &retval, 0, NULL, 0, NULL); + call_result = call_user_function(NULL, Z_ISUNDEF(us->object)? NULL : &us->object, &func_name, &retval, 0, NULL); if (call_result == SUCCESS && (Z_TYPE(retval) == IS_FALSE || Z_TYPE(retval) == IS_TRUE)) { ret = zval_is_true(&retval) ? PHP_STREAM_OPTION_RETURN_ERR : PHP_STREAM_OPTION_RETURN_OK; } else { @@ -1075,7 +1070,7 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_SET_OPTION " is not implemented!", us->wrapper->classname); ret = PHP_STREAM_OPTION_RETURN_ERR; - } else if (Z_TYPE(retval) != IS_UNDEF && zend_is_true(&retval)) { + } else if (zend_is_true(&retval)) { ret = PHP_STREAM_OPTION_RETURN_OK; } else { ret = PHP_STREAM_OPTION_RETURN_ERR; @@ -1418,11 +1413,10 @@ static size_t php_userstreamop_readdir(php_stream *stream, char *buf, size_t cou ZVAL_STRINGL(&func_name, USERSTREAM_DIR_READ, sizeof(USERSTREAM_DIR_READ)-1); - call_result = call_user_function_ex(NULL, + call_result = call_user_function(NULL, Z_ISUNDEF(us->object)? NULL : &us->object, &func_name, &retval, - 0, NULL, 0, NULL); if (call_result == SUCCESS && Z_TYPE(retval) != IS_FALSE && Z_TYPE(retval) != IS_TRUE) { @@ -1451,11 +1445,11 @@ static int php_userstreamop_closedir(php_stream *stream, int close_handle) ZVAL_STRINGL(&func_name, USERSTREAM_DIR_CLOSE, sizeof(USERSTREAM_DIR_CLOSE)-1); - call_user_function_ex(NULL, + call_user_function(NULL, Z_ISUNDEF(us->object)? NULL : &us->object, &func_name, &retval, - 0, NULL, 0, NULL); + 0, NULL); zval_ptr_dtor(&retval); zval_ptr_dtor(&func_name); @@ -1475,11 +1469,11 @@ static int php_userstreamop_rewinddir(php_stream *stream, zend_off_t offset, int ZVAL_STRINGL(&func_name, USERSTREAM_DIR_REWIND, sizeof(USERSTREAM_DIR_REWIND)-1); - call_user_function_ex(NULL, + call_user_function(NULL, Z_ISUNDEF(us->object)? NULL : &us->object, &func_name, &retval, - 0, NULL, 0, NULL); + 0, NULL); zval_ptr_dtor(&retval); zval_ptr_dtor(&func_name); @@ -1521,7 +1515,7 @@ static int php_userstreamop_cast(php_stream *stream, int castas, void **retptr) us->wrapper->classname); break; } - if (Z_ISUNDEF(retval) || !zend_is_true(&retval)) { + if (!zend_is_true(&retval)) { break; } php_stream_from_zval_no_verify(intstream, &retval); @@ -1546,7 +1540,7 @@ static int php_userstreamop_cast(php_stream *stream, int castas, void **retptr) return ret; } -php_stream_ops php_stream_userspace_ops = { +const php_stream_ops php_stream_userspace_ops = { php_userstreamop_write, php_userstreamop_read, php_userstreamop_close, php_userstreamop_flush, "user-space", @@ -1556,7 +1550,7 @@ php_stream_ops php_stream_userspace_ops = { php_userstreamop_set_option, }; -php_stream_ops php_stream_userspace_dir_ops = { +const php_stream_ops php_stream_userspace_dir_ops = { NULL, /* write */ php_userstreamop_readdir, php_userstreamop_closedir, |
