1 /* 2 +----------------------------------------------------------------------+ 3 | Zend Engine | 4 +----------------------------------------------------------------------+ 5 | Copyright (c) 1998-2018 Zend Technologies Ltd. (http://www.zend.com) | 6 +----------------------------------------------------------------------+ 7 | This source file is subject to version 2.00 of the Zend license, | 8 | that is bundled with this package in the file LICENSE, and is | 9 | available through the world-wide-web at the following url: | 10 | http://www.zend.com/license/2_00.txt. | 11 | If you did not receive a copy of the Zend license and are unable to | 12 | obtain it through the world-wide-web, please send a note to | 13 | license@zend.com so we can mail you a copy immediately. | 14 +----------------------------------------------------------------------+ 15 | Authors: Andi Gutmans <andi@zend.com> | 16 | Zeev Suraski <zeev@zend.com> | 17 +----------------------------------------------------------------------+ 18 */ 19 20 /* $Id$ */ 21 22 #ifndef MODULES_H 23 #define MODULES_H 24 25 #include "zend.h" 26 #include "zend_compile.h" 27 #include "zend_build.h" 28 29 #define INIT_FUNC_ARGS int type, int module_number 30 #define INIT_FUNC_ARGS_PASSTHRU type, module_number 31 #define SHUTDOWN_FUNC_ARGS int type, int module_number 32 #define SHUTDOWN_FUNC_ARGS_PASSTHRU type, module_number 33 #define ZEND_MODULE_INFO_FUNC_ARGS zend_module_entry *zend_module 34 #define ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU zend_module 35 36 #define ZEND_MODULE_API_NO 20170718 37 #ifdef ZTS 38 #define USING_ZTS 1 39 #else 40 #define USING_ZTS 0 41 #endif 42 43 #define STANDARD_MODULE_HEADER_EX sizeof(zend_module_entry), ZEND_MODULE_API_NO, ZEND_DEBUG, USING_ZTS 44 #define STANDARD_MODULE_HEADER \ 45 STANDARD_MODULE_HEADER_EX, NULL, NULL 46 #define ZE2_STANDARD_MODULE_HEADER \ 47 STANDARD_MODULE_HEADER_EX, ini_entries, NULL 48 49 #define ZEND_MODULE_BUILD_ID "API" ZEND_TOSTR(ZEND_MODULE_API_NO) ZEND_BUILD_TS ZEND_BUILD_DEBUG ZEND_BUILD_SYSTEM ZEND_BUILD_EXTRA 50 51 #define STANDARD_MODULE_PROPERTIES_EX 0, 0, NULL, 0, ZEND_MODULE_BUILD_ID 52 53 #define NO_MODULE_GLOBALS 0, NULL, NULL, NULL 54 55 #ifdef ZTS 56 # define ZEND_MODULE_GLOBALS(module_name) sizeof(zend_##module_name##_globals), &module_name##_globals_id 57 #else 58 # define ZEND_MODULE_GLOBALS(module_name) sizeof(zend_##module_name##_globals), &module_name##_globals 59 #endif 60 61 #define STANDARD_MODULE_PROPERTIES \ 62 NO_MODULE_GLOBALS, NULL, STANDARD_MODULE_PROPERTIES_EX 63 64 #define NO_VERSION_YET NULL 65 66 #define MODULE_PERSISTENT 1 67 #define MODULE_TEMPORARY 2 68 69 struct _zend_ini_entry; 70 typedef struct _zend_module_entry zend_module_entry; 71 typedef struct _zend_module_dep zend_module_dep; 72 73 struct _zend_module_entry { 74 unsigned short size; 75 unsigned int zend_api; 76 unsigned char zend_debug; 77 unsigned char zts; 78 const struct _zend_ini_entry *ini_entry; 79 const struct _zend_module_dep *deps; 80 const char *name; 81 const struct _zend_function_entry *functions; 82 int (*module_startup_func)(INIT_FUNC_ARGS); 83 int (*module_shutdown_func)(SHUTDOWN_FUNC_ARGS); 84 int (*request_startup_func)(INIT_FUNC_ARGS); 85 int (*request_shutdown_func)(SHUTDOWN_FUNC_ARGS); 86 void (*info_func)(ZEND_MODULE_INFO_FUNC_ARGS); 87 const char *version; 88 size_t globals_size; 89 #ifdef ZTS 90 ts_rsrc_id* globals_id_ptr; 91 #else 92 void* globals_ptr; 93 #endif 94 void (*globals_ctor)(void *global); 95 void (*globals_dtor)(void *global); 96 int (*post_deactivate_func)(void); 97 int module_started; 98 unsigned char type; 99 void *handle; 100 int module_number; 101 const char *build_id; 102 }; 103 104 #define MODULE_DEP_REQUIRED 1 105 #define MODULE_DEP_CONFLICTS 2 106 #define MODULE_DEP_OPTIONAL 3 107 108 #define ZEND_MOD_REQUIRED_EX(name, rel, ver) { name, rel, ver, MODULE_DEP_REQUIRED }, 109 #define ZEND_MOD_CONFLICTS_EX(name, rel, ver) { name, rel, ver, MODULE_DEP_CONFLICTS }, 110 #define ZEND_MOD_OPTIONAL_EX(name, rel, ver) { name, rel, ver, MODULE_DEP_OPTIONAL }, 111 112 #define ZEND_MOD_REQUIRED(name) ZEND_MOD_REQUIRED_EX(name, NULL, NULL) 113 #define ZEND_MOD_CONFLICTS(name) ZEND_MOD_CONFLICTS_EX(name, NULL, NULL) 114 #define ZEND_MOD_OPTIONAL(name) ZEND_MOD_OPTIONAL_EX(name, NULL, NULL) 115 116 #define ZEND_MOD_END { NULL, NULL, NULL, 0 } 117 118 struct _zend_module_dep { 119 const char *name; /* module name */ 120 const char *rel; /* version relationship: NULL (exists), lt|le|eq|ge|gt (to given version) */ 121 const char *version; /* version */ 122 unsigned char type; /* dependency type */ 123 }; 124 125 BEGIN_EXTERN_C() 126 extern ZEND_API HashTable module_registry; 127 128 void module_destructor(zend_module_entry *module); 129 int module_registry_request_startup(zend_module_entry *module); 130 int module_registry_unload_temp(const zend_module_entry *module); 131 END_EXTERN_C() 132 133 #endif 134 135 /* 136 * Local variables: 137 * tab-width: 4 138 * c-basic-offset: 4 139 * indent-tabs-mode: t 140 * End: 141 * vim600: sw=4 ts=4 fdm=marker 142 * vim<600: sw=4 ts=4 143 */ 144