1573b4602SAndi Gutmans/*
2573b4602SAndi Gutmans   +----------------------------------------------------------------------+
3573b4602SAndi Gutmans   | Zend Engine                                                          |
4573b4602SAndi Gutmans   +----------------------------------------------------------------------+
5a6519d05SXinchen Hui   | Copyright (c) 1998-2018 Zend Technologies Ltd. (http://www.zend.com) |
6573b4602SAndi Gutmans   +----------------------------------------------------------------------+
7d863d52aSSebastian Bergmann   | This source file is subject to version 2.00 of the Zend license,     |
8637a4042SMarcus Boerger   | that is bundled with this package in the file LICENSE, and is        |
9f68c7ff2SJames Cox   | available through the world-wide-web at the following url:           |
10d863d52aSSebastian Bergmann   | http://www.zend.com/license/2_00.txt.                                |
11b5b11177SZeev Suraski   | If you did not receive a copy of the Zend license and are unable to  |
12b5b11177SZeev Suraski   | obtain it through the world-wide-web, please send a note to          |
13b5b11177SZeev Suraski   | license@zend.com so we can mail you a copy immediately.              |
14573b4602SAndi Gutmans   +----------------------------------------------------------------------+
159afce019SZeev Suraski   | Authors: Andi Gutmans <andi@php.net>                                 |
169afce019SZeev Suraski   |          Zeev Suraski <zeev@php.net>                                 |
17573b4602SAndi Gutmans   +----------------------------------------------------------------------+
18573b4602SAndi Gutmans*/
19573b4602SAndi Gutmans
20b982307dSSascha Schumann#ifndef MODULES_H
21b982307dSSascha Schumann#define MODULES_H
22573b4602SAndi Gutmans
237513a2f9SAndi Gutmans#include "zend.h"
24d608f1a0SAnantha Kesari H Y#include "zend_compile.h"
255d8c9f8cSStanislav Malyshev#include "zend_build.h"
26de9206a9SAndi Gutmans
27e112f6a0SAnatol Belski#define INIT_FUNC_ARGS		int type, int module_number
28e112f6a0SAnatol Belski#define INIT_FUNC_ARGS_PASSTHRU	type, module_number
29e112f6a0SAnatol Belski#define SHUTDOWN_FUNC_ARGS	int type, int module_number
30e112f6a0SAnatol Belski#define SHUTDOWN_FUNC_ARGS_PASSTHRU type, module_number
31e112f6a0SAnatol Belski#define ZEND_MODULE_INFO_FUNC_ARGS zend_module_entry *zend_module
32e112f6a0SAnatol Belski#define ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU zend_module
33573b4602SAndi Gutmans
34144e8d1fSChristoph M. Becker#define ZEND_MODULE_API_NO 20180731
353bd9e023SAndi Gutmans#ifdef ZTS
363bd9e023SAndi Gutmans#define USING_ZTS 1
373bd9e023SAndi Gutmans#else
383bd9e023SAndi Gutmans#define USING_ZTS 0
393bd9e023SAndi Gutmans#endif
403bd9e023SAndi Gutmans
41c0c7a9f0SDmitry Stogov#define STANDARD_MODULE_HEADER_EX sizeof(zend_module_entry), ZEND_MODULE_API_NO, ZEND_DEBUG, USING_ZTS
42c0c7a9f0SDmitry Stogov#define STANDARD_MODULE_HEADER \
43c0c7a9f0SDmitry Stogov	STANDARD_MODULE_HEADER_EX, NULL, NULL
44c0c7a9f0SDmitry Stogov#define ZE2_STANDARD_MODULE_HEADER \
45c0c7a9f0SDmitry Stogov	STANDARD_MODULE_HEADER_EX, ini_entries, NULL
4601850714SSebastian Bergmann
475d8c9f8cSStanislav Malyshev#define ZEND_MODULE_BUILD_ID "API" ZEND_TOSTR(ZEND_MODULE_API_NO) ZEND_BUILD_TS ZEND_BUILD_DEBUG ZEND_BUILD_SYSTEM ZEND_BUILD_EXTRA
485d8c9f8cSStanislav Malyshev
495d8c9f8cSStanislav Malyshev#define STANDARD_MODULE_PROPERTIES_EX 0, 0, NULL, 0, ZEND_MODULE_BUILD_ID
50ada4e506SDmitry Stogov
511757bf88SAntony Dovgal#define NO_MODULE_GLOBALS 0, NULL, NULL, NULL
52ada4e506SDmitry Stogov
53ada4e506SDmitry Stogov#ifdef ZTS
54d11734b4SAnatol Belski# define ZEND_MODULE_GLOBALS(module_name) sizeof(zend_##module_name##_globals), &module_name##_globals_id
55ada4e506SDmitry Stogov#else
56ada4e506SDmitry Stogov# define ZEND_MODULE_GLOBALS(module_name) sizeof(zend_##module_name##_globals), &module_name##_globals
57ada4e506SDmitry Stogov#endif
58573b4602SAndi Gutmans
59690575e5SSascha Schumann#define STANDARD_MODULE_PROPERTIES \
601757bf88SAntony Dovgal	NO_MODULE_GLOBALS, NULL, STANDARD_MODULE_PROPERTIES_EX
61573b4602SAndi Gutmans
6201850714SSebastian Bergmann#define NO_VERSION_YET NULL
6301850714SSebastian Bergmann
64573b4602SAndi Gutmans#define MODULE_PERSISTENT 1
65573b4602SAndi Gutmans#define MODULE_TEMPORARY 2
66573b4602SAndi Gutmans
672f7f1dd1SHarald Radistruct _zend_ini_entry;
68bfbe8618SZeev Suraskitypedef struct _zend_module_entry zend_module_entry;
69c0c7a9f0SDmitry Stogovtypedef struct _zend_module_dep zend_module_dep;
70bfbe8618SZeev Suraski
71bfbe8618SZeev Suraskistruct _zend_module_entry {
72c0c7a9f0SDmitry Stogov	unsigned short size;
7301850714SSebastian Bergmann	unsigned int zend_api;
7401850714SSebastian Bergmann	unsigned char zend_debug;
7501850714SSebastian Bergmann	unsigned char zts;
766c810b0dSDmitry Stogov	const struct _zend_ini_entry *ini_entry;
776c810b0dSDmitry Stogov	const struct _zend_module_dep *deps;
786c810b0dSDmitry Stogov	const char *name;
796c810b0dSDmitry Stogov	const struct _zend_function_entry *functions;
80573b4602SAndi Gutmans	int (*module_startup_func)(INIT_FUNC_ARGS);
819d8e0db3SZeev Suraski	int (*module_shutdown_func)(SHUTDOWN_FUNC_ARGS);
82573b4602SAndi Gutmans	int (*request_startup_func)(INIT_FUNC_ARGS);
839d8e0db3SZeev Suraski	int (*request_shutdown_func)(SHUTDOWN_FUNC_ARGS);
84bfbe8618SZeev Suraski	void (*info_func)(ZEND_MODULE_INFO_FUNC_ARGS);
856c810b0dSDmitry Stogov	const char *version;
86ada4e506SDmitry Stogov	size_t globals_size;
87ada4e506SDmitry Stogov#ifdef ZTS
88ada4e506SDmitry Stogov	ts_rsrc_id* globals_id_ptr;
89ada4e506SDmitry Stogov#else
90ada4e506SDmitry Stogov	void* globals_ptr;
91ada4e506SDmitry Stogov#endif
92bdeb220fSAnatol Belski	void (*globals_ctor)(void *global);
93bdeb220fSAnatol Belski	void (*globals_dtor)(void *global);
946535933fSDerick Rethans	int (*post_deactivate_func)(void);
9594b51198SZeev Suraski	int module_started;
96573b4602SAndi Gutmans	unsigned char type;
97573b4602SAndi Gutmans	void *handle;
98573b4602SAndi Gutmans	int module_number;
99aaa2f1c3SHartmut Holzgraefe	const char *build_id;
100bfbe8618SZeev Suraski};
101573b4602SAndi Gutmans
102c0c7a9f0SDmitry Stogov#define MODULE_DEP_REQUIRED		1
103c0c7a9f0SDmitry Stogov#define MODULE_DEP_CONFLICTS	2
104c0c7a9f0SDmitry Stogov#define MODULE_DEP_OPTIONAL		3
105c0c7a9f0SDmitry Stogov
106c0c7a9f0SDmitry Stogov#define ZEND_MOD_REQUIRED_EX(name, rel, ver)	{ name, rel, ver, MODULE_DEP_REQUIRED  },
107c0c7a9f0SDmitry Stogov#define ZEND_MOD_CONFLICTS_EX(name, rel, ver)	{ name, rel, ver, MODULE_DEP_CONFLICTS },
108c0c7a9f0SDmitry Stogov#define ZEND_MOD_OPTIONAL_EX(name, rel, ver)	{ name, rel, ver, MODULE_DEP_OPTIONAL  },
109c0c7a9f0SDmitry Stogov
110c0c7a9f0SDmitry Stogov#define ZEND_MOD_REQUIRED(name)		ZEND_MOD_REQUIRED_EX(name, NULL, NULL)
111c0c7a9f0SDmitry Stogov#define ZEND_MOD_CONFLICTS(name)	ZEND_MOD_CONFLICTS_EX(name, NULL, NULL)
112c0c7a9f0SDmitry Stogov#define ZEND_MOD_OPTIONAL(name)		ZEND_MOD_OPTIONAL_EX(name, NULL, NULL)
113c0c7a9f0SDmitry Stogov
1149480eaceSFelipe Pena#define ZEND_MOD_END { NULL, NULL, NULL, 0 }
1159480eaceSFelipe Pena
116c0c7a9f0SDmitry Stogovstruct _zend_module_dep {
1176c810b0dSDmitry Stogov	const char *name;		/* module name */
1186c810b0dSDmitry Stogov	const char *rel;		/* version relationship: NULL (exists), lt|le|eq|ge|gt (to given version) */
1196c810b0dSDmitry Stogov	const char *version;	/* version */
1206c810b0dSDmitry Stogov	unsigned char type;		/* dependency type */
121c0c7a9f0SDmitry Stogov};
122573b4602SAndi Gutmans
123c71b773aSAnatol BelskiBEGIN_EXTERN_C()
1242946f87fSAndi Gutmansextern ZEND_API HashTable module_registry;
125573b4602SAndi Gutmans
1263feb4b3bSZeev Suraskivoid module_destructor(zend_module_entry *module);
127bdeb220fSAnatol Belskiint module_registry_request_startup(zend_module_entry *module);
128bdeb220fSAnatol Belskiint module_registry_unload_temp(const zend_module_entry *module);
129c71b773aSAnatol BelskiEND_EXTERN_C()
130573b4602SAndi Gutmans
131573b4602SAndi Gutmans#endif
132333406bdSfoobar
133333406bdSfoobar/*
134333406bdSfoobar * Local variables:
135333406bdSfoobar * tab-width: 4
136333406bdSfoobar * c-basic-offset: 4
137333406bdSfoobar * indent-tabs-mode: t
138333406bdSfoobar * End:
139bc5811f3SAnatol Belski * vim600: sw=4 ts=4 fdm=marker
140bc5811f3SAnatol Belski * vim<600: sw=4 ts=4
141333406bdSfoobar */
142