From a4b927a0f9e7dce9d0b002e559c314b45acf46ff Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 10 Jun 2021 16:17:26 +0200 Subject: [PATCH] add PHPC_PHP_STAT helper --- phpc.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/phpc.h b/phpc.h index 9206105..8e7211f 100644 --- a/phpc/phpc.h +++ b/phpc/phpc.h @@ -1595,5 +1595,16 @@ typedef const char phpc_stream_opener_char_t; php_stream_locate_url_wrapper(_path, (char **) _path_for_open, _options TSRMLS_CC) #endif +#if (PHP_MAJOR_VERSION == 8 && PHP_MINOR_VERSION >= 1) || (PHP_MAJOR_VERSION > 8) +#define PHPC_PHP_STAT(filename, filename_length, type, return_value) do { \ + zend_string *str = zend_string_init(filename, filename_length, 0); \ + php_stat(str, type, return_value); \ + zend_string_release(str); \ + } while (0) + +#else +#define PHPC_PHP_STAT php_stat +#endif + #endif /* PHPC_H */ From 79111c0b9504d18f4c9b70c2a6b6ed9eadc5047d Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 10 Jun 2021 16:18:23 +0200 Subject: [PATCH] Use PHPC_PHP_STAT helper --- fann.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fann.c b/fann.c index 68dd96b..d0c0d84 100644 --- a/fann.c +++ b/fann.c @@ -1189,13 +1189,13 @@ static char *php_fann_get_path_for_open(char *path, phpc_str_size_t path_len, in char *path_for_open; if (read) { - php_stat(path, (php_stat_len) path_len, FS_IS_R, &retval TSRMLS_CC); + PHPC_PHP_STAT(path, (php_stat_len) path_len, FS_IS_R, &retval TSRMLS_CC); } else { - php_stat(path, (php_stat_len) path_len, FS_IS_W, &retval TSRMLS_CC); + PHPC_PHP_STAT(path, (php_stat_len) path_len, FS_IS_W, &retval TSRMLS_CC); if (PHP_FANN_PATH_FORBIDDEN(retval)) { char *dirname = estrndup(path, path_len); size_t dirname_len = php_dirname(dirname, (size_t) path_len); - php_stat(dirname, (php_stat_len) dirname_len, FS_IS_W, &retval TSRMLS_CC); + PHPC_PHP_STAT(dirname, (php_stat_len) dirname_len, FS_IS_W, &retval TSRMLS_CC); efree(dirname); } }