From bfbe86187e594ac1cc67518b4f1fc54e1cbacba8 Mon Sep 17 00:00:00 2001 From: Zeev Suraski Date: Sun, 9 May 1999 12:24:21 +0000 Subject: [PATCH] Almost forgot to commit those --- Zend/zend.c | 6 ++++++ Zend/zend_API.c | 20 +++++++++++++++++--- Zend/zend_API.h | 3 ++- Zend/zend_modules.h | 11 +++++++---- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/Zend/zend.c b/Zend/zend.c index b6f81a69cc7..70e65349ed2 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -204,12 +204,14 @@ static void compiler_globals_dtor(zend_compiler_globals *compiler_globals) static void executor_globals_ctor(zend_executor_globals *executor_globals) { zend_startup_constants(ELS_C); + init_resource_plist(ELS_C); } static void executor_globals_dtor(zend_executor_globals *executor_globals) { zend_shutdown_constants(ELS_C); + destroy_resource_plist(); } @@ -275,7 +277,9 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions) compiler_globals->class_table = GLOBAL_CLASS_TABLE; #endif +#ifndef ZTS init_resource_plist(ELS_C); +#endif return SUCCESS; } @@ -283,7 +287,9 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions) void zend_shutdown() { +#ifndef ZTS destroy_resource_plist(); +#endif zend_hash_destroy(&list_destructors); zend_hash_destroy(&module_registry); zend_hash_destroy(GLOBAL_FUNCTION_TABLE); diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 4b1ac8e2ba0..49ed26dbe95 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -675,7 +675,7 @@ ZEND_API int zend_register_module(zend_module_entry *module) #if 0 zend_printf("%s: Registering module %d\n",module->name, module->module_number); #endif - if (zend_register_functions(module->functions)==FAILURE) { + if (module->functions && zend_register_functions(module->functions)==FAILURE) { zend_error(E_CORE_WARNING,"%s: Unable to register functions, unable to load",module->name); return FAILURE; } @@ -705,7 +705,9 @@ void module_destructor(zend_module_entry *module) module->module_shutdown_func(module->type, module->module_number); } module->module_started=0; - zend_unregister_functions(module->functions,-1); + if (module->functions) { + zend_unregister_functions(module->functions,-1); + } #if HAVE_LIBDL if (module->handle) { @@ -760,7 +762,7 @@ int zend_next_free_module(void) } -zend_class_entry *register_internal_class(zend_class_entry *class_entry) +ZEND_API zend_class_entry *register_internal_class(zend_class_entry *class_entry) { zend_class_entry *register_class; char *lowercase_name = zend_strndup(class_entry->name, class_entry->name_length); @@ -779,3 +781,15 @@ zend_class_entry *register_internal_class(zend_class_entry *class_entry) free(lowercase_name); return register_class; } + + +ZEND_API zend_module_entry *zend_get_module(int module_number) +{ + zend_module_entry *module; + + if (zend_hash_index_find(&module_registry, module_number, (void **) &module)==SUCCESS) { + return module; + } else { + return NULL; + } +} diff --git a/Zend/zend_API.h b/Zend/zend_API.h index ddc17f88070..8df14d2a04b 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -41,7 +41,8 @@ ZEND_API int ParameterPassedByReference(int ht, uint n); int zend_register_functions(zend_function_entry *functions); void zend_unregister_functions(zend_function_entry *functions, int count); ZEND_API int zend_register_module(zend_module_entry *module_entry); -zend_class_entry *register_internal_class(zend_class_entry *class_entry); +ZEND_API zend_class_entry *register_internal_class(zend_class_entry *class_entry); +ZEND_API zend_module_entry *zend_get_module(int module_number); ZEND_API void wrong_param_count(void); diff --git a/Zend/zend_modules.h b/Zend/zend_modules.h index f4805f06630..b0838953ec2 100644 --- a/Zend/zend_modules.h +++ b/Zend/zend_modules.h @@ -19,6 +19,7 @@ #define INIT_FUNC_ARGS int type, int module_number #define SHUTDOWN_FUNC_ARGS int type, int module_number +#define ZEND_MODULE_INFO_FUNC_ARGS zend_module_entry *module #define STANDARD_MODULE_PROPERTIES 0, 0, 0, NULL, 0 @@ -26,19 +27,21 @@ #define MODULE_PERSISTENT 1 #define MODULE_TEMPORARY 2 -typedef struct { +typedef struct _zend_module_entry zend_module_entry; + +struct _zend_module_entry { char *name; zend_function_entry *functions; int (*module_startup_func)(INIT_FUNC_ARGS); int (*module_shutdown_func)(SHUTDOWN_FUNC_ARGS); int (*request_startup_func)(INIT_FUNC_ARGS); int (*request_shutdown_func)(SHUTDOWN_FUNC_ARGS); - void (*info_func)(void); - int request_started,module_started; + void (*info_func)(ZEND_MODULE_INFO_FUNC_ARGS); + int request_started, module_started; unsigned char type; void *handle; int module_number; -} zend_module_entry; +}; extern HashTable module_registry;