xref: /PHP-7.0/ext/mysqlnd/mysqlnd_ext_plugin.c (revision 478f119a)
1 /*
2   +----------------------------------------------------------------------+
3   | PHP Version 7                                                        |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 2006-2017 The PHP Group                                |
6   +----------------------------------------------------------------------+
7   | This source file is subject to version 3.01 of the PHP 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.php.net/license/3_01.txt                                  |
11   | If you did not receive a copy of the PHP license and are unable to   |
12   | obtain it through the world-wide-web, please send a note to          |
13   | license@php.net so we can mail you a copy immediately.               |
14   +----------------------------------------------------------------------+
15   | Authors: Andrey Hristov <andrey@php.net>                             |
16   |          Ulf Wendel <uw@php.net>                                     |
17   |          Georg Richter <georg@php.net>                               |
18   +----------------------------------------------------------------------+
19 */
20 
21 #include "php.h"
22 #include "mysqlnd.h"
23 #include "mysqlnd_priv.h"
24 #include "mysqlnd_result.h"
25 #include "mysqlnd_debug.h"
26 
27 static struct st_mysqlnd_conn_methods * mysqlnd_conn_methods;
28 static struct st_mysqlnd_conn_data_methods * mysqlnd_conn_data_methods;
29 static struct st_mysqlnd_stmt_methods * mysqlnd_stmt_methods;
30 
31 /* {{{ _mysqlnd_plugin_get_plugin_connection_data */
32 PHPAPI void **
_mysqlnd_plugin_get_plugin_connection_data(const MYSQLND * conn,unsigned int plugin_id)33 _mysqlnd_plugin_get_plugin_connection_data(const MYSQLND * conn, unsigned int plugin_id)
34 {
35 	DBG_ENTER("_mysqlnd_plugin_get_plugin_connection_data");
36 	DBG_INF_FMT("plugin_id=%u", plugin_id);
37 	if (!conn || plugin_id >= mysqlnd_plugin_count()) {
38 		return NULL;
39 	}
40 	DBG_RETURN((void *)((char *)conn + sizeof(MYSQLND) + plugin_id * sizeof(void *)));
41 }
42 /* }}} */
43 
44 
45 /* {{{ _mysqlnd_plugin_get_plugin_connection_data_data */
46 PHPAPI void **
_mysqlnd_plugin_get_plugin_connection_data_data(const MYSQLND_CONN_DATA * conn,unsigned int plugin_id)47 _mysqlnd_plugin_get_plugin_connection_data_data(const MYSQLND_CONN_DATA * conn, unsigned int plugin_id)
48 {
49 	DBG_ENTER("_mysqlnd_plugin_get_plugin_connection_data_data");
50 	DBG_INF_FMT("plugin_id=%u", plugin_id);
51 	if (!conn || plugin_id >= mysqlnd_plugin_count()) {
52 		return NULL;
53 	}
54 	DBG_RETURN((void *)((char *)conn + sizeof(MYSQLND_CONN_DATA) + plugin_id * sizeof(void *)));
55 }
56 /* }}} */
57 
58 
59 /* {{{ _mysqlnd_plugin_get_plugin_result_data */
_mysqlnd_plugin_get_plugin_result_data(const MYSQLND_RES * result,unsigned int plugin_id)60 PHPAPI void ** _mysqlnd_plugin_get_plugin_result_data(const MYSQLND_RES * result, unsigned int plugin_id)
61 {
62 	DBG_ENTER("_mysqlnd_plugin_get_plugin_result_data");
63 	DBG_INF_FMT("plugin_id=%u", plugin_id);
64 	if (!result || plugin_id >= mysqlnd_plugin_count()) {
65 		return NULL;
66 	}
67 	DBG_RETURN((void *)((char *)result + sizeof(MYSQLND_RES) + plugin_id * sizeof(void *)));
68 }
69 /* }}} */
70 
71 
72 /* {{{ _mysqlnd_plugin_get_plugin_result_unbuffered_data */
_mysqlnd_plugin_get_plugin_result_unbuffered_data(const MYSQLND_RES_UNBUFFERED * result,unsigned int plugin_id)73 PHPAPI void ** _mysqlnd_plugin_get_plugin_result_unbuffered_data(const MYSQLND_RES_UNBUFFERED * result, unsigned int plugin_id)
74 {
75 	DBG_ENTER("_mysqlnd_plugin_get_plugin_result_data");
76 	DBG_INF_FMT("plugin_id=%u", plugin_id);
77 	if (!result || plugin_id >= mysqlnd_plugin_count()) {
78 		return NULL;
79 	}
80 	DBG_RETURN((void *)((char *)result + sizeof(MYSQLND_RES_UNBUFFERED) + plugin_id * sizeof(void *)));
81 }
82 /* }}} */
83 
84 
85 /* {{{ _mysqlnd_plugin_get_plugin_result_buffered_data */
_mysqlnd_plugin_get_plugin_result_buffered_data_zval(const MYSQLND_RES_BUFFERED_ZVAL * result,unsigned int plugin_id)86 PHPAPI void ** _mysqlnd_plugin_get_plugin_result_buffered_data_zval(const MYSQLND_RES_BUFFERED_ZVAL * result, unsigned int plugin_id)
87 {
88 	DBG_ENTER("_mysqlnd_plugin_get_plugin_result_data");
89 	DBG_INF_FMT("plugin_id=%u", plugin_id);
90 	if (!result || plugin_id >= mysqlnd_plugin_count()) {
91 		return NULL;
92 	}
93 	DBG_RETURN((void *)((char *)result + sizeof(MYSQLND_RES_BUFFERED_ZVAL) + plugin_id * sizeof(void *)));
94 }
95 /* }}} */
96 
97 /* {{{ _mysqlnd_plugin_get_plugin_result_buffered_data */
_mysqlnd_plugin_get_plugin_result_buffered_data_c(const MYSQLND_RES_BUFFERED_C * result,unsigned int plugin_id)98 PHPAPI void ** _mysqlnd_plugin_get_plugin_result_buffered_data_c(const MYSQLND_RES_BUFFERED_C * result, unsigned int plugin_id)
99 {
100 	DBG_ENTER("_mysqlnd_plugin_get_plugin_result_data");
101 	DBG_INF_FMT("plugin_id=%u", plugin_id);
102 	if (!result || plugin_id >= mysqlnd_plugin_count()) {
103 		return NULL;
104 	}
105 	DBG_RETURN((void *)((char *)result + sizeof(MYSQLND_RES_BUFFERED_C) + plugin_id * sizeof(void *)));
106 }
107 /* }}} */
108 
109 
110 /* {{{ _mysqlnd_plugin_get_plugin_protocol_data */
111 PHPAPI void **
_mysqlnd_plugin_get_plugin_protocol_data(const MYSQLND_PROTOCOL * protocol,unsigned int plugin_id)112 _mysqlnd_plugin_get_plugin_protocol_data(const MYSQLND_PROTOCOL * protocol, unsigned int plugin_id)
113 {
114 	DBG_ENTER("_mysqlnd_plugin_get_plugin_protocol_data");
115 	DBG_INF_FMT("plugin_id=%u", plugin_id);
116 	if (!protocol || plugin_id >= mysqlnd_plugin_count()) {
117 		return NULL;
118 	}
119 	DBG_RETURN((void *)((char *)protocol + sizeof(MYSQLND_PROTOCOL) + plugin_id * sizeof(void *)));
120 }
121 /* }}} */
122 
123 
124 /* {{{ _mysqlnd_plugin_get_plugin_stmt_data */
_mysqlnd_plugin_get_plugin_stmt_data(const MYSQLND_STMT * stmt,unsigned int plugin_id)125 PHPAPI void ** _mysqlnd_plugin_get_plugin_stmt_data(const MYSQLND_STMT * stmt, unsigned int plugin_id)
126 {
127 	DBG_ENTER("_mysqlnd_plugin_get_plugin_stmt_data");
128 	DBG_INF_FMT("plugin_id=%u", plugin_id);
129 	if (!stmt || plugin_id >= mysqlnd_plugin_count()) {
130 		return NULL;
131 	}
132 	DBG_RETURN((void *)((char *)stmt + sizeof(MYSQLND_STMT) + plugin_id * sizeof(void *)));
133 }
134 /* }}} */
135 
136 
137 /* {{{ _mysqlnd_plugin_get_plugin_net_data */
_mysqlnd_plugin_get_plugin_net_data(const MYSQLND_NET * net,unsigned int plugin_id)138 PHPAPI void ** _mysqlnd_plugin_get_plugin_net_data(const MYSQLND_NET * net, unsigned int plugin_id)
139 {
140 	DBG_ENTER("_mysqlnd_plugin_get_plugin_net_data");
141 	DBG_INF_FMT("plugin_id=%u", plugin_id);
142 	if (!net || plugin_id >= mysqlnd_plugin_count()) {
143 		return NULL;
144 	}
145 	DBG_RETURN((void *)((char *)net + sizeof(MYSQLND_NET) + plugin_id * sizeof(void *)));
146 }
147 /* }}} */
148 
149 
150 
151 /* {{{ mysqlnd_conn_get_methods */
152 PHPAPI struct st_mysqlnd_conn_methods *
mysqlnd_conn_get_methods()153 mysqlnd_conn_get_methods()
154 {
155 	return mysqlnd_conn_methods;
156 }
157 /* }}} */
158 
159 /* {{{ mysqlnd_conn_set_methods */
mysqlnd_conn_set_methods(struct st_mysqlnd_conn_methods * methods)160 PHPAPI void mysqlnd_conn_set_methods(struct st_mysqlnd_conn_methods *methods)
161 {
162 	mysqlnd_conn_methods = methods;
163 }
164 /* }}} */
165 
166 
167 /* {{{ mysqlnd_conn_get_methods */
168 PHPAPI struct st_mysqlnd_conn_data_methods *
mysqlnd_conn_data_get_methods()169 mysqlnd_conn_data_get_methods()
170 {
171 	return mysqlnd_conn_data_methods;
172 }
173 /* }}} */
174 
175 /* {{{ mysqlnd_conn_set_methods */
mysqlnd_conn_data_set_methods(struct st_mysqlnd_conn_data_methods * methods)176 PHPAPI void mysqlnd_conn_data_set_methods(struct st_mysqlnd_conn_data_methods * methods)
177 {
178 	mysqlnd_conn_data_methods = methods;
179 }
180 /* }}} */
181 
182 
183 /* {{{ mysqlnd_result_get_methods */
184 PHPAPI struct st_mysqlnd_res_methods *
mysqlnd_result_get_methods()185 mysqlnd_result_get_methods()
186 {
187 	return &MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_res);
188 }
189 /* }}} */
190 
191 
192 /* {{{ mysqlnd_result_set_methods */
193 PHPAPI void
mysqlnd_result_set_methods(struct st_mysqlnd_res_methods * methods)194 mysqlnd_result_set_methods(struct st_mysqlnd_res_methods * methods)
195 {
196 	MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_res) = *methods;
197 }
198 /* }}} */
199 
200 
201 /* {{{ mysqlnd_result_unbuffered_get_methods */
202 PHPAPI struct st_mysqlnd_result_unbuffered_methods *
mysqlnd_result_unbuffered_get_methods()203 mysqlnd_result_unbuffered_get_methods()
204 {
205 	return &MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_result_unbuffered);
206 }
207 /* }}} */
208 
209 
210 /* {{{ mysqlnd_result_unbuffered_set_methods */
211 PHPAPI void
mysqlnd_result_unbuffered_set_methods(struct st_mysqlnd_result_unbuffered_methods * methods)212 mysqlnd_result_unbuffered_set_methods(struct st_mysqlnd_result_unbuffered_methods * methods)
213 {
214 	MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_result_unbuffered) = *methods;
215 }
216 /* }}} */
217 
218 
219 /* {{{ mysqlnd_result_buffered_get_methods */
220 PHPAPI struct st_mysqlnd_result_buffered_methods *
mysqlnd_result_buffered_get_methods()221 mysqlnd_result_buffered_get_methods()
222 {
223 	return &MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_result_buffered);
224 }
225 /* }}} */
226 
227 
228 /* {{{ mysqlnd_result_buffered_set_methods */
229 PHPAPI void
mysqlnd_result_buffered_set_methods(struct st_mysqlnd_result_buffered_methods * methods)230 mysqlnd_result_buffered_set_methods(struct st_mysqlnd_result_buffered_methods * methods)
231 {
232 	MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_result_buffered) = *methods;
233 }
234 /* }}} */
235 
236 
237 /* {{{ mysqlnd_stmt_get_methods */
238 PHPAPI struct st_mysqlnd_stmt_methods *
mysqlnd_stmt_get_methods()239 mysqlnd_stmt_get_methods()
240 {
241 	return mysqlnd_stmt_methods;
242 }
243 /* }}} */
244 
245 
246 /* {{{ mysqlnd_stmt_set_methods */
247 PHPAPI void
mysqlnd_stmt_set_methods(struct st_mysqlnd_stmt_methods * methods)248 mysqlnd_stmt_set_methods(struct st_mysqlnd_stmt_methods *methods)
249 {
250 	mysqlnd_stmt_methods = methods;
251 }
252 /* }}} */
253 
254 
255 /* {{{ mysqlnd_protocol_get_methods */
256 PHPAPI struct st_mysqlnd_protocol_methods *
mysqlnd_protocol_get_methods()257 mysqlnd_protocol_get_methods()
258 {
259 	return &MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_protocol);
260 }
261 /* }}} */
262 
263 
264 /* {{{ mysqlnd_protocol_set_methods */
265 PHPAPI void
mysqlnd_protocol_set_methods(struct st_mysqlnd_protocol_methods * methods)266 mysqlnd_protocol_set_methods(struct st_mysqlnd_protocol_methods * methods)
267 {
268 	MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_protocol) = *methods;
269 }
270 /* }}} */
271 
272 
273 /* {{{ mysqlnd_net_get_methods */
274 PHPAPI struct st_mysqlnd_net_methods *
mysqlnd_net_get_methods()275 mysqlnd_net_get_methods()
276 {
277 	return &MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_net);
278 }
279 /* }}} */
280 
281 
282 /* {{{ mysqlnd_net_set_methods */
283 PHPAPI void
mysqlnd_net_set_methods(struct st_mysqlnd_net_methods * methods)284 mysqlnd_net_set_methods(struct st_mysqlnd_net_methods * methods)
285 {
286 	MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_net) = *methods;
287 }
288 /* }}} */
289 
290 
291 /*
292  * Local variables:
293  * tab-width: 4
294  * c-basic-offset: 4
295  * End:
296  * vim600: noet sw=4 ts=4 fdm=marker
297  * vim<600: noet sw=4 ts=4
298  */
299