streams: add const specifier

This commit is contained in:
Gina Peter Banyard 2025-07-12 11:56:39 +01:00
parent ef98a6e723
commit 17b8706bf6
6 changed files with 22 additions and 22 deletions

View file

@ -568,13 +568,13 @@ PHP_FUNCTION(stream_get_meta_data)
/* {{{ Retrieves list of registered socket transports */ /* {{{ Retrieves list of registered socket transports */
PHP_FUNCTION(stream_get_transports) PHP_FUNCTION(stream_get_transports)
{ {
HashTable *stream_xport_hash;
zend_string *stream_xport;
ZEND_PARSE_PARAMETERS_NONE(); ZEND_PARSE_PARAMETERS_NONE();
stream_xport_hash = php_stream_xport_get_hash();
array_init(return_value); array_init(return_value);
const HashTable *stream_xport_hash = php_stream_xport_get_hash();
zend_string *stream_xport;
ZEND_HASH_MAP_FOREACH_STR_KEY(stream_xport_hash, stream_xport) { ZEND_HASH_MAP_FOREACH_STR_KEY(stream_xport_hash, stream_xport) {
add_next_index_str(return_value, zend_string_copy(stream_xport)); add_next_index_str(return_value, zend_string_copy(stream_xport));
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
@ -584,13 +584,12 @@ PHP_FUNCTION(stream_get_transports)
/* {{{ Retrieves list of registered stream wrappers */ /* {{{ Retrieves list of registered stream wrappers */
PHP_FUNCTION(stream_get_wrappers) PHP_FUNCTION(stream_get_wrappers)
{ {
HashTable *url_stream_wrappers_hash;
zend_string *stream_protocol;
ZEND_PARSE_PARAMETERS_NONE(); ZEND_PARSE_PARAMETERS_NONE();
url_stream_wrappers_hash = php_stream_get_url_stream_wrappers_hash();
array_init(return_value); array_init(return_value);
const HashTable *url_stream_wrappers_hash = php_stream_get_url_stream_wrappers_hash();
zend_string *stream_protocol;
ZEND_HASH_MAP_FOREACH_STR_KEY(url_stream_wrappers_hash, stream_protocol) { ZEND_HASH_MAP_FOREACH_STR_KEY(url_stream_wrappers_hash, stream_protocol) {
if (stream_protocol) { if (stream_protocol) {
add_next_index_str(return_value, zend_string_copy(stream_protocol)); add_next_index_str(return_value, zend_string_copy(stream_protocol));
@ -882,7 +881,7 @@ static void user_space_stream_notifier_dtor(php_stream_notifier *notifier)
notifier->ptr = NULL; notifier->ptr = NULL;
} }
static zend_result parse_context_options(php_stream_context *context, HashTable *options) static zend_result parse_context_options(php_stream_context *context, const HashTable *options)
{ {
zval *wval, *oval; zval *wval, *oval;
zend_string *wkey, *okey; zend_string *wkey, *okey;
@ -906,7 +905,7 @@ static zend_result parse_context_options(php_stream_context *context, HashTable
return SUCCESS; return SUCCESS;
} }
static zend_result parse_context_params(php_stream_context *context, HashTable *params) static zend_result parse_context_params(php_stream_context *context, const HashTable *params)
{ {
zval *tmp; zval *tmp;

View file

@ -361,7 +361,7 @@ PHPAPI int _php_stream_seek(php_stream *stream, zend_off_t offset, int whence);
#define php_stream_rewind(stream) _php_stream_seek((stream), 0L, SEEK_SET) #define php_stream_rewind(stream) _php_stream_seek((stream), 0L, SEEK_SET)
#define php_stream_seek(stream, offset, whence) _php_stream_seek((stream), (offset), (whence)) #define php_stream_seek(stream, offset, whence) _php_stream_seek((stream), (offset), (whence))
PHPAPI zend_off_t _php_stream_tell(php_stream *stream); PHPAPI zend_off_t _php_stream_tell(const php_stream *stream);
#define php_stream_tell(stream) _php_stream_tell((stream)) #define php_stream_tell(stream) _php_stream_tell((stream))
PHPAPI ssize_t _php_stream_read(php_stream *stream, char *buf, size_t count); PHPAPI ssize_t _php_stream_read(php_stream *stream, char *buf, size_t count);

View file

@ -68,7 +68,7 @@ PHPAPI int php_stream_filter_register_factory_volatile(zend_string *filterpatter
/* Buckets */ /* Buckets */
PHPAPI php_stream_bucket *php_stream_bucket_new(php_stream *stream, char *buf, size_t buflen, uint8_t own_buf, uint8_t buf_persistent) PHPAPI php_stream_bucket *php_stream_bucket_new(const php_stream *stream, char *buf, size_t buflen, uint8_t own_buf, uint8_t buf_persistent)
{ {
int is_persistent = php_stream_is_persistent(stream); int is_persistent = php_stream_is_persistent(stream);
php_stream_bucket *bucket; php_stream_bucket *bucket;

View file

@ -59,7 +59,7 @@ BEGIN_EXTERN_C()
PHPAPI int php_le_stream_context(void); PHPAPI int php_le_stream_context(void);
PHPAPI void php_stream_context_free(php_stream_context *context); PHPAPI void php_stream_context_free(php_stream_context *context);
PHPAPI php_stream_context *php_stream_context_alloc(void); PHPAPI php_stream_context *php_stream_context_alloc(void);
PHPAPI zval *php_stream_context_get_option(php_stream_context *context, PHPAPI zval *php_stream_context_get_option(const php_stream_context *context,
const char *wrappername, const char *optionname); const char *wrappername, const char *optionname);
PHPAPI void php_stream_context_set_option(php_stream_context *context, PHPAPI void php_stream_context_set_option(php_stream_context *context,
const char *wrappername, const char *optionname, zval *optionvalue); const char *wrappername, const char *optionname, zval *optionvalue);

View file

@ -63,7 +63,7 @@ typedef enum {
/* Buckets API. */ /* Buckets API. */
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
PHPAPI php_stream_bucket *php_stream_bucket_new(php_stream *stream, char *buf, size_t buflen, uint8_t own_buf, uint8_t buf_persistent); PHPAPI php_stream_bucket *php_stream_bucket_new(const php_stream *stream, char *buf, size_t buflen, uint8_t own_buf, uint8_t buf_persistent);
PHPAPI int php_stream_bucket_split(php_stream_bucket *in, php_stream_bucket **left, php_stream_bucket **right, size_t length); PHPAPI int php_stream_bucket_split(php_stream_bucket *in, php_stream_bucket **left, php_stream_bucket **right, size_t length);
PHPAPI void php_stream_bucket_delref(php_stream_bucket *bucket); PHPAPI void php_stream_bucket_delref(php_stream_bucket *bucket);
#define php_stream_bucket_addref(bucket) (bucket)->refcount++ #define php_stream_bucket_addref(bucket) (bucket)->refcount++

View file

@ -1041,12 +1041,13 @@ PHPAPI char *_php_stream_get_line(php_stream *stream, char *buf, size_t maxlen,
#define STREAM_BUFFERED_AMOUNT(stream) \ #define STREAM_BUFFERED_AMOUNT(stream) \
((size_t)(((stream)->writepos) - (stream)->readpos)) ((size_t)(((stream)->writepos) - (stream)->readpos))
static const char *_php_stream_search_delim(php_stream *stream, static const char *_php_stream_search_delim(
const php_stream *stream,
size_t maxlen, size_t maxlen,
size_t skiplen, size_t skiplen,
const char *delim, /* non-empty! */ const char *delim, /* non-empty! */
size_t delim_len) size_t delim_len
{ ) {
size_t seek_len; size_t seek_len;
/* set the maximum number of bytes we're allowed to read from buffer */ /* set the maximum number of bytes we're allowed to read from buffer */
@ -1340,7 +1341,7 @@ PHPAPI ssize_t _php_stream_printf(php_stream *stream, const char *fmt, ...)
return count; return count;
} }
PHPAPI zend_off_t _php_stream_tell(php_stream *stream) PHPAPI zend_off_t _php_stream_tell(const php_stream *stream)
{ {
return stream->position; return stream->position;
} }
@ -1975,7 +1976,7 @@ PHPAPI zend_result php_unregister_url_stream_wrapper_volatile(zend_string *proto
/* {{{ php_stream_locate_url_wrapper */ /* {{{ php_stream_locate_url_wrapper */
PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, const char **path_for_open, int options) PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, const char **path_for_open, int options)
{ {
HashTable *wrapper_hash = (FG(stream_wrappers) ? FG(stream_wrappers) : &url_stream_wrappers_hash); const HashTable *wrapper_hash = (FG(stream_wrappers) ? FG(stream_wrappers) : &url_stream_wrappers_hash);
php_stream_wrapper *wrapper = NULL; php_stream_wrapper *wrapper = NULL;
const char *p, *protocol = NULL; const char *p, *protocol = NULL;
size_t n = 0; size_t n = 0;
@ -2416,7 +2417,7 @@ PHPAPI void php_stream_notification_free(php_stream_notifier *notifier)
efree(notifier); efree(notifier);
} }
PHPAPI zval *php_stream_context_get_option(php_stream_context *context, PHPAPI zval *php_stream_context_get_option(const php_stream_context *context,
const char *wrappername, const char *optionname) const char *wrappername, const char *optionname)
{ {
zval *wrapperhash; zval *wrapperhash;