mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
main/streams: Add a helper macro to retrieve default context
This commit is contained in:
@@ -25,14 +25,17 @@ typedef void (*php_stream_notification_func)(php_stream_context *context,
|
||||
|
||||
#define PHP_STREAM_NOTIFIER_PROGRESS 1
|
||||
|
||||
/* TODO: Remove dependence on ext/standard/file.h for the default context global */
|
||||
#define php_stream_context_get_default(without_context) \
|
||||
(without_context) ? NULL : FG(default_context) ? FG(default_context) : \
|
||||
(FG(default_context) = php_stream_context_alloc())
|
||||
|
||||
/* Attempt to fetch context from the zval passed,
|
||||
If no context was passed, use the default context
|
||||
The default context has not yet been created, do it now. */
|
||||
#define php_stream_context_from_zval(zcontext, nocontext) ( \
|
||||
(zcontext) ? zend_fetch_resource_ex(zcontext, "Stream-Context", php_le_stream_context()) : \
|
||||
(nocontext) ? NULL : \
|
||||
FG(default_context) ? FG(default_context) : \
|
||||
(FG(default_context) = php_stream_context_alloc()) )
|
||||
php_stream_context_get_default(nocontext))
|
||||
|
||||
#define php_stream_context_to_zval(context, zval) { ZVAL_RES(zval, (context)->res); GC_ADDREF((context)->res); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user