xref: /php-src/ext/mysqlnd/mysqlnd_ext_plugin.h (revision c40231af)
1 /*
2   +----------------------------------------------------------------------+
3   | Copyright (c) The PHP Group                                          |
4   +----------------------------------------------------------------------+
5   | This source file is subject to version 3.01 of the PHP license,      |
6   | that is bundled with this package in the file LICENSE, and is        |
7   | available through the world-wide-web at the following url:           |
8   | https://www.php.net/license/3_01.txt                                 |
9   | If you did not receive a copy of the PHP license and are unable to   |
10   | obtain it through the world-wide-web, please send a note to          |
11   | license@php.net so we can mail you a copy immediately.               |
12   +----------------------------------------------------------------------+
13   | Authors: Andrey Hristov <andrey@php.net>                             |
14   |          Johannes Schlüter <johannes@php.net>                        |
15   |          Ulf Wendel <uw@php.net>                                     |
16   +----------------------------------------------------------------------+
17 */
18 
19 #ifndef MYSQLND_EXT_PLUGIN_H
20 #define MYSQLND_EXT_PLUGIN_H
21 
22 struct st_mysqlnd_plugin__plugin_area_getters
23 {
24 	void ** (*get_connection_area)(const MYSQLND * conn, const unsigned int plugin_id);
25 	void ** (*get_connection_data_area)(const MYSQLND_CONN_DATA * conn, const unsigned int plugin_id);
26 	void ** (*get_result_area)(const MYSQLND_RES * result, const unsigned int plugin_id);
27 	void ** (*get_unbuffered_area)(const MYSQLND_RES_UNBUFFERED * result, const unsigned int plugin_id);
28 	void ** (*get_result_buffered_aread)(const MYSQLND_RES_BUFFERED * result, const unsigned int plugin_id);
29 	void ** (*get_stmt_area)(const MYSQLND_STMT * stmt, const unsigned int plugin_id);
30 	void ** (*get_protocol_decoder_area)(const MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * factory, const unsigned int plugin_id);
31 	void ** (*get_pfc_area)(const MYSQLND_PFC * pfc, const unsigned int plugin_id);
32 	void ** (*get_vio_area)(const MYSQLND_VIO * vio, const unsigned int plugin_id);
33 };
34 
35 PHPAPI extern struct st_mysqlnd_plugin__plugin_area_getters mysqlnd_plugin_area_getters;
36 
37 #define mysqlnd_plugin_get_plugin_connection_data(c, p_id)				mysqlnd_plugin_area_getters.get_connection_area((c), (p_id))
38 #define mysqlnd_plugin_get_plugin_connection_data_data(c, p_id)			mysqlnd_plugin_area_getters.get_connection_data_area((c), (p_id))
39 #define mysqlnd_plugin_get_plugin_result_data(res, p_id)				mysqlnd_plugin_area_getters.get_result_area((res), (p_id))
40 #define mysqlnd_plugin_get_plugin_result_unbuffered_data(res, p_id)		mysqlnd_plugin_area_getters.get_unbuffered_area((res), (p_id))
41 #define mysqlnd_plugin_get_plugin_result_buffered_data_c(res, p_id)		mysqlnd_plugin_area_getters.get_result_buffered_aread((res), (p_id))
42 #define mysqlnd_plugin_get_plugin_stmt_data(stmt, p_id)					mysqlnd_plugin_area_getters.get_stmt_area((stmt), (p_id))
43 #define mysqlnd_plugin_get_plugin_protocol_data(proto, p_id)			mysqlnd_plugin_area_getters.get_protocol_decoder_area((proto), (p_id))
44 #define mysqlnd_plugin_get_plugin_pfc_data(pfc, p_id)					mysqlnd_plugin_area_getters.get_pfc_area((pfc), (p_id))
45 #define mysqlnd_plugin_get_plugin_vio_data(vio, p_id)					mysqlnd_plugin_area_getters.get_pfc_area((vio), (p_id))
46 
47 
48 struct st_mysqlnd_plugin_methods_xetters
49 {
50 	struct st_mnd_object_factory_xetters
51 	{
52 		MYSQLND_CLASS_METHODS_TYPE(mysqlnd_object_factory) * (*get)(void);
53 		void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_object_factory) *methods);
54 	} object_factory;
55 
56 	struct st_mnd_connection_xetters
57 	{
58 		MYSQLND_CLASS_METHODS_TYPE(mysqlnd_conn) * (*get)(void);
59 		void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_conn) *methods);
60 	} connection;
61 
62 	struct st_mnd_connection_data_xetters
63 	{
64 		MYSQLND_CLASS_METHODS_TYPE(mysqlnd_conn_data) * (*get)(void);
65 		void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_conn_data) *methods);
66 	} connection_data;
67 
68 	struct st_mnd_result_xetters
69 	{
70 		MYSQLND_CLASS_METHODS_TYPE(mysqlnd_res) * (*get)(void);
71 		void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_res) *methods);
72 	} result;
73 
74 	struct st_mnd_unbuffered_result_xetters
75 	{
76 		MYSQLND_CLASS_METHODS_TYPE(mysqlnd_result_unbuffered) * (*get)(void);
77 		void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_result_unbuffered) *methods);
78 	} unbuffered_result;
79 
80 	struct st_mnd_buffered_result_xetters
81 	{
82 		MYSQLND_CLASS_METHODS_TYPE(mysqlnd_result_buffered)* (*get)(void);
83 		void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_result_buffered) *methods);
84 	} buffered_result;
85 
86 	struct st_mnd_stmt_xetters
87 	{
88 		MYSQLND_CLASS_METHODS_TYPE(mysqlnd_stmt) * (*get)(void);
89 		void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_stmt) * methods);
90 	} statement;
91 
92 	struct st_mnd_protocol_xetters
93 	{
94 		MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_payload_decoder_factory)* (*get)(void);
95 		void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_payload_decoder_factory) *methods);
96 	} protocol;
97 
98 	struct st_mnd_pfc_xetters
99 	{
100 		MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_packet_frame_codec) * (*get)(void);
101 		void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_packet_frame_codec) * methods);
102 	} pfc;
103 
104 	struct st_mnd_vio_xetters
105 	{
106 		MYSQLND_CLASS_METHODS_TYPE(mysqlnd_vio) * (*get)(void);
107 		void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_vio) * methods);
108 	} vio;
109 
110 	struct st_mnd_error_info_xetters
111 	{
112 		MYSQLND_CLASS_METHODS_TYPE(mysqlnd_error_info) * (*get)(void);
113 		void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_error_info) * methods);
114 	} error_info;
115 
116 	struct st_mnd_command_xetters
117 	{
118 		MYSQLND_CLASS_METHODS_TYPE(mysqlnd_command) * (*get)(void);
119 		void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_command) * methods);
120 	} command;
121 };
122 
123 PHPAPI extern struct st_mysqlnd_plugin_methods_xetters mysqlnd_plugin_methods_xetters;
124 
125 
126 #define mysqlnd_object_factory_get_methods()	mysqlnd_plugin_methods_xetters.object_factory.get()
127 #define mysqlnd_object_factory_set_methods(m)	mysqlnd_plugin_methods_xetters.object_factory.set((m))
128 
129 #define mysqlnd_conn_get_methods()			mysqlnd_plugin_methods_xetters.connection.get()
130 #define mysqlnd_conn_set_methods(m)			mysqlnd_plugin_methods_xetters.connection.set((m))
131 
132 #define mysqlnd_conn_data_get_methods()		mysqlnd_plugin_methods_xetters.connection_data.get()
133 #define mysqlnd_conn_data_set_methods(m)	mysqlnd_plugin_methods_xetters.connection_data.set((m))
134 
135 #define mysqlnd_result_get_methods()		mysqlnd_plugin_methods_xetters.result.get()
136 #define mysqlnd_result_set_methods(m)		mysqlnd_plugin_methods_xetters.result.set((m))
137 
138 #define mysqlnd_result_unbuffered_get_methods()		mysqlnd_plugin_methods_xetters.unbuffered_result.get()
139 #define mysqlnd_result_unbuffered_set_methods(m)	mysqlnd_plugin_methods_xetters.unbuffered_result.set((m))
140 
141 #define mysqlnd_result_buffered_get_methods()		mysqlnd_plugin_methods_xetters.buffered_result.get()
142 #define mysqlnd_result_buffered_set_methods(m)		mysqlnd_plugin_methods_xetters.buffered_result.set((m))
143 
144 #define mysqlnd_stmt_get_methods()		mysqlnd_plugin_methods_xetters.statement.get()
145 #define mysqlnd_stmt_set_methods(m)		mysqlnd_plugin_methods_xetters.statement.set((m))
146 
147 #define mysqlnd_protocol_get_methods()	mysqlnd_plugin_methods_xetters.protocol.get()
148 #define mysqlnd_protocol_set_methods(m)	mysqlnd_plugin_methods_xetters.protocol.set((m))
149 
150 #define mysqlnd_pfc_get_methods()		mysqlnd_plugin_methods_xetters.pfc.get()
151 #define mysqlnd_pfc_set_methods(m)		mysqlnd_plugin_methods_xetters.pfc.set((m))
152 
153 #define mysqlnd_vio_get_methods()		mysqlnd_plugin_methods_xetters.vio.get()
154 #define mysqlnd_vio_set_methods(m)		mysqlnd_plugin_methods_xetters.vio.set((m))
155 
156 #define mysqlnd_command_get_methods()		mysqlnd_plugin_methods_xetters.command.get()
157 #define mysqlnd_command_set_methods(m)		mysqlnd_plugin_methods_xetters.command.set((m))
158 
159 #define mysqlnd_error_info_get_methods()	mysqlnd_plugin_methods_xetters.error_info.get()
160 #define mysqlnd_error_info_set_methods(m)	mysqlnd_plugin_methods_xetters.error_info.set((m))
161 
162 #endif	/* MYSQLND_EXT_PLUGIN_H */
163