From ca07586e1ec2b6443221dd2a6139b27e562a6789 Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Sun, 29 Oct 2000 16:25:16 +0000 Subject: [PATCH] Allow module to proclaim compatibility with any Zend version --- Zend/zend_extensions.c | 21 ++++++++++++--------- Zend/zend_extensions.h | 5 +++-- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Zend/zend_extensions.c b/Zend/zend_extensions.c index 794728adb5c..06d4d5c7381 100644 --- a/Zend/zend_extensions.c +++ b/Zend/zend_extensions.c @@ -64,17 +64,19 @@ int zend_load_extension(char *path) return FAILURE; } - if (extension_version_info->zend_extension_api_no > ZEND_EXTENSION_API_NO) { - fprintf(stderr, "%s requires Zend Engine API version %d\n" + + /* allow extension to proclaim compatibility with any Zend version */ + if(extension_version_info->zend_extension_api_no != ZEND_EXTENSION_API_NO &&(!new_extension->api_no_check || new_extension->api_no_check(ZEND_EXTENSION_API_NO) != SUCCESS)) { + if (extension_version_info->zend_extension_api_no > ZEND_EXTENSION_API_NO) { + fprintf(stderr, "%s requires Zend Engine API version %d\n" "The installed Zend Engine API version is %d\n\n", new_extension->name, extension_version_info->zend_extension_api_no, ZEND_EXTENSION_API_NO); - DL_UNLOAD(handle); - return FAILURE; - } else if (extension_version_info->zend_extension_api_no < ZEND_EXTENSION_API_NO) { - /* we may be able to allow for downwards compatability in some harmless cases. */ - fprintf(stderr, "%s designed to be used with the Zend Engine API %d is outdated\n" + DL_UNLOAD(handle); + return FAILURE; + } else if (extension_version_info->zend_extension_api_no < ZEND_EXTENSION_API_NO) { + fprintf(stderr, "%s designed to be used with the Zend Engine API %d is outdated\ n" "It requires a more recent version of the Zend Engine\n" "The installed Zend Engine API version is %d\n" "Contact %s at %s for a later version of this module.\n\n", @@ -83,8 +85,9 @@ int zend_load_extension(char *path) ZEND_EXTENSION_API_NO, new_extension->author, new_extension->URL); - DL_UNLOAD(handle); - return FAILURE; + DL_UNLOAD(handle); + return FAILURE; + } } else if (ZTS_V!=extension_version_info->thread_safe) { fprintf(stderr, "Cannot load %s - it %s thread safe, whereas Zend %s\n", new_extension->name, diff --git a/Zend/zend_extensions.h b/Zend/zend_extensions.h index c39ac27937c..b594788809c 100644 --- a/Zend/zend_extensions.h +++ b/Zend/zend_extensions.h @@ -23,7 +23,7 @@ #include "zend_compile.h" -#define ZEND_EXTENSION_API_NO 20001002 +#define ZEND_EXTENSION_API_NO 20001002 typedef struct _zend_extension_version_info { int zend_extension_api_no; @@ -58,7 +58,7 @@ struct _zend_extension { void (*op_array_ctor)(zend_op_array *op_array); void (*op_array_dtor)(zend_op_array *op_array); - void *reserved1; + int (*api_no_check)(int api_no); void *reserved2; void *reserved3; void *reserved4; @@ -82,6 +82,7 @@ ZEND_API void zend_extension_dispatch_message(int message, void *arg); ZEND_EXT_API zend_extension_version_info extension_version_info = { ZEND_EXTENSION_API_NO, ZEND_VERSION, ZTS_V, ZEND_DEBUG } #define STANDARD_ZEND_EXTENSION_PROPERTIES NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1 +#define COMPAT_ZEND_EXTENSION_PROPERTIES NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1 ZEND_API extern zend_llist zend_extensions;