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