29# include <sys/utime.h>
36static int le_protocols;
60 user_wrapper_stat_url,
75 efree(uwrap->protoname);
86 register_userspace_symbols(module_number);
98#define USERSTREAM_OPEN "stream_open"
99#define USERSTREAM_CLOSE "stream_close"
100#define USERSTREAM_READ "stream_read"
101#define USERSTREAM_WRITE "stream_write"
102#define USERSTREAM_FLUSH "stream_flush"
103#define USERSTREAM_SEEK "stream_seek"
104#define USERSTREAM_TELL "stream_tell"
105#define USERSTREAM_EOF "stream_eof"
106#define USERSTREAM_STAT "stream_stat"
107#define USERSTREAM_STATURL "url_stat"
108#define USERSTREAM_UNLINK "unlink"
109#define USERSTREAM_RENAME "rename"
110#define USERSTREAM_MKDIR "mkdir"
111#define USERSTREAM_RMDIR "rmdir"
112#define USERSTREAM_DIR_OPEN "dir_opendir"
113#define USERSTREAM_DIR_READ "dir_readdir"
114#define USERSTREAM_DIR_REWIND "dir_rewinddir"
115#define USERSTREAM_DIR_CLOSE "dir_closedir"
116#define USERSTREAM_LOCK "stream_lock"
117#define USERSTREAM_CAST "stream_cast"
118#define USERSTREAM_SET_OPTION "stream_set_option"
119#define USERSTREAM_TRUNCATE "stream_truncate"
120#define USERSTREAM_METADATA "stream_metadata"
276 add_property_resource(
object,
"context",
context->res);
278 add_property_null(
object,
"context");
288 zend_call_known_instance_method_with_0_params(
298 zval zretval, zfuncname;
302 bool old_in_user_include;
305 if (
FG(user_stream_current_filename) !=
NULL &&
strcmp(filename,
FG(user_stream_current_filename)) == 0) {
309 FG(user_stream_current_filename) = filename;
315 old_in_user_include =
PG(in_user_include);
318 !
PG(allow_url_include)) {
319 PG(in_user_include) = 1;
329 FG(user_stream_current_filename) =
NULL;
330 PG(in_user_include) = old_in_user_include;
344 call_result = call_method_if_exists(&us->
object, &zfuncname, &zretval, 4,
args);
346 FG(user_stream_current_filename) =
NULL;
367 if (stream ==
NULL) {
380 FG(user_stream_current_filename) =
NULL;
382 PG(in_user_include) = old_in_user_include;
399 zval zretval, zfuncname;
405 if (
FG(user_stream_current_filename) !=
NULL &&
strcmp(filename,
FG(user_stream_current_filename)) == 0) {
409 FG(user_stream_current_filename) = filename;
418 FG(user_stream_current_filename) =
NULL;
429 call_result = call_method_if_exists(&us->
object, &zfuncname, &zretval, 2,
args);
443 if (stream ==
NULL) {
455 FG(user_stream_current_filename) =
NULL;
533 HashTable *global_wrapper_hash, *wrapper_hash;
540 if ((
wrapper = zend_hash_find_ptr(global_wrapper_hash, protocol)) ==
NULL) {
546 if (wrapper_hash == global_wrapper_hash || zend_hash_find_ptr(wrapper_hash, protocol) ==
wrapper) {
563static ssize_t php_userstreamop_write(
php_stream *stream,
const char *
buf,
size_t count)
600 if (didwrite > 0 && didwrite >
count) {
646 if (!try_convert_to_string(&
retval)) {
653 if (didread >
count) {
677 }
else if (call_result ==
FAILURE) {
690static int php_userstreamop_close(
php_stream *stream,
int close_handle)
713static int php_userstreamop_flush(
php_stream *stream)
741 int call_result,
ret;
787 }
else if (call_result ==
FAILURE) {
805#define STAT_PROP_ENTRY_EX(name, name2) \
806 if (NULL != (elem = zend_hash_str_find(Z_ARRVAL_P(array), #name, sizeof(#name)-1))) { \
807 ssb->sb.st_##name2 = zval_get_long(elem); \
810#define STAT_PROP_ENTRY(name) STAT_PROP_ENTRY_EX(name,name)
819#ifdef HAVE_STRUCT_STAT_ST_RDEV
826#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
829#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
833#undef STAT_PROP_ENTRY
834#undef STAT_PROP_ENTRY_EX
850 statbuf_from_array(&
retval, ssb);
866static int php_userstreamop_set_option(
php_stream *stream,
int option,
int value,
void *ptrparam) {
915 }
else if (call_result ==
FAILURE) {
994 struct timeval
tv = *(
struct timeval*)ptrparam;
1035 zval zfuncname, zretval;
1042 user_stream_create_object(uwrap,
context, &
object);
1052 call_result = call_method_if_exists(&
object, &zfuncname, &zretval, 1,
args);
1056 }
else if (call_result ==
FAILURE) {
1074 zval zfuncname, zretval;
1081 user_stream_create_object(uwrap,
context, &
object);
1092 call_result = call_method_if_exists(&
object, &zfuncname, &zretval, 2,
args);
1096 }
else if (call_result ==
FAILURE) {
1115 zval zfuncname, zretval;
1122 user_stream_create_object(uwrap,
context, &
object);
1134 call_result = call_method_if_exists(&
object, &zfuncname, &zretval, 3,
args);
1138 }
else if (call_result ==
FAILURE) {
1158 zval zfuncname, zretval;
1165 user_stream_create_object(uwrap,
context, &
object);
1176 call_result = call_method_if_exists(&
object, &zfuncname, &zretval, 2,
args);
1180 }
else if (call_result ==
FAILURE) {
1199 zval zfuncname, zretval;
1209 struct utimbuf *newtime = (
struct utimbuf *)
value;
1230 user_stream_create_object(uwrap,
context, &
object);
1242 call_result = call_method_if_exists(&
object, &zfuncname, &zretval, 3,
args);
1246 }
else if (call_result ==
FAILURE) {
1267 zval zfuncname, zretval;
1274 user_stream_create_object(uwrap,
context, &
object);
1285 call_result = call_method_if_exists(&
object, &zfuncname, &zretval, 2,
args);
1289 statbuf_from_array(&zretval, ssb);
1333 }
else if (call_result ==
FAILURE) {
1344static int php_userstreamop_closedir(
php_stream *stream,
int close_handle)
1383static int php_userstreamop_cast(
php_stream *stream,
int castas,
void **retptr)
1393 bool report_errors = retptr;
1410 if (report_errors) {
1421 if (report_errors) {
1427 if (intstream == stream) {
1428 if (report_errors) {
1446 php_userstreamop_write, php_userstreamop_read,
1447 php_userstreamop_close, php_userstreamop_flush,
1449 php_userstreamop_seek,
1450 php_userstreamop_cast,
1451 php_userstreamop_stat,
1452 php_userstreamop_set_option,
1457 php_userstreamop_readdir,
1458 php_userstreamop_closedir,
1461 php_userstreamop_rewinddir,
stream_wrapper_restore(string $protocol)
stream_wrapper_register(string $protocol, string $class, int $flags=0)
stream_wrapper_unregister(string $protocol)
count(Countable|array $value, int $mode=COUNT_NORMAL)
assert(mixed $assertion, Throwable|string|null $description=null)
memset(ptr, 0, type->size)
zend_ffi_ctype_name_buf buf
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...)
#define PHP_MINIT_FUNCTION
#define PHP_STRLCPY(dst, src, size, src_size)
PHP_JSON_API size_t int options
PHPAPI const php_stream_ops php_stream_userspace_dir_ops
PHPAPI const php_stream_ops php_stream_userspace_ops
#define php_stream_cast(stream, as, ret, show_err)
struct _php_stream_wrapper_ops php_stream_wrapper_ops
struct _php_stream php_stream
struct _php_stream_context php_stream_context
#define PHP_STREAM_META_GROUP
#define PHP_STREAM_OPTION_BLOCKING
struct _php_stream_dirent php_stream_dirent
#define PHP_STREAM_AS_FD_FOR_SELECT
#define PHP_STREAM_TRUNCATE_SET_SIZE
#define PHP_STREAM_META_OWNER_NAME
#define php_stream_alloc_rel(ops, thisptr, persistent, mode)
#define PHP_STREAM_FLAG_NO_SEEK
#define STREAM_OPEN_FOR_INCLUDE
#define PHP_STREAM_OPTION_WRITE_BUFFER
#define PHP_STREAM_META_GROUP_NAME
PHPAPI HashTable * php_stream_get_url_stream_wrappers_hash_global(void)
#define PHP_STREAM_OPTION_RETURN_NOTIMPL
#define PHP_STREAM_META_OWNER
#define PHP_STREAM_OPTION_READ_TIMEOUT
struct _php_stream_ops php_stream_ops
#define PHP_STREAM_OPTION_LOCKING
#define PHP_STREAM_META_TOUCH
#define PHP_STREAM_OPTION_READ_BUFFER
PHPAPI zend_result php_unregister_url_stream_wrapper_volatile(zend_string *protocol)
#define php_stream_get_url_stream_wrappers_hash()
#define PHP_STREAM_OPTION_RETURN_ERR
#define PHP_STREAM_OPTION_CHECK_LIVENESS
#define php_stream_from_zval_no_verify(xstr, pzval)
#define PHP_STREAM_OPTION_TRUNCATE_API
#define PHP_STREAM_IS_URL
struct _php_stream_wrapper php_stream_wrapper
#define PHP_STREAM_TRUNCATE_SUPPORTED
PHPAPI zend_result php_register_url_stream_wrapper_volatile(zend_string *protocol, php_stream_wrapper *wrapper)
#define PHP_STREAM_OPTION_RETURN_OK
#define PHP_STREAM_AS_STDIO
struct _php_stream_statbuf php_stream_statbuf
PHPAPI void php_stream_wrapper_log_error(const php_stream_wrapper *wrapper, int options, const char *fmt,...) PHP_ATTRIBUTE_FORMAT(printf
#define PHP_STREAM_META_ACCESS
const php_stream_wrapper_ops * wops
struct php_user_stream_wrapper * wrapper
zend_function * constructor
php_stream_wrapper wrapper
#define USERSTREAM_RENAME
#define USERSTREAM_DIR_REWIND
#define USERSTREAM_UNLINK
#define USERSTREAM_DIR_OPEN
struct _php_userstream_data php_userstream_data_t
#define USERSTREAM_DIR_CLOSE
#define USERSTREAM_STATURL
#define USERSTREAM_METADATA
#define USERSTREAM_DIR_READ
#define USERSTREAM_SET_OPTION
#define USERSTREAM_TRUNCATE
#define STAT_PROP_ENTRY(name)
ZEND_API zend_result object_init_ex(zval *arg, zend_class_entry *class_type)
ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec,...)
ZEND_API bool zend_is_callable_ex(zval *callable, zend_object *object, uint32_t check_flags, zend_string **callable_name, zend_fcall_info_cache *fcc, char **error)
ZEND_API void add_index_long(zval *arg, zend_ulong index, zend_long n)
#define IS_CALLABLE_SUPPRESS_DEPRECATIONS
#define ZVAL_STRING(z, s)
ZEND_API zend_result zend_call_method_if_exists(zend_object *object, zend_string *method_name, zval *retval, uint32_t param_count, zval *params)
#define ZVAL_STRINGL(z, s, l)
#define estrndup(s, length)
#define ecalloc(nmemb, size)
strcmp(string $string1, string $string2)
#define ZEND_ACC_IMPLICIT_ABSTRACT_CLASS
#define ZEND_ACC_EXPLICIT_ABSTRACT_CLASS
#define ZEND_ACC_INTERFACE
ZEND_API zend_resource * zend_register_resource(void *rsrc_pointer, int rsrc_type)
ZEND_API zend_result ZEND_FASTCALL zend_list_delete(zend_resource *res)
ZEND_API int zend_register_list_destructors_ex(rsrc_dtor_func_t ld, rsrc_dtor_func_t pld, const char *type_name, int module_number)
struct _zend_string zend_string
ZEND_API bool ZEND_FASTCALL zend_is_true(const zval *op)
ZEND_API void ZEND_FASTCALL convert_to_long(zval *op)
#define convert_to_string(op)
struct _zend_class_entry zend_class_entry
struct _zend_resource zend_resource
struct _zend_array HashTable
#define ZVAL_NEW_REF(z, r)
ZEND_RESULT_CODE zend_result
ZEND_API void zval_ptr_dtor(zval *zval_ptr)