summaryrefslogtreecommitdiff
path: root/ext/standard/streamsfuncs.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard/streamsfuncs.c')
-rw-r--r--ext/standard/streamsfuncs.c270
1 files changed, 129 insertions, 141 deletions
diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c
index b623447651..68567ea0d5 100644
--- a/ext/standard/streamsfuncs.c
+++ b/ext/standard/streamsfuncs.c
@@ -75,8 +75,8 @@ PHP_FUNCTION(stream_socket_pair)
php_stream_auto_cleanup(s1);
php_stream_auto_cleanup(s2);
- add_next_index_resource(return_value, php_stream_get_resource_id(s1));
- add_next_index_resource(return_value, php_stream_get_resource_id(s2));
+ add_next_index_resource(return_value, s1->res);
+ add_next_index_resource(return_value, s2->res);
}
/* }}} */
#endif
@@ -125,7 +125,7 @@ PHP_FUNCTION(stream_socket_client)
}
if (zerrstr) {
zval_dtor(zerrstr);
- ZVAL_STRING(zerrstr, "", 1);
+ ZVAL_EMPTY_STRING(zerrstr);
}
stream = php_stream_xport_create(host, host_len, REPORT_ERRORS,
@@ -154,7 +154,8 @@ PHP_FUNCTION(stream_socket_client)
if (zerrstr && errstr) {
/* no need to dup; we need to efree buf anyway */
zval_dtor(zerrstr);
- ZVAL_STRING(zerrstr, errstr, 0);
+//??? ZVAL_STRING(zerrstr, errstr, 0);
+ ZVAL_STRING(zerrstr, errstr);
} else if (errstr) {
efree(errstr);
}
@@ -192,7 +193,7 @@ PHP_FUNCTION(stream_socket_server)
context = php_stream_context_from_zval(zcontext, flags & PHP_FILE_NO_DEFAULT_CONTEXT);
if (context) {
- zend_list_addref(context->rsrc_id);
+ context->res->gc.refcount++;
}
if (zerrno) {
@@ -201,7 +202,7 @@ PHP_FUNCTION(stream_socket_server)
}
if (zerrstr) {
zval_dtor(zerrstr);
- ZVAL_STRING(zerrstr, "", 1);
+ ZVAL_EMPTY_STRING(zerrstr);
}
stream = php_stream_xport_create(host, host_len, REPORT_ERRORS,
@@ -220,7 +221,8 @@ PHP_FUNCTION(stream_socket_server)
if (zerrstr && errstr) {
/* no need to dup; we need to efree buf anyway */
zval_dtor(zerrstr);
- ZVAL_STRING(zerrstr, errstr, 0);
+//??? ZVAL_STRING(zerrstr, errstr, 0);
+ ZVAL_STRING(zerrstr, errstr);
} else if (errstr) {
efree(errstr);
}
@@ -254,7 +256,7 @@ PHP_FUNCTION(stream_socket_accept)
RETURN_FALSE;
}
- php_stream_from_zval(stream, &zstream);
+ php_stream_from_zval(stream, zstream);
/* prepare the timeout value for use */
conv = (php_timeout_ull) (timeout * 1000000.0);
@@ -278,7 +280,8 @@ PHP_FUNCTION(stream_socket_accept)
TSRMLS_CC) && clistream) {
if (peername) {
- ZVAL_STRINGL(zpeername, peername, peername_len, 0);
+//??? ZVAL_STRINGL(zpeername, peername, peername_len, 0);
+ ZVAL_STRINGL(zpeername, peername, peername_len);
}
php_stream_to_zval(clistream, return_value);
} else {
@@ -306,7 +309,7 @@ PHP_FUNCTION(stream_socket_get_name)
RETURN_FALSE;
}
- php_stream_from_zval(stream, &zstream);
+ php_stream_from_zval(stream, zstream);
if (0 != php_stream_xport_get_name(stream, want_peer,
&name,
@@ -316,7 +319,8 @@ PHP_FUNCTION(stream_socket_get_name)
RETURN_FALSE;
}
- RETURN_STRINGL(name, name_len, 0);
+//??? RETURN_STRINGL(name, name_len, 0);
+ RETURN_STRINGL(name, name_len);
}
/* }}} */
@@ -335,7 +339,7 @@ PHP_FUNCTION(stream_socket_sendto)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|ls", &zstream, &data, &datalen, &flags, &target_addr, &target_addr_len) == FAILURE) {
RETURN_FALSE;
}
- php_stream_from_zval(stream, &zstream);
+ php_stream_from_zval(stream, zstream);
if (target_addr_len) {
/* parse the address */
@@ -358,7 +362,7 @@ PHP_FUNCTION(stream_socket_recvfrom)
char *remote_addr = NULL;
int remote_addr_len;
long to_read = 0;
- char *read_buf;
+ zend_string *read_buf;
long flags = 0;
int recvd;
@@ -366,7 +370,7 @@ PHP_FUNCTION(stream_socket_recvfrom)
RETURN_FALSE;
}
- php_stream_from_zval(stream, &zstream);
+ php_stream_from_zval(stream, zstream);
if (zremote) {
zval_dtor(zremote);
@@ -378,23 +382,24 @@ PHP_FUNCTION(stream_socket_recvfrom)
RETURN_FALSE;
}
- read_buf = safe_emalloc(1, to_read, 1);
+ read_buf = STR_ALLOC(to_read, 0);
- recvd = php_stream_xport_recvfrom(stream, read_buf, to_read, flags, NULL, NULL,
+ recvd = php_stream_xport_recvfrom(stream, read_buf->val, to_read, flags, NULL, NULL,
zremote ? &remote_addr : NULL,
zremote ? &remote_addr_len : NULL
TSRMLS_CC);
if (recvd >= 0) {
if (zremote) {
- ZVAL_STRINGL(zremote, remote_addr, remote_addr_len, 0);
+//??? ZVAL_STRINGL(zremote, remote_addr, remote_addr_len, 0);
+ ZVAL_STRINGL(zremote, remote_addr, remote_addr_len);
}
- read_buf[recvd] = '\0';
-
- RETURN_STRINGL(read_buf, recvd, 0);
+ read_buf->val[recvd] = '\0';
+ read_buf->len = recvd;
+ RETURN_STR(read_buf);
}
- efree(read_buf);
+ STR_FREE(read_buf);
RETURN_FALSE;
}
/* }}} */
@@ -414,7 +419,7 @@ PHP_FUNCTION(stream_get_contents)
RETURN_FALSE;
}
- php_stream_from_zval(stream, &zsrc);
+ php_stream_from_zval(stream, zsrc);
if (desiredpos >= 0) {
int seek_res = 0;
@@ -439,7 +444,8 @@ PHP_FUNCTION(stream_get_contents)
len = php_stream_copy_to_mem(stream, &contents, maxlen, 0);
if (contents) {
- RETVAL_STRINGL(contents, len, 0);
+//??? RETVAL_STRINGL(contents, len, 0);
+ RETVAL_STRINGL(contents, len);
} else {
RETVAL_EMPTY_STRING();
}
@@ -460,8 +466,8 @@ PHP_FUNCTION(stream_copy_to_stream)
RETURN_FALSE;
}
- php_stream_from_zval(src, &zsrc);
- php_stream_from_zval(dest, &zdest);
+ php_stream_from_zval(src, zsrc);
+ php_stream_from_zval(dest, zdest);
if (pos > 0 && php_stream_seek(src, pos, SEEK_SET) < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream", pos);
@@ -483,20 +489,16 @@ PHP_FUNCTION(stream_get_meta_data)
{
zval *arg1;
php_stream *stream;
- zval *newval;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) {
return;
}
- php_stream_from_zval(stream, &arg1);
+ php_stream_from_zval(stream, arg1);
array_init(return_value);
- if (stream->wrapperdata) {
- MAKE_STD_ZVAL(newval);
- MAKE_COPY_ZVAL(&stream->wrapperdata, newval);
-
- add_assoc_zval(return_value, "wrapper_data", newval);
+ if (Z_TYPE(stream->wrapperdata) != IS_NULL) {
+ add_assoc_zval(return_value, "wrapper_data", &stream->wrapperdata);
}
if (stream->wrapper) {
add_assoc_string(return_value, "wrapper_type", (char *)stream->wrapper->wops->label, 1);
@@ -541,8 +543,7 @@ PHP_FUNCTION(stream_get_meta_data)
PHP_FUNCTION(stream_get_transports)
{
HashTable *stream_xport_hash;
- char *stream_xport;
- uint stream_xport_len;
+ zend_string *stream_xport;
ulong num_key;
if (zend_parse_parameters_none() == FAILURE) {
@@ -554,9 +555,9 @@ PHP_FUNCTION(stream_get_transports)
array_init(return_value);
zend_hash_internal_pointer_reset_ex(stream_xport_hash, &pos);
while (zend_hash_get_current_key_ex(stream_xport_hash,
- &stream_xport, &stream_xport_len,
- &num_key, 0, &pos) == HASH_KEY_IS_STRING) {
- add_next_index_stringl(return_value, stream_xport, stream_xport_len - 1, 1);
+ &stream_xport, &num_key, 0, &pos) == HASH_KEY_IS_STRING) {
+//???
+ add_next_index_stringl(return_value, stream_xport->val, stream_xport->len, 1);
zend_hash_move_forward_ex(stream_xport_hash, &pos);
}
} else {
@@ -570,9 +571,8 @@ PHP_FUNCTION(stream_get_transports)
PHP_FUNCTION(stream_get_wrappers)
{
HashTable *url_stream_wrappers_hash;
- char *stream_protocol;
+ zend_string *stream_protocol;
int key_flags;
- uint stream_protocol_len = 0;
ulong num_key;
if (zend_parse_parameters_none() == FAILURE) {
@@ -583,10 +583,11 @@ PHP_FUNCTION(stream_get_wrappers)
HashPosition pos;
array_init(return_value);
for (zend_hash_internal_pointer_reset_ex(url_stream_wrappers_hash, &pos);
- (key_flags = zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, &stream_protocol_len, &num_key, 0, &pos)) != HASH_KEY_NON_EXISTENT;
+ (key_flags = zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, &num_key, 0, &pos)) != HASH_KEY_NON_EXISTENT;
zend_hash_move_forward_ex(url_stream_wrappers_hash, &pos)) {
if (key_flags == HASH_KEY_IS_STRING) {
- add_next_index_stringl(return_value, stream_protocol, stream_protocol_len - 1, 1);
+//???
+ add_next_index_stringl(return_value, stream_protocol->val, stream_protocol->len, 1);
}
}
} else {
@@ -599,7 +600,7 @@ PHP_FUNCTION(stream_get_wrappers)
/* {{{ stream_select related functions */
static int stream_array_to_fd_set(zval *stream_array, fd_set *fds, php_socket_t *max_fd TSRMLS_DC)
{
- zval **elem;
+ zval *elem;
php_stream *stream;
int cnt = 0;
@@ -607,7 +608,7 @@ static int stream_array_to_fd_set(zval *stream_array, fd_set *fds, php_socket_t
return 0;
}
for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(stream_array));
- zend_hash_get_current_data(Z_ARRVAL_P(stream_array), (void **) &elem) == SUCCESS;
+ (elem = zend_hash_get_current_data(Z_ARRVAL_P(stream_array))) != NULL;
zend_hash_move_forward(Z_ARRVAL_P(stream_array))) {
/* Temporary int fd is needed for the STREAM data type on windows, passing this_fd directly to php_stream_cast()
@@ -641,24 +642,22 @@ static int stream_array_to_fd_set(zval *stream_array, fd_set *fds, php_socket_t
static int stream_array_from_fd_set(zval *stream_array, fd_set *fds TSRMLS_DC)
{
- zval **elem, **dest_elem;
+ zval *elem, *dest_elem, new_array;
php_stream *stream;
- HashTable *new_hash;
int ret = 0;
if (Z_TYPE_P(stream_array) != IS_ARRAY) {
return 0;
}
- ALLOC_HASHTABLE(new_hash);
- zend_hash_init(new_hash, zend_hash_num_elements(Z_ARRVAL_P(stream_array)), NULL, ZVAL_PTR_DTOR, 0);
+ ZVAL_NEW_ARR(&new_array);
+ zend_hash_init(Z_ARRVAL(new_array), zend_hash_num_elements(Z_ARRVAL_P(stream_array)), NULL, ZVAL_PTR_DTOR, 0);
for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(stream_array));
zend_hash_has_more_elements(Z_ARRVAL_P(stream_array)) == SUCCESS;
zend_hash_move_forward(Z_ARRVAL_P(stream_array))) {
int type;
- char *key;
- uint key_len;
+ zend_string *key;
ulong num_ind;
/* Temporary int fd is needed for the STREAM data type on windows, passing this_fd directly to php_stream_cast()
would eventually bring a wrong result on x64. php_stream_cast() casts to int internally, and this will leave
@@ -667,9 +666,9 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds TSRMLS_DC)
type = zend_hash_get_current_key_ex(Z_ARRVAL_P(stream_array),
- &key, &key_len, &num_ind, 0, NULL);
+ &key, &num_ind, 0, NULL);
if (type == HASH_KEY_NON_EXISTENT ||
- zend_hash_get_current_data(Z_ARRVAL_P(stream_array), (void **) &elem) == FAILURE) {
+ (elem = zend_hash_get_current_data(Z_ARRVAL_P(stream_array))) == NULL) {
continue; /* should not happen */
}
@@ -688,9 +687,9 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds TSRMLS_DC)
if (PHP_SAFE_FD_ISSET(this_fd, fds)) {
if (type == HASH_KEY_IS_LONG) {
- zend_hash_index_update(new_hash, num_ind, (void *)elem, sizeof(zval *), (void **)&dest_elem);
+ dest_elem = zend_hash_index_update(Z_ARRVAL(new_array), num_ind, elem);
} else { /* HASH_KEY_IS_STRING */
- zend_hash_update(new_hash, key, key_len, (void *)elem, sizeof(zval *), (void **)&dest_elem);
+ dest_elem = zend_hash_update(Z_ARRVAL(new_array), key, elem);
}
if (dest_elem) {
@@ -704,29 +703,28 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds TSRMLS_DC)
/* destroy old array and add new one */
zend_hash_destroy(Z_ARRVAL_P(stream_array));
- efree(Z_ARRVAL_P(stream_array));
+ efree(Z_ARR_P(stream_array));
- zend_hash_internal_pointer_reset(new_hash);
- Z_ARRVAL_P(stream_array) = new_hash;
+ zend_hash_internal_pointer_reset(Z_ARRVAL(new_array));
+ Z_ARR_P(stream_array) = Z_ARR(new_array);
return ret;
}
static int stream_array_emulate_read_fd_set(zval *stream_array TSRMLS_DC)
{
- zval **elem, **dest_elem;
+ zval *elem, *dest_elem, new_array;
php_stream *stream;
- HashTable *new_hash;
int ret = 0;
if (Z_TYPE_P(stream_array) != IS_ARRAY) {
return 0;
}
- ALLOC_HASHTABLE(new_hash);
- zend_hash_init(new_hash, zend_hash_num_elements(Z_ARRVAL_P(stream_array)), NULL, ZVAL_PTR_DTOR, 0);
+ ZVAL_NEW_ARR(&new_array);
+ zend_hash_init(Z_ARRVAL(new_array), zend_hash_num_elements(Z_ARRVAL_P(stream_array)), NULL, ZVAL_PTR_DTOR, 0);
for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(stream_array));
- zend_hash_get_current_data(Z_ARRVAL_P(stream_array), (void **) &elem) == SUCCESS;
+ (elem = zend_hash_get_current_data(Z_ARRVAL_P(stream_array))) != NULL;
zend_hash_move_forward(Z_ARRVAL_P(stream_array))) {
php_stream_from_zval_no_verify(stream, elem);
@@ -740,7 +738,7 @@ static int stream_array_emulate_read_fd_set(zval *stream_array TSRMLS_DC)
* This branch of code also allows blocking streams with buffered data to
* operate correctly in stream_select.
* */
- zend_hash_next_index_insert(new_hash, (void *)elem, sizeof(zval *), (void **)&dest_elem);
+ dest_elem = zend_hash_next_index_insert(Z_ARRVAL(new_array), elem);
if (dest_elem) {
zval_add_ref(dest_elem);
}
@@ -752,13 +750,13 @@ static int stream_array_emulate_read_fd_set(zval *stream_array TSRMLS_DC)
if (ret > 0) {
/* destroy old array and add new one */
zend_hash_destroy(Z_ARRVAL_P(stream_array));
- efree(Z_ARRVAL_P(stream_array));
+ efree(Z_ARR_P(stream_array));
- zend_hash_internal_pointer_reset(new_hash);
- Z_ARRVAL_P(stream_array) = new_hash;
+ zend_hash_internal_pointer_reset(Z_ARRVAL(new_array));
+ Z_ARR_P(stream_array) = Z_ARR(new_array);
} else {
- zend_hash_destroy(new_hash);
- FREE_HASHTABLE(new_hash);
+ zend_hash_destroy(Z_ARRVAL(new_array));
+ efree(Z_ARR(new_array));
}
return ret;
@@ -769,7 +767,7 @@ static int stream_array_emulate_read_fd_set(zval *stream_array TSRMLS_DC)
Runs the select() system call on the sets of streams with a timeout specified by tv_sec and tv_usec */
PHP_FUNCTION(stream_select)
{
- zval *r_array, *w_array, *e_array, **sec = NULL;
+ zval *r_array, *w_array, *e_array, *sec = NULL;
struct timeval tv;
struct timeval *tv_p = NULL;
fd_set rfds, wfds, efds;
@@ -778,7 +776,7 @@ PHP_FUNCTION(stream_select)
long usec = 0;
int set_count, max_set_count = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a!a!a!Z!|l", &r_array, &w_array, &e_array, &sec, &usec) == FAILURE)
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a!a!a!z!|l", &r_array, &w_array, &e_array, &sec, &usec) == FAILURE)
return;
FD_ZERO(&rfds);
@@ -817,7 +815,7 @@ PHP_FUNCTION(stream_select)
if (sec != NULL) {
convert_to_long_ex(sec);
- if (Z_LVAL_PP(sec) < 0) {
+ if (Z_LVAL_P(sec) < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The seconds parameter must be greater than 0");
RETURN_FALSE;
} else if (usec < 0) {
@@ -827,10 +825,10 @@ PHP_FUNCTION(stream_select)
/* Solaris + BSD do not like microsecond values which are >= 1 sec */
if (usec > 999999) {
- tv.tv_sec = Z_LVAL_PP(sec) + (usec / 1000000);
+ tv.tv_sec = Z_LVAL_P(sec) + (usec / 1000000);
tv.tv_usec = usec % 1000000;
} else {
- tv.tv_sec = Z_LVAL_PP(sec);
+ tv.tv_sec = Z_LVAL_P(sec);
tv.tv_usec = usec;
}
@@ -875,45 +873,34 @@ static void user_space_stream_notifier(php_stream_context *context, int notifyco
char *xmsg, int xcode, size_t bytes_sofar, size_t bytes_max, void * ptr TSRMLS_DC)
{
zval *callback = (zval*)context->notifier->ptr;
- zval *retval = NULL;
+ zval retval;
zval zvs[6];
- zval *ps[6];
- zval **ptps[6];
int i;
- for (i = 0; i < 6; i++) {
- INIT_ZVAL(zvs[i]);
- ps[i] = &zvs[i];
- ptps[i] = &ps[i];
- MAKE_STD_ZVAL(ps[i]);
- }
-
- ZVAL_LONG(ps[0], notifycode);
- ZVAL_LONG(ps[1], severity);
+ ZVAL_LONG(&zvs[0], notifycode);
+ ZVAL_LONG(&zvs[1], severity);
if (xmsg) {
- ZVAL_STRING(ps[2], xmsg, 1);
+ ZVAL_STRING(&zvs[2], xmsg);
} else {
- ZVAL_NULL(ps[2]);
+ ZVAL_NULL(&zvs[2]);
}
- ZVAL_LONG(ps[3], xcode);
- ZVAL_LONG(ps[4], bytes_sofar);
- ZVAL_LONG(ps[5], bytes_max);
+ ZVAL_LONG(&zvs[3], xcode);
+ ZVAL_LONG(&zvs[4], bytes_sofar);
+ ZVAL_LONG(&zvs[5], bytes_max);
- if (FAILURE == call_user_function_ex(EG(function_table), NULL, callback, &retval, 6, ptps, 0, NULL TSRMLS_CC)) {
+ if (FAILURE == call_user_function_ex(EG(function_table), NULL, callback, &retval, 6, zvs, 0, NULL TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to call user notifier");
}
for (i = 0; i < 6; i++) {
- zval_ptr_dtor(&ps[i]);
- }
- if (retval) {
- zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&zvs[i]);
}
+ zval_ptr_dtor(&retval);
}
static void user_space_stream_notifier_dtor(php_stream_notifier *notifier)
{
if (notifier && notifier->ptr) {
- zval_ptr_dtor((zval **)&(notifier->ptr));
+ zval_ptr_dtor((zval*)(notifier->ptr));
notifier->ptr = NULL;
}
}
@@ -921,24 +908,23 @@ static void user_space_stream_notifier_dtor(php_stream_notifier *notifier)
static int parse_context_options(php_stream_context *context, zval *options TSRMLS_DC)
{
HashPosition pos, opos;
- zval **wval, **oval;
- char *wkey, *okey;
- uint wkey_len, okey_len;
+ zval *wval, *oval;
+ zend_string *wkey, *okey;
int ret = SUCCESS;
ulong num_key;
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(options), &pos);
- while (SUCCESS == zend_hash_get_current_data_ex(Z_ARRVAL_P(options), (void**)&wval, &pos)) {
- if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(Z_ARRVAL_P(options), &wkey, &wkey_len, &num_key, 0, &pos)
- && Z_TYPE_PP(wval) == IS_ARRAY) {
+ while (NULL != (wval = zend_hash_get_current_data_ex(Z_ARRVAL_P(options), &pos))) {
+ if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(Z_ARRVAL_P(options), &wkey, &num_key, 0, &pos)
+ && Z_TYPE_P(wval) == IS_ARRAY) {
- zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(wval), &opos);
- while (SUCCESS == zend_hash_get_current_data_ex(Z_ARRVAL_PP(wval), (void**)&oval, &opos)) {
+ zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(wval), &opos);
+ while (NULL != (oval = zend_hash_get_current_data_ex(Z_ARRVAL_P(wval), &opos))) {
- if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(Z_ARRVAL_PP(wval), &okey, &okey_len, &num_key, 0, &opos)) {
- php_stream_context_set_option(context, wkey, okey, *oval);
+ if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(Z_ARRVAL_P(wval), &okey, &num_key, 0, &opos)) {
+ php_stream_context_set_option(context, wkey->val, okey->val, oval);
}
- zend_hash_move_forward_ex(Z_ARRVAL_PP(wval), &opos);
+ zend_hash_move_forward_ex(Z_ARRVAL_P(wval), &opos);
}
} else {
@@ -953,9 +939,9 @@ static int parse_context_options(php_stream_context *context, zval *options TSRM
static int parse_context_params(php_stream_context *context, zval *params TSRMLS_DC)
{
int ret = SUCCESS;
- zval **tmp;
+ zval *tmp;
- if (SUCCESS == zend_hash_find(Z_ARRVAL_P(params), "notification", sizeof("notification"), (void**)&tmp)) {
+ if (NULL != (tmp = zend_hash_str_find(Z_ARRVAL_P(params), "notification", sizeof("notification")-1))) {
if (context->notifier) {
php_stream_notification_free(context->notifier);
@@ -964,13 +950,13 @@ static int parse_context_params(php_stream_context *context, zval *params TSRMLS
context->notifier = php_stream_notification_alloc();
context->notifier->func = user_space_stream_notifier;
- context->notifier->ptr = *tmp;
- Z_ADDREF_P(*tmp);
+ context->notifier->ptr = tmp;
+ Z_ADDREF_P(tmp);
context->notifier->dtor = user_space_stream_notifier_dtor;
}
- if (SUCCESS == zend_hash_find(Z_ARRVAL_P(params), "options", sizeof("options"), (void**)&tmp)) {
- if (Z_TYPE_PP(tmp) == IS_ARRAY) {
- parse_context_options(context, *tmp TSRMLS_CC);
+ if (NULL != (tmp = zend_hash_str_find(Z_ARRVAL_P(params), "options", sizeof("options")-1))) {
+ if (Z_TYPE_P(tmp) == IS_ARRAY) {
+ parse_context_options(context, tmp TSRMLS_CC);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid stream/context parameter");
}
@@ -986,11 +972,11 @@ static php_stream_context *decode_context_param(zval *contextresource TSRMLS_DC)
{
php_stream_context *context = NULL;
- context = zend_fetch_resource(&contextresource TSRMLS_CC, -1, NULL, NULL, 1, php_le_stream_context(TSRMLS_C));
+ context = zend_fetch_resource(contextresource TSRMLS_CC, -1, NULL, NULL, 1, php_le_stream_context(TSRMLS_C));
if (context == NULL) {
php_stream *stream;
- stream = zend_fetch_resource(&contextresource TSRMLS_CC, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream);
+ stream = zend_fetch_resource(contextresource TSRMLS_CC, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream);
if (stream) {
context = stream->context;
@@ -1024,7 +1010,7 @@ PHP_FUNCTION(stream_context_get_options)
RETURN_FALSE;
}
- RETURN_ZVAL(context->options, 1, 0);
+ RETURN_ZVAL(&context->options, 1, 0);
}
/* }}} */
@@ -1089,7 +1075,7 @@ PHP_FUNCTION(stream_context_set_params)
Get parameters of a file context */
PHP_FUNCTION(stream_context_get_params)
{
- zval *zcontext, *options;
+ zval *zcontext, options;
php_stream_context *context;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zcontext) == FAILURE) {
@@ -1107,9 +1093,8 @@ PHP_FUNCTION(stream_context_get_params)
add_assoc_zval_ex(return_value, ZEND_STRS("notification"), context->notifier->ptr);
Z_ADDREF_P(context->notifier->ptr);
}
- ALLOC_INIT_ZVAL(options);
- ZVAL_ZVAL(options, context->options, 1, 0);
- add_assoc_zval_ex(return_value, ZEND_STRS("options"), options);
+ ZVAL_ZVAL(&options, &context->options, 1, 0);
+ add_assoc_zval_ex(return_value, ZEND_STRS("options"), &options);
}
/* }}} */
@@ -1180,7 +1165,7 @@ PHP_FUNCTION(stream_context_create)
parse_context_params(context, params TSRMLS_CC);
}
- RETURN_RESOURCE(context->rsrc_id);
+ RETURN_RES(context->res);
}
/* }}} */
@@ -1201,7 +1186,7 @@ static void apply_filter_to_stream(int append, INTERNAL_FUNCTION_PARAMETERS)
RETURN_FALSE;
}
- php_stream_from_zval(stream, &zstream);
+ php_stream_from_zval(stream, zstream);
if ((read_write & PHP_STREAM_FILTER_ALL) == 0) {
/* Chain not specified.
@@ -1252,7 +1237,8 @@ static void apply_filter_to_stream(int append, INTERNAL_FUNCTION_PARAMETERS)
}
if (filter) {
- RETURN_RESOURCE(filter->rsrc_id = ZEND_REGISTER_RESOURCE(NULL, filter, php_file_le_stream_filter()));
+ filter->res = ZEND_REGISTER_RESOURCE(NULL, filter, php_file_le_stream_filter());
+ RETURN_RES(filter->res);
} else {
RETURN_FALSE;
}
@@ -1286,7 +1272,7 @@ PHP_FUNCTION(stream_filter_remove)
RETURN_FALSE;
}
- filter = zend_fetch_resource(&zfilter TSRMLS_CC, -1, NULL, NULL, 1, php_file_le_stream_filter());
+ filter = zend_fetch_resource(zfilter TSRMLS_CC, -1, NULL, NULL, 1, php_file_le_stream_filter());
if (!filter) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid resource given, not a stream filter");
RETURN_FALSE;
@@ -1297,7 +1283,7 @@ PHP_FUNCTION(stream_filter_remove)
RETURN_FALSE;
}
- if (zend_list_delete(Z_LVAL_P(zfilter)) == FAILURE) {
+ if (zend_list_delete(Z_RES_P(zfilter)) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not invalidate filter, not removing");
RETURN_FALSE;
} else {
@@ -1331,10 +1317,11 @@ PHP_FUNCTION(stream_get_line)
max_length = PHP_SOCK_CHUNK_SIZE;
}
- php_stream_from_zval(stream, &zstream);
+ php_stream_from_zval(stream, zstream);
if ((buf = php_stream_get_record(stream, max_length, &buf_size, str, str_len TSRMLS_CC))) {
- RETURN_STRINGL(buf, buf_size, 0);
+//??? RETURN_STRINGL(buf, buf_size, 0);
+ RETURN_STRINGL(buf, buf_size);
} else {
RETURN_FALSE;
}
@@ -1355,7 +1342,7 @@ PHP_FUNCTION(stream_set_blocking)
return;
}
- php_stream_from_zval(stream, &arg1);
+ php_stream_from_zval(stream, arg1);
block = arg2;
@@ -1383,7 +1370,7 @@ PHP_FUNCTION(stream_set_timeout)
return;
}
- php_stream_from_zval(stream, &socket);
+ php_stream_from_zval(stream, socket);
t.tv_sec = seconds;
@@ -1417,7 +1404,7 @@ PHP_FUNCTION(stream_set_write_buffer)
RETURN_FALSE;
}
- php_stream_from_zval(stream, &arg1);
+ php_stream_from_zval(stream, arg1);
buff = arg2;
@@ -1458,7 +1445,7 @@ PHP_FUNCTION(stream_set_chunk_size)
RETURN_FALSE;
}
- php_stream_from_zval(stream, &zstream);
+ php_stream_from_zval(stream, zstream);
ret = php_stream_set_option(stream, PHP_STREAM_OPTION_SET_CHUNK_SIZE, (int)csize, NULL);
@@ -1480,7 +1467,7 @@ PHP_FUNCTION(stream_set_read_buffer)
RETURN_FALSE;
}
- php_stream_from_zval(stream, &arg1);
+ php_stream_from_zval(stream, arg1);
buff = arg2;
@@ -1509,11 +1496,11 @@ PHP_FUNCTION(stream_socket_enable_crypto)
RETURN_FALSE;
}
- php_stream_from_zval(stream, &zstream);
+ php_stream_from_zval(stream, zstream);
if (ZEND_NUM_ARGS() >= 3) {
if (zsessstream) {
- php_stream_from_zval(sessstream, &zsessstream);
+ php_stream_from_zval(sessstream, zsessstream);
}
if (php_stream_xport_crypto_setup(stream, cryptokind, sessstream TSRMLS_CC) < 0) {
@@ -1552,7 +1539,8 @@ PHP_FUNCTION(stream_resolve_include_path)
resolved_path = zend_resolve_path(filename, filename_len TSRMLS_CC);
if (resolved_path) {
- RETURN_STRING(resolved_path, 0);
+//??? RETURN_STRING(resolved_path, 0);
+ RETURN_STRING(resolved_path);
}
RETURN_FALSE;
}
@@ -1562,15 +1550,15 @@ PHP_FUNCTION(stream_resolve_include_path)
*/
PHP_FUNCTION(stream_is_local)
{
- zval **zstream;
+ zval *zstream;
php_stream *stream = NULL;
php_stream_wrapper *wrapper = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &zstream) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zstream) == FAILURE) {
RETURN_FALSE;
}
- if (Z_TYPE_PP(zstream) == IS_RESOURCE) {
+ if (Z_TYPE_P(zstream) == IS_RESOURCE) {
php_stream_from_zval(stream, zstream);
if (stream == NULL) {
RETURN_FALSE;
@@ -1579,7 +1567,7 @@ PHP_FUNCTION(stream_is_local)
} else {
convert_to_string_ex(zstream);
- wrapper = php_stream_locate_url_wrapper(Z_STRVAL_PP(zstream), NULL, 0 TSRMLS_CC);
+ wrapper = php_stream_locate_url_wrapper(Z_STRVAL_P(zstream), NULL, 0 TSRMLS_CC);
}
if (!wrapper) {
@@ -1601,7 +1589,7 @@ PHP_FUNCTION(stream_supports_lock)
RETURN_FALSE;
}
- php_stream_from_zval(stream, &zsrc);
+ php_stream_from_zval(stream, zsrc);
if (!php_stream_supports_lock(stream)) {
RETURN_FALSE;
@@ -1633,7 +1621,7 @@ PHP_FUNCTION(stream_socket_shutdown)
RETURN_FALSE;
}
- php_stream_from_zval(stream, &zstream);
+ php_stream_from_zval(stream, zstream);
RETURN_BOOL(php_stream_xport_shutdown(stream, (stream_shutdown_t)how TSRMLS_CC) == 0);
}