31#define php_select(m, r, w, e, t) select(m, r, w, e, t)
40#define GET_CTX_OPT(stream, wrapper, name, val) (PHP_STREAM_CONTEXT(stream) && NULL != (val = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), wrapper, name)))
101 bool timeout_is_null = 1;
104 char *hashkey =
NULL;
123 if (timeout_is_null) {
124 timeout = (double)
FG(default_socket_timeout);
137 struct timeval *tv_pointer;
143 tv.tv_sec = (long)(conv / 1000000);
144 tv.tv_usec = (long)(conv % 1000000);
146 tv.tv_sec = conv / 1000000;
147 tv.tv_usec = conv % 1000000;
165 if (stream ==
NULL) {
177 if (stream ==
NULL) {
181 if (zerrstr && errstr) {
234 if (stream ==
NULL) {
238 if (stream ==
NULL) {
242 if (zerrstr && errstr) {
262 bool timeout_is_null = 1;
278 if (timeout_is_null) {
279 timeout = (double)
FG(default_socket_timeout);
288 struct timeval *tv_pointer;
294 tv.tv_sec = (long)(conv / 1000000);
295 tv.tv_usec = (long)(conv % 1000000);
297 tv.tv_sec = conv / 1000000;
298 tv.tv_usec = conv % 1000000;
304 zpeername ? &peername :
NULL,
315 zend_string_release(peername);
365 size_t datalen, target_addr_len = 0;
378 if (target_addr_len) {
420 read_buf = zend_string_alloc(to_read, 0);
423 zremote ? &remote_addr :
NULL
427 if (zremote && remote_addr) {
435 zend_string_efree(read_buf);
465 if (desiredpos >= 0) {
470 if (position >= 0 && desiredpos > position) {
473 }
else if (desiredpos < position) {
480 "Failed to seek to position " ZEND_LONG_FMT " in the stream", desiredpos);
564 if (stream->filterhead) {
567 MAKE_STD_ZVAL(newval);
570 for (filter = stream->filterhead; filter !=
NULL; filter = filter->
next) {
615 if (stream_protocol) {
624static int stream_array_to_fd_set(
zval *stream_array, fd_set *fds,
php_socket_t *max_fd)
642 if (stream ==
NULL) {
654 if (this_fd > *max_fd) {
663static int stream_array_from_fd_set(
zval *stream_array, fd_set *fds)
665 zval *elem, *dest_elem;
682 if (stream ==
NULL) {
712static int stream_array_emulate_read_fd_set(
zval *stream_array)
714 zval *elem, *dest_elem;
729 if (stream ==
NULL) {
765 zval *r_array, *w_array, *e_array;
766 struct timeval
tv, *tv_p =
NULL;
767 fd_set rfds, wfds, efds;
773 int set_count, max_set_count = 0;
788 if (r_array !=
NULL) {
789 set_count = stream_array_to_fd_set(r_array, &rfds, &max_fd);
790 if (set_count > max_set_count)
791 max_set_count = set_count;
795 if (w_array !=
NULL) {
796 set_count = stream_array_to_fd_set(w_array, &wfds, &max_fd);
797 if (set_count > max_set_count)
798 max_set_count = set_count;
802 if (e_array !=
NULL) {
803 set_count = stream_array_to_fd_set(e_array, &efds, &max_fd);
804 if (set_count > max_set_count)
805 max_set_count = set_count;
818 if (secnull && !usecnull) {
830 }
else if (usec < 0) {
836 tv.tv_sec = (long)(sec + (usec / 1000000));
837 tv.tv_usec = (long)(usec % 1000000);
844 if (r_array !=
NULL) {
845 retval = stream_array_emulate_read_fd_set(r_array);
847 if (w_array !=
NULL) {
851 if (e_array !=
NULL) {
867 if (r_array !=
NULL) stream_array_from_fd_set(r_array, &rfds);
868 if (w_array !=
NULL) stream_array_from_fd_set(w_array, &wfds);
869 if (e_array !=
NULL) stream_array_from_fd_set(e_array, &efds);
877 char *xmsg,
int xcode,
size_t bytes_sofar,
size_t bytes_max,
void *
ptr)
898 for (i = 0; i < 6; i++) {
928 zend_value_error(
"Options should have the form [\"wrappername\"][\"optionname\"] = $value");
948 context->notifier->func = user_space_stream_notifier;
950 context->notifier->dtor = user_space_stream_notifier_dtor;
1021 char *optionname =
NULL;
1022 size_t optionname_len;
1027 "use stream_context_set_options() instead"
1166 if (
FG(default_context) ==
NULL) {
1191 if (
FG(default_context) ==
NULL) {
1241 size_t filternamelen;
1263 if (
strchr(stream->mode,
'r') ||
strchr(stream->mode,
'+')) {
1264 read_write |= PHP_STREAM_FILTER_READ;
1267 read_write |= PHP_STREAM_FILTER_WRITE;
1273 if (filter ==
NULL) {
1290 if (filter ==
NULL) {
1372 if (max_length < 0) {
1415#if defined(HAVE_SYS_TIME_H) || defined(PHP_WIN32)
1434 t.tv_sec = (long)seconds;
1437 t.tv_usec = (long)(microseconds % 1000000);
1438 t.tv_sec +=(long)(microseconds / 1000000);
1446 t.tv_usec = microseconds % 1000000;
1447 t.tv_sec += microseconds / 1000000;
1558 zval *zstream, *zsessstream =
NULL;
1560 bool enable, cryptokindnull = 1;
1574 if (cryptokindnull) {
1620 if (resolved_path) {
1642 if (!try_convert_to_string(zstream)) {
1704#elif defined(HAVE_UNISTD_H)
1723 bool enable, enable_is_null = 1;
1743 if (!enable_is_null) {
1747 "not able to analyze the specified stream"
1758 if (enable_is_null) {
stream_socket_get_name($socket, bool $remote)
stream_socket_recvfrom($socket, int $length, int $flags=0, &$address=null)
stream_socket_server(string $address, &$error_code=null, &$error_message=null, int $flags=STREAM_SERVER_BIND|STREAM_SERVER_LISTEN, $context=null)
stream_socket_client(string $address, &$error_code=null, &$error_message=null, ?float $timeout=null, int $flags=STREAM_CLIENT_CONNECT, $context=null)
stream_context_create(?array $options=null, ?array $params=null)
stream_socket_shutdown($stream, int $mode)
stream_socket_enable_crypto($stream, bool $enable, ?int $crypto_method=null, $session_stream=null)
stream_socket_accept($socket, ?float $timeout=null, &$peer_name=null)
stream_filter_prepend($stream, string $filter_name, int $mode=0, mixed $params=UNKNOWN)
stream_context_get_default(?array $options=null)
stream_get_meta_data($stream)
stream_copy_to_stream($from, $to, ?int $length=null, int $offset=0)
stream_get_line($stream, int $length, string $ending="")
sapi_windows_vt100_support($stream, ?bool $enable=null)
stream_context_set_option($context, array|string $wrapper_or_options, ?string $option_name=null, mixed $value=UNKNOWN)
stream_select(?array &$read, ?array &$write, ?array &$except, ?int $seconds, ?int $microseconds=null)
stream_filter_append($stream, string $filter_name, int $mode=0, mixed $params=UNKNOWN)
stream_socket_sendto($socket, string $data, int $flags=0, string $address="")
stream_resolve_include_path(string $filename)
stream_context_set_params($context, array $params)
stream_context_set_default(array $options)
stream_set_timeout($stream, int $seconds, int $microseconds=0)
stream_socket_pair(int $domain, int $type, int $protocol)
stream_context_set_options($context, array $options)
stream_filter_remove($stream_filter)
stream_set_write_buffer($stream, int $size)
stream_set_chunk_size($stream, int $size)
stream_supports_lock($stream)
stream_context_get_options($stream_or_context)
stream_get_contents($stream, ?int $length=null, int $offset=-1)
stream_context_get_params($context)
stream_set_blocking($stream, bool $enable)
strchr(string $haystack, string $needle, bool $before_needle=false)
stream_set_read_buffer($stream, int $size)
PHP_WINUTIL_API BOOL php_win32_console_fileno_has_vt100(zend_long fileno)
PHP_WINUTIL_API BOOL php_win32_console_fileno_is_console(zend_long fileno)
PHP_WINUTIL_API BOOL php_win32_console_fileno_set_vt100(zend_long fileno, BOOL enable)
zend_ffi_ctype_name_buf buf
PHPAPI int php_le_stream_context(void)
foreach($dp as $el) foreach( $dp as $el) if( $pass2< 2) echo ""
PHPAPI php_stream_filter * php_stream_filter_create(const char *filtername, zval *filterparams, uint8_t persistent)
PHPAPI int php_stream_filter_prepend_ex(php_stream_filter_chain *chain, php_stream_filter *filter)
PHPAPI int php_stream_filter_append_ex(php_stream_filter_chain *chain, php_stream_filter *filter)
PHPAPI php_stream_filter * php_stream_filter_remove(php_stream_filter *filter, int call_dtor)
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...)
PHPAPI char * php_socket_strerror(long err, char *buf, size_t bufsize)
PHPAPI zend_result php_network_parse_network_address_with_port(const char *addr, size_t addrlen, struct sockaddr *sa, socklen_t *sl)
unsigned const char * pos
PHP_JSON_API size_t int options
#define PHP_SAFE_FD_ISSET(fd, set)
#define PHP_SOCK_CHUNK_SIZE
#define PHP_SAFE_FD_SET(fd, set)
#define php_stream_sock_open_from_socket(socket, persistent)
#define php_socket_errno()
#define PHP_SAFE_MAX_FD(m, n)
unsigned char key[REFLECTION_KEY_LEN]
PHPAPI void php_stream_notification_free(php_stream_notifier *notifier)
PHPAPI php_stream_notifier * php_stream_notification_alloc(void)
#define php_stream_context_from_zval(zcontext, nocontext)
#define php_stream_context_to_zval(context, zval)
PHPAPI php_stream_context * php_stream_context_alloc(void)
PHPAPI void php_stream_context_set_option(php_stream_context *context, const char *wrappername, const char *optionname, zval *optionvalue)
struct _php_stream_notifier php_stream_notifier
#define PHP_STREAM_FILTER_ALL
#define php_stream_filter_flush(filter, finish)
#define PHP_STREAM_FILTER_WRITE
#define PHP_STREAM_FILTER_READ
#define php_stream_xport_create(name, namelen, options, flags, persistent_id, timeout, context, estr, ecode)
PHPAPI int php_stream_xport_crypto_enable(php_stream *stream, int activate)
#define STREAM_XPORT_SERVER
#define STREAM_XPORT_BIND
PHPAPI int php_stream_xport_accept(php_stream *stream, php_stream **client, zend_string **textaddr, void **addr, socklen_t *addrlen, struct timeval *timeout, zend_string **error_text)
#define STREAM_XPORT_CONNECT_ASYNC
PHPAPI HashTable * php_stream_xport_get_hash(void)
PHPAPI int php_stream_xport_shutdown(php_stream *stream, stream_shutdown_t how)
#define STREAM_XPORT_CONNECT
PHPAPI int php_stream_xport_get_name(php_stream *stream, int want_peer, zend_string **textaddr, void **addr, socklen_t *addrlen)
PHPAPI int php_stream_xport_crypto_setup(php_stream *stream, php_stream_xport_crypt_method_t crypto_method, php_stream *session_stream)
#define STREAM_XPORT_CLIENT
#define STREAM_XPORT_LISTEN
PHPAPI int php_stream_xport_recvfrom(php_stream *stream, char *buf, size_t buflen, int flags, void **addr, socklen_t *addrlen, zend_string **textaddr)
PHPAPI int php_stream_xport_sendto(php_stream *stream, const char *buf, size_t buflen, int flags, void *addr, socklen_t addrlen)
#define php_stream_cast(stream, as, ret, show_err)
PHPAPI zend_string * php_stream_get_record(php_stream *stream, size_t maxlen, const char *delim, size_t delim_len)
PHPAPI int php_file_le_stream_filter(void)
struct _php_stream php_stream
struct _php_stream_context php_stream_context
#define PHP_STREAM_OPTION_BLOCKING
#define PHP_STREAM_AS_FD_FOR_SELECT
#define php_stream_from_zval(xstr, pzval)
#define PHP_STREAM_OPTION_SET_CHUNK_SIZE
struct _php_stream_filter php_stream_filter
#define php_stream_populate_meta_data(stream, zv)
#define php_stream_auto_cleanup(stream)
#define PHP_STREAM_COPY_ALL
#define PHP_STREAM_FLAG_NO_SEEK
#define PHP_STREAM_BUFFER_NONE
#define php_stream_seek(stream, offset, whence)
#define php_stream_supports_lock(stream)
#define php_stream_to_zval(stream, zval)
#define php_stream_can_cast(stream, as)
#define PHP_STREAM_OPTION_WRITE_BUFFER
#define php_stream_eof(stream)
#define php_stream_free(stream, close_options)
#define PHP_STREAM_CONTEXT(stream)
#define PHP_STREAM_FREE_CLOSE
#define php_stream_tell(stream)
#define php_stream_is_persistent(stream)
#define PHP_STREAM_OPTION_READ_TIMEOUT
#define php_stream_copy_to_mem(src, maxlen, persistent)
#define PHP_STREAM_OPTION_READ_BUFFER
#define PHP_STREAM_BUFFER_FULL
#define php_stream_get_url_stream_wrappers_hash()
PHPAPI int php_file_le_pstream(void)
#define php_stream_from_zval_no_verify(xstr, pzval)
struct _php_stream_wrapper php_stream_wrapper
#define php_stream_copy_to_stream_ex(src, dest, maxlen, len)
PHPAPI php_stream_wrapper * php_stream_locate_url_wrapper(const char *path, const char **path_for_open, int options)
#define php_stream_set_option(stream, option, value, ptrvalue)
#define PHP_STREAM_OPTION_RETURN_OK
PHPAPI int php_file_le_stream(void)
#define PHP_STREAM_CAST_INTERNAL
PHPAPI zend_string * php_addslashes(zend_string *str)
#define PHP_FILE_NO_DEFAULT_CONTEXT
#define PHP_TIMEOUT_ULL_MAX
#define php_select(m, r, w, e, t)
unsigned long long php_timeout_ull
#define GET_CTX_OPT(stream, wrapper, name, val)
#define PHP_STREAM_CLIENT_ASYNC_CONNECT
#define PHP_STREAM_CLIENT_PERSISTENT
#define PHP_STREAM_CLIENT_CONNECT
const php_stream_filter_ops * fops
int(* seek)(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffset)
const php_stream_wrapper_ops * wops
const php_stream_ops * ops
php_stream_wrapper * wrapper
PHPAPI int socketpair(int domain, int type, int protocol, SOCKET sock[2])
ZEND_API ZEND_COLD void zend_type_error(const char *format,...)
ZEND_API ZEND_COLD void zend_value_error(const char *format,...)
ZEND_API ZEND_COLD void zend_error(int type, const char *format,...)
ZEND_API zend_string *(* zend_resolve_path)(zend_string *filename)
#define INTERNAL_FUNCTION_PARAMETERS
#define INTERNAL_FUNCTION_PARAM_PASSTHRU
ZEND_API void add_assoc_zval_ex(zval *arg, const char *key, size_t key_len, zval *value)
ZEND_API zend_result add_next_index_resource(zval *arg, zend_resource *r)
ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *format,...)
ZEND_API ZEND_COLD void zend_argument_type_error(uint32_t arg_num, const char *format,...)
ZEND_API zend_result add_next_index_string(zval *arg, const char *str)
ZEND_API zend_result add_next_index_str(zval *arg, zend_string *str)
#define Z_PARAM_PATH_STR(dest)
#define Z_PARAM_ARRAY_EX2(dest, check_null, deref, separate)
#define ZEND_PARSE_PARAMETERS_END()
#define Z_PARAM_ARRAY_HT_OR_NULL(dest)
#define Z_PARAM_RESOURCE(dest)
#define ZEND_PARSE_PARAMETERS_NONE()
#define ZVAL_STRING(z, s)
#define Z_PARAM_STRING(dest, dest_len)
#define Z_PARAM_STR(dest)
#define Z_PARAM_STRING_OR_NULL(dest, dest_len)
#define Z_PARAM_DOUBLE_OR_NULL(dest, is_null)
#define ZEND_PARSE_PARAMETERS_START(min_num_args, max_num_args)
#define Z_PARAM_BOOL_OR_NULL(dest, is_null)
#define ZEND_TRY_ASSIGN_REF_LONG(zv, lval)
#define Z_PARAM_ARRAY_HT_OR_STR(dest_ht, dest_str)
#define ZEND_TRY_ASSIGN_REF_NULL(zv)
#define Z_PARAM_LONG(dest)
#define RETURN_NEW_STR(s)
#define Z_PARAM_ARRAY_HT(dest)
#define ZEND_TRY_ASSIGN_REF_EMPTY_STRING(zv)
#define Z_PARAM_LONG_OR_NULL(dest, is_null)
#define call_user_function(function_table, object, function_name, retval_ptr, param_count, params)
#define Z_PARAM_BOOL(dest)
#define RETURN_EMPTY_STRING()
#define Z_PARAM_RESOURCE_OR_NULL(dest)
#define Z_PARAM_ZVAL(dest)
#define ZEND_TRY_ASSIGN_REF_STR(zv, str)
zend_string_release_ex(func->internal_function.function_name, 0)
ZEND_API zval *ZEND_FASTCALL zend_hash_str_find(const HashTable *ht, const char *str, size_t len)
ZEND_API zval *ZEND_FASTCALL zend_hash_index_update(HashTable *ht, zend_ulong h, zval *pData)
ZEND_API void ZEND_FASTCALL zend_array_destroy(HashTable *ht)
ZEND_API zval *ZEND_FASTCALL zend_hash_update(HashTable *ht, zend_string *key, zval *pData)
#define zend_new_array(size)
#define ZEND_HASH_FOREACH_KEY_VAL(ht, _h, _key, _val)
#define ZEND_HASH_FOREACH_STR_KEY_VAL(ht, _key, _val)
#define ZEND_HASH_MAP_FOREACH_STR_KEY(ht, _key)
#define ZEND_HASH_FOREACH_END()
#define ZVAL_EMPTY_ARRAY(z)
#define ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(ht, _key, _val)
#define ZEND_HASH_FOREACH_VAL(ht, _val)
ZEND_API void * zend_fetch_resource(zend_resource *res, const char *resource_type_name, int resource_type)
ZEND_API zend_resource * zend_register_resource(void *rsrc_pointer, int rsrc_type)
ZEND_API void ZEND_FASTCALL zend_list_close(zend_resource *res)
ZEND_API void * zend_fetch_resource_ex(zval *res, const char *resource_type_name, int resource_type)
ZEND_API void * zend_fetch_resource2_ex(zval *res, const char *resource_type_name, int resource_type1, int resource_type2)
struct _zend_string zend_string
#define UNEXPECTED(condition)
ZEND_DLIMPORT int isatty(int fd)
#define Z_STRVAL_P(zval_p)
#define Z_ARRVAL_P(zval_p)
struct _zend_array HashTable
ZEND_RESULT_CODE zend_result
ZEND_API void zval_ptr_dtor(zval *zval_ptr)
ZEND_API void zval_add_ref(zval *p)