xref: /PHP-7.0/Zend/zend_extensions.h (revision 478f119a)
1 /*
2    +----------------------------------------------------------------------+
3    | Zend Engine                                                          |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1998-2017 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 ZEND_EXTENSIONS_H
23 #define ZEND_EXTENSIONS_H
24 
25 #include "zend_compile.h"
26 #include "zend_build.h"
27 
28 /* The first number is the engine version and the rest is the date (YYYYMMDD).
29  * This way engine 2/3 API no. is always greater than engine 1 API no..
30  */
31 #define ZEND_EXTENSION_API_NO	320151012
32 
33 typedef struct _zend_extension_version_info {
34 	int zend_extension_api_no;
35 	char *build_id;
36 } zend_extension_version_info;
37 
38 #define ZEND_EXTENSION_BUILD_ID "API" ZEND_TOSTR(ZEND_EXTENSION_API_NO) ZEND_BUILD_TS ZEND_BUILD_DEBUG ZEND_BUILD_SYSTEM ZEND_BUILD_EXTRA
39 
40 typedef struct _zend_extension zend_extension;
41 
42 /* Typedef's for zend_extension function pointers */
43 typedef int (*startup_func_t)(zend_extension *extension);
44 typedef void (*shutdown_func_t)(zend_extension *extension);
45 typedef void (*activate_func_t)(void);
46 typedef void (*deactivate_func_t)(void);
47 
48 typedef void (*message_handler_func_t)(int message, void *arg);
49 
50 typedef void (*op_array_handler_func_t)(zend_op_array *op_array);
51 
52 typedef void (*statement_handler_func_t)(zend_op_array *op_array);
53 typedef void (*fcall_begin_handler_func_t)(zend_op_array *op_array);
54 typedef void (*fcall_end_handler_func_t)(zend_op_array *op_array);
55 
56 typedef void (*op_array_ctor_func_t)(zend_op_array *op_array);
57 typedef void (*op_array_dtor_func_t)(zend_op_array *op_array);
58 typedef size_t (*op_array_persist_calc_func_t)(zend_op_array *op_array);
59 typedef size_t (*op_array_persist_func_t)(zend_op_array *op_array, void *mem);
60 
61 struct _zend_extension {
62 	char *name;
63 	char *version;
64 	char *author;
65 	char *URL;
66 	char *copyright;
67 
68 	startup_func_t startup;
69 	shutdown_func_t shutdown;
70 	activate_func_t activate;
71 	deactivate_func_t deactivate;
72 
73 	message_handler_func_t message_handler;
74 
75 	op_array_handler_func_t op_array_handler;
76 
77 	statement_handler_func_t statement_handler;
78 	fcall_begin_handler_func_t fcall_begin_handler;
79 	fcall_end_handler_func_t fcall_end_handler;
80 
81 	op_array_ctor_func_t op_array_ctor;
82 	op_array_dtor_func_t op_array_dtor;
83 
84 	int (*api_no_check)(int api_no);
85 	int (*build_id_check)(const char* build_id);
86 	op_array_persist_calc_func_t op_array_persist_calc;
87 	op_array_persist_func_t op_array_persist;
88 	void *reserved5;
89 	void *reserved6;
90 	void *reserved7;
91 	void *reserved8;
92 
93 	DL_HANDLE handle;
94 	int resource_number;
95 };
96 
97 BEGIN_EXTERN_C()
98 ZEND_API int zend_get_resource_handle(zend_extension *extension);
99 ZEND_API void zend_extension_dispatch_message(int message, void *arg);
100 END_EXTERN_C()
101 
102 #define ZEND_EXTMSG_NEW_EXTENSION		1
103 
104 
105 #define ZEND_EXTENSION()	\
106 	ZEND_EXT_API zend_extension_version_info extension_version_info = { ZEND_EXTENSION_API_NO, ZEND_EXTENSION_BUILD_ID }
107 
108 #define STANDARD_ZEND_EXTENSION_PROPERTIES       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1
109 #define COMPAT_ZEND_EXTENSION_PROPERTIES         NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1
110 #define BUILD_COMPAT_ZEND_EXTENSION_PROPERTIES   NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1
111 
112 
113 ZEND_API extern zend_llist zend_extensions;
114 ZEND_API extern uint32_t zend_extension_flags;
115 
116 #define ZEND_EXTENSIONS_HAVE_OP_ARRAY_CTOR         (1<<0)
117 #define ZEND_EXTENSIONS_HAVE_OP_ARRAY_DTOR         (1<<1)
118 #define ZEND_EXTENSIONS_HAVE_OP_ARRAY_HANDLER      (1<<2)
119 #define ZEND_EXTENSIONS_HAVE_OP_ARRAY_PERSIST_CALC (1<<3)
120 #define ZEND_EXTENSIONS_HAVE_OP_ARRAY_PERSIST      (1<<4)
121 
122 void zend_extension_dtor(zend_extension *extension);
123 ZEND_API void zend_append_version_info(const zend_extension *extension);
124 int zend_startup_extensions_mechanism(void);
125 int zend_startup_extensions(void);
126 void zend_shutdown_extensions(void);
127 
128 BEGIN_EXTERN_C()
129 ZEND_API int zend_load_extension(const char *path);
130 ZEND_API int zend_register_extension(zend_extension *new_extension, DL_HANDLE handle);
131 ZEND_API zend_extension *zend_get_extension(const char *extension_name);
132 ZEND_API size_t zend_extensions_op_array_persist_calc(zend_op_array *op_array);
133 ZEND_API size_t zend_extensions_op_array_persist(zend_op_array *op_array, void *mem);
134 END_EXTERN_C()
135 
136 #endif /* ZEND_EXTENSIONS_H */
137 
138 /*
139  * Local variables:
140  * tab-width: 4
141  * c-basic-offset: 4
142  * indent-tabs-mode: t
143  * End:
144  */
145