struct _php_userstream_data {
struct php_user_stream_wrapper * wrapper;
- zval * object;
+ zval object;
};
typedef struct _php_userstream_data php_userstream_data_t;
}}} **/
-static zval *user_stream_create_object(struct php_user_stream_wrapper *uwrap, php_stream_context *context, zval *object TSRMLS_DC)
+static void user_stream_create_object(struct php_user_stream_wrapper *uwrap, php_stream_context *context, zval *object TSRMLS_DC)
{
/* create an instance of our class */
object_init_ex(object, uwrap->ce);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not execute %s::%s()", uwrap->ce->name->val, uwrap->ce->constructor->common.function_name->val);
zval_dtor(object);
ZVAL_UNDEF(object);
- return NULL;
} else {
zval_ptr_dtor(&retval);
}
}
- return object;
}
static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, const char *filename, const char *mode,
int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC)
{
- zval object;
struct php_user_stream_wrapper *uwrap = (struct php_user_stream_wrapper*)wrapper->abstract;
php_userstream_data_t *us;
zval zretval, zfuncname;
us = emalloc(sizeof(*us));
us->wrapper = uwrap;
- us->object = user_stream_create_object(uwrap, context, &object TSRMLS_CC);
- if(us->object == NULL) {
+ user_stream_create_object(uwrap, context, &us->object TSRMLS_CC);
+ if (Z_TYPE(us->object) == IS_UNDEF) {
FG(user_stream_current_filename) = NULL;
PG(in_user_include) = old_in_user_include;
efree(us);
ZVAL_STRING(&zfuncname, USERSTREAM_OPEN);
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&zfuncname,
&zretval,
4, args,
}
/* set wrapper data to be a reference to our object */
- ZVAL_COPY(&stream->wrapperdata, us->object);
+ ZVAL_COPY(&stream->wrapperdata, &us->object);
} else {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "\"%s::" USERSTREAM_OPEN "\" call failed",
us->wrapper->classname);
/* destroy everything else */
if (stream == NULL) {
- zval_ptr_dtor(us->object);
+ zval_ptr_dtor(&us->object);
efree(us);
}
zval_ptr_dtor(&zretval);
zval_ptr_dtor(&zfuncname);
- zval_ptr_dtor(&args[4]);
zval_ptr_dtor(&args[3]);
zval_ptr_dtor(&args[2]);
zval_ptr_dtor(&args[1]);
+ zval_ptr_dtor(&args[0]);
FG(user_stream_current_filename) = NULL;
static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, const char *filename, const char *mode,
int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC)
{
- zval object;
struct php_user_stream_wrapper *uwrap = (struct php_user_stream_wrapper*)wrapper->abstract;
php_userstream_data_t *us;
zval zretval, zfuncname;
us = emalloc(sizeof(*us));
us->wrapper = uwrap;
- us->object = user_stream_create_object(uwrap, context, &object TSRMLS_CC);
- if(us->object == NULL) {
+ user_stream_create_object(uwrap, context, &us->object TSRMLS_CC);
+ if (Z_TYPE(us->object) == IS_UNDEF) {
FG(user_stream_current_filename) = NULL;
efree(us);
return NULL;
ZVAL_STRING(&zfuncname, USERSTREAM_DIR_OPEN);
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&zfuncname,
&zretval,
2, args,
stream = php_stream_alloc_rel(&php_stream_userspace_dir_ops, us, 0, mode);
/* set wrapper data to be a reference to our object */
- ZVAL_COPY(&stream->wrapperdata, us->object);
+ ZVAL_COPY(&stream->wrapperdata, &us->object);
} else {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "\"%s::" USERSTREAM_DIR_OPEN "\" call failed",
us->wrapper->classname);
/* destroy everything else */
if (stream == NULL) {
- zval_ptr_dtor(us->object);
+ zval_ptr_dtor(&us->object);
efree(us);
}
zval_ptr_dtor(&zretval);
assert(us != NULL);
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_WRITE, sizeof(USERSTREAM_WRITE)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_WRITE, sizeof(USERSTREAM_WRITE)-1);
ZVAL_STRINGL(&args[0], (char*)buf, count);
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
1, args,
0, NULL TSRMLS_CC);
zval_ptr_dtor(&args[0]);
+ zval_ptr_dtor(&func_name);
didwrite = 0;
if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
assert(us != NULL);
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_READ, sizeof(USERSTREAM_READ)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_READ, sizeof(USERSTREAM_READ)-1);
ZVAL_LONG(&args[0], count);
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
1, args,
zval_ptr_dtor(&retval);
ZVAL_UNDEF(&retval);
+ zval_ptr_dtor(&func_name);
/* since the user stream has no way of setting the eof flag directly, we need to ask it if we hit eof */
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_EOF, sizeof(USERSTREAM_EOF)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_EOF, sizeof(USERSTREAM_EOF)-1);
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
0, NULL, 0, NULL TSRMLS_CC);
}
zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&func_name);
return didread;
}
assert(us != NULL);
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_CLOSE, sizeof(USERSTREAM_CLOSE)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_CLOSE, sizeof(USERSTREAM_CLOSE)-1);
call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
0, NULL, 0, NULL TSRMLS_CC);
zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&func_name);
- zval_ptr_dtor(us->object);
+ zval_ptr_dtor(&us->object);
efree(us);
assert(us != NULL);
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_FLUSH, sizeof(USERSTREAM_FLUSH)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_FLUSH, sizeof(USERSTREAM_FLUSH)-1);
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
0, NULL, 0, NULL TSRMLS_CC);
call_result = -1;
zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&func_name);
return call_result;
}
assert(us != NULL);
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_SEEK, sizeof(USERSTREAM_SEEK)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_SEEK, sizeof(USERSTREAM_SEEK)-1);
ZVAL_LONG(&args[0], offset);
ZVAL_LONG(&args[1], whence);
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
2, args,
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&args[1]);
+ zval_ptr_dtor(&func_name);
if (call_result == FAILURE) {
/* stream_seek is not implemented, so disable seeks for this stream */
}
/* now determine where we are */
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_TELL, sizeof(USERSTREAM_TELL)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_TELL, sizeof(USERSTREAM_TELL)-1);
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
0, NULL, 0, NULL TSRMLS_CC);
}
zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&func_name);
return ret;
}
php_userstream_data_t *us = (php_userstream_data_t *)stream->abstract;
int ret = -1;
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_STAT, sizeof(USERSTREAM_STAT)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_STAT, sizeof(USERSTREAM_STAT)-1);
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
0, NULL, 0, NULL TSRMLS_CC);
}
zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&func_name);
return ret;
}
switch (option) {
case PHP_STREAM_OPTION_CHECK_LIVENESS:
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_EOF, sizeof(USERSTREAM_EOF)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_EOF, sizeof(USERSTREAM_EOF)-1);
- call_result = call_user_function_ex(NULL, us->object, &func_name, &retval, 0, NULL, 0, NULL TSRMLS_CC);
+ call_result = call_user_function_ex(NULL, &us->object, &func_name, &retval, 0, NULL, 0, NULL TSRMLS_CC);
if (call_result == SUCCESS && Z_TYPE(retval) == IS_BOOL) {
ret = zval_is_true(&retval) ? PHP_STREAM_OPTION_RETURN_ERR : PHP_STREAM_OPTION_RETURN_OK;
} else {
"%s::" USERSTREAM_EOF " is not implemented! Assuming EOF",
us->wrapper->classname);
}
+ zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&func_name);
break;
case PHP_STREAM_OPTION_LOCKING:
}
/* TODO wouldblock */
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_LOCK, sizeof(USERSTREAM_LOCK)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_LOCK, sizeof(USERSTREAM_LOCK)-1);
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
1, args, 0, NULL TSRMLS_CC);
}
}
+ zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&func_name);
+ zval_ptr_dtor(&args[0]);
break;
case PHP_STREAM_OPTION_TRUNCATE_API:
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_TRUNCATE, sizeof(USERSTREAM_TRUNCATE)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_TRUNCATE, sizeof(USERSTREAM_TRUNCATE)-1);
switch (value) {
case PHP_STREAM_TRUNCATE_SUPPORTED:
- if (zend_is_callable_ex(&func_name, us->object, IS_CALLABLE_CHECK_SILENT,
+ if (zend_is_callable_ex(&func_name, &us->object, IS_CALLABLE_CHECK_SILENT,
NULL, NULL, NULL TSRMLS_CC))
ret = PHP_STREAM_OPTION_RETURN_OK;
else
if (new_size >= 0 && new_size <= (ptrdiff_t)LONG_MAX) {
ZVAL_LONG(&args[0], (long)new_size);
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
1, args, 0, NULL TSRMLS_CC);
"%s::" USERSTREAM_TRUNCATE " is not implemented!",
us->wrapper->classname);
}
+ zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&args[0]);
} else { /* bad new size */
ret = PHP_STREAM_OPTION_RETURN_ERR;
}
break;
}
}
+ zval_ptr_dtor(&func_name);
break;
case PHP_STREAM_OPTION_READ_BUFFER:
case PHP_STREAM_OPTION_READ_TIMEOUT:
case PHP_STREAM_OPTION_BLOCKING: {
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_SET_OPTION, sizeof(USERSTREAM_SET_OPTION)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_SET_OPTION, sizeof(USERSTREAM_SET_OPTION)-1);
ZVAL_LONG(&args[0], option);
}
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
3, args, 0, NULL TSRMLS_CC);
ret = PHP_STREAM_OPTION_RETURN_ERR;
}
+ zval_ptr_dtor(&retval);
zval_ptr_dtor(&args[2]);
zval_ptr_dtor(&args[1]);
+ zval_ptr_dtor(&args[0]);
+ zval_ptr_dtor(&func_name);
break;
}
}
- /* clean up */
- zval_ptr_dtor(&retval);
- zval_ptr_dtor(&args[0]);
-
return ret;
}
zval zfuncname, zretval;
zval args[1];
int call_result;
- zval *object, tmp_object;
+ zval object;
int ret = 0;
/* create an instance of our class */
- object = user_stream_create_object(uwrap, context, &tmp_object TSRMLS_CC);
- if(object == NULL) {
+ user_stream_create_object(uwrap, context, &object TSRMLS_CC);
+ if (Z_TYPE(object) == IS_UNDEF) {
return ret;
}
ZVAL_STRING(&zfuncname, USERSTREAM_UNLINK);
call_result = call_user_function_ex(NULL,
- object,
+ &object,
&zfuncname,
&zretval,
1, args,
}
/* clean up */
- zval_ptr_dtor(object);
+ zval_ptr_dtor(&object);
zval_ptr_dtor(&zretval);
zval_ptr_dtor(&args[1]);
zval zfuncname, zretval;
zval args[2];
int call_result;
- zval *object, tmp_object;
+ zval object;
int ret = 0;
/* create an instance of our class */
- object = user_stream_create_object(uwrap, context, &tmp_object TSRMLS_CC);
- if(object == NULL) {
+ user_stream_create_object(uwrap, context, &object TSRMLS_CC);
+ if (Z_TYPE(object) == IS_UNDEF) {
return ret;
}
ZVAL_STRING(&zfuncname, USERSTREAM_RENAME);
call_result = call_user_function_ex(NULL,
- object,
+ &object,
&zfuncname,
&zretval,
2, args,
}
/* clean up */
- zval_ptr_dtor(object);
+ zval_ptr_dtor(&object);
zval_ptr_dtor(&zretval);
zval_ptr_dtor(&zfuncname);
zval zfuncname, zretval;
zval args[3];
int call_result;
- zval *object, tmp_object;
+ zval object;
int ret = 0;
/* create an instance of our class */
- object = user_stream_create_object(uwrap, context, &tmp_object TSRMLS_CC);
- if(object == NULL) {
+ user_stream_create_object(uwrap, context, &object TSRMLS_CC);
+ if (Z_TYPE(object) == IS_UNDEF) {
return ret;
}
ZVAL_STRING(&zfuncname, USERSTREAM_MKDIR);
call_result = call_user_function_ex(NULL,
- object,
+ &object,
&zfuncname,
&zretval,
3, args,
}
/* clean up */
- zval_ptr_dtor(object);
+ zval_ptr_dtor(&object);
zval_ptr_dtor(&zretval);
zval_ptr_dtor(&zfuncname);
zval zfuncname, zretval;
zval args[2];
int call_result;
- zval *object, tmp_object;
+ zval object;
int ret = 0;
/* create an instance of our class */
- object = user_stream_create_object(uwrap, context, &tmp_object TSRMLS_CC);
- if(object == NULL) {
+ user_stream_create_object(uwrap, context, &object TSRMLS_CC);
+ if (Z_TYPE(object) == IS_UNDEF) {
return ret;
}
ZVAL_STRING(&zfuncname, USERSTREAM_RMDIR);
call_result = call_user_function_ex(NULL,
- object,
+ &object,
&zfuncname,
&zretval,
2, args,
}
/* clean up */
- zval_ptr_dtor(object);
+ zval_ptr_dtor(&object);
zval_ptr_dtor(&zretval);
zval_ptr_dtor(&zfuncname);
zval zfuncname, zretval;
zval args[3];
int call_result;
- zval *object, tmp_object;
+ zval object;
int ret = 0;
switch(option) {
}
/* create an instance of our class */
- object = user_stream_create_object(uwrap, context, &tmp_object TSRMLS_CC);
- if (object == NULL) {
+ user_stream_create_object(uwrap, context, &object TSRMLS_CC);
+ if (Z_TYPE(object) == IS_UNDEF) {
zval_ptr_dtor(&args[2]);
return ret;
}
ZVAL_STRING(&zfuncname, USERSTREAM_METADATA);
call_result = call_user_function_ex(NULL,
- object,
+ &object,
&zfuncname,
&zretval,
3, args,
}
/* clean up */
- zval_ptr_dtor(object);
+ zval_ptr_dtor(&object);
zval_ptr_dtor(&zretval);
zval_ptr_dtor(&zfuncname);
zval zfuncname, zretval;
zval args[2];
int call_result;
- zval *object, tmp_object;
+ zval object;
int ret = -1;
/* create an instance of our class */
- object = user_stream_create_object(uwrap, context, &tmp_object TSRMLS_CC);
- if(object == NULL) {
+ user_stream_create_object(uwrap, context, &object TSRMLS_CC);
+ if (Z_TYPE(object) == IS_UNDEF) {
return ret;
}
ZVAL_STRING(&zfuncname, USERSTREAM_STATURL);
call_result = call_user_function_ex(NULL,
- object,
+ &object,
&zfuncname,
&zretval,
2, args,
}
/* clean up */
- zval_ptr_dtor(object);
+ zval_ptr_dtor(&object);
zval_ptr_dtor(&zretval);
zval_ptr_dtor(&zfuncname);
if (count != sizeof(php_stream_dirent))
return 0;
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_DIR_READ, sizeof(USERSTREAM_DIR_READ)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_DIR_READ, sizeof(USERSTREAM_DIR_READ)-1);
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
0, NULL,
}
zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&func_name);
return didread;
}
assert(us != NULL);
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_DIR_CLOSE, sizeof(USERSTREAM_DIR_CLOSE)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_DIR_CLOSE, sizeof(USERSTREAM_DIR_CLOSE)-1);
call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
0, NULL, 0, NULL TSRMLS_CC);
- zval_ptr_dtor(us->object);
+ zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&func_name);
+ zval_ptr_dtor(&us->object);
efree(us);
zval retval;
php_userstream_data_t *us = (php_userstream_data_t *)stream->abstract;
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_DIR_REWIND, sizeof(USERSTREAM_DIR_REWIND)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_DIR_REWIND, sizeof(USERSTREAM_DIR_REWIND)-1);
call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
0, NULL, 0, NULL TSRMLS_CC);
zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&func_name);
return 0;
int call_result;
int ret = FAILURE;
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_CAST, sizeof(USERSTREAM_CAST)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_CAST, sizeof(USERSTREAM_CAST)-1);
switch(castas) {
}
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
1, args, 0, NULL TSRMLS_CC);
} while (0);
zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&func_name);
zval_ptr_dtor(&args[0]);
return ret;