Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions main/streams/php_stream_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,6 @@

BEGIN_EXTERN_C()

/* Error mode context options (internal C constants) */
#define PHP_STREAM_ERROR_MODE_ERROR 0
#define PHP_STREAM_ERROR_MODE_EXCEPTION 1
#define PHP_STREAM_ERROR_MODE_SILENT 2

/* Error store context options (internal C constants) */
#define PHP_STREAM_ERROR_STORE_AUTO 0
#define PHP_STREAM_ERROR_STORE_NONE 1
#define PHP_STREAM_ERROR_STORE_NON_TERM 2
#define PHP_STREAM_ERROR_STORE_TERMINAL 3
#define PHP_STREAM_ERROR_STORE_ALL 4

/* Maximum operation nesting depth */
#define PHP_STREAM_ERROR_MAX_DEPTH 1000
/* Operations pool size to prevent extra allocations */
Expand Down
30 changes: 23 additions & 7 deletions main/streams/stream_errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,23 @@ static void php_stream_error_create_array(zval *zv, php_stream_error_entry *firs
}

/* Context option helpers */

static int php_stream_auto_decide_error_store_mode(int error_mode)
/* Error mode context options (internal C constants) */
C23_ENUM(php_stream_error_mode, uint8_t) {
PHP_STREAM_ERROR_MODE_ERROR = 0,
PHP_STREAM_ERROR_MODE_EXCEPTION = 1,
PHP_STREAM_ERROR_MODE_SILENT = 2
};

/* Error store context options (internal C constants) */
C23_ENUM(php_stream_error_store, uint8_t) {
PHP_STREAM_ERROR_STORE_AUTO = 0,
PHP_STREAM_ERROR_STORE_NONE = 1,
PHP_STREAM_ERROR_STORE_NON_TERM = 2,
PHP_STREAM_ERROR_STORE_TERMINAL = 3,
PHP_STREAM_ERROR_STORE_ALL = 4
};

static php_stream_error_store php_stream_auto_decide_error_store_mode(php_stream_error_mode error_mode)
{
switch (error_mode) {
case PHP_STREAM_ERROR_MODE_ERROR:
Expand All @@ -98,7 +113,7 @@ static int php_stream_auto_decide_error_store_mode(int error_mode)
}
}

static int php_stream_get_error_mode(php_stream_context *context)
static php_stream_error_mode php_stream_get_error_mode(php_stream_context *context)
{
if (!context) {
return PHP_STREAM_ERROR_MODE_ERROR;
Expand Down Expand Up @@ -127,7 +142,8 @@ static int php_stream_get_error_mode(php_stream_context *context)
return PHP_STREAM_ERROR_MODE_ERROR;
}

static int php_stream_get_error_store_mode(php_stream_context *context, int error_mode)
static php_stream_error_store php_stream_get_error_store_mode(
php_stream_context *context, php_stream_error_mode error_mode)
{
if (!context) {
return php_stream_auto_decide_error_store_mode(error_mode);
Expand Down Expand Up @@ -386,7 +402,7 @@ static void php_stream_throw_exception_with_errors(php_stream_error_operation *o
}

static void php_stream_report_errors(php_stream_context *context, php_stream_error_operation *op,
int error_mode, bool is_terminating)
php_stream_error_mode error_mode, bool is_terminating)
{
switch (error_mode) {
case PHP_STREAM_ERROR_MODE_ERROR: {
Expand Down Expand Up @@ -439,8 +455,8 @@ PHPAPI void php_stream_error_operation_end(php_stream_context *context)
context = FG(default_context);
}

int error_mode = php_stream_get_error_mode(context);
int store_mode = php_stream_get_error_store_mode(context, error_mode);
php_stream_error_mode error_mode = php_stream_get_error_mode(context);
php_stream_error_store store_mode = php_stream_get_error_store_mode(context, error_mode);

bool is_terminating = php_stream_has_terminating_error(op);

Expand Down
Loading