mysqlnd_ext_plugin.c 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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. /* $Id: mysqlnd.c 318221 2011-10-19 15:04:12Z andrey $ */
  21. #include "php.h"
  22. #include "mysqlnd.h"
  23. #include "mysqlnd_priv.h"
  24. #include "mysqlnd_result.h"
  25. #include "mysqlnd_debug.h"
  26. static struct st_mysqlnd_conn_methods * mysqlnd_conn_methods;
  27. static struct st_mysqlnd_conn_data_methods * mysqlnd_conn_data_methods;
  28. static struct st_mysqlnd_stmt_methods * mysqlnd_stmt_methods;
  29. /* {{{ _mysqlnd_plugin_get_plugin_connection_data */
  30. PHPAPI void **
  31. _mysqlnd_plugin_get_plugin_connection_data(const MYSQLND * conn, unsigned int plugin_id TSRMLS_DC)
  32. {
  33. DBG_ENTER("_mysqlnd_plugin_get_plugin_connection_data");
  34. DBG_INF_FMT("plugin_id=%u", plugin_id);
  35. if (!conn || plugin_id >= mysqlnd_plugin_count()) {
  36. return NULL;
  37. }
  38. DBG_RETURN((void *)((char *)conn + sizeof(MYSQLND) + plugin_id * sizeof(void *)));
  39. }
  40. /* }}} */
  41. /* {{{ _mysqlnd_plugin_get_plugin_connection_data_data */
  42. PHPAPI void **
  43. _mysqlnd_plugin_get_plugin_connection_data_data(const MYSQLND_CONN_DATA * conn, unsigned int plugin_id TSRMLS_DC)
  44. {
  45. DBG_ENTER("_mysqlnd_plugin_get_plugin_connection_data_data");
  46. DBG_INF_FMT("plugin_id=%u", plugin_id);
  47. if (!conn || plugin_id >= mysqlnd_plugin_count()) {
  48. return NULL;
  49. }
  50. DBG_RETURN((void *)((char *)conn + sizeof(MYSQLND_CONN_DATA) + plugin_id * sizeof(void *)));
  51. }
  52. /* }}} */
  53. /* {{{ _mysqlnd_plugin_get_plugin_result_data */
  54. PHPAPI void ** _mysqlnd_plugin_get_plugin_result_data(const MYSQLND_RES * result, unsigned int plugin_id TSRMLS_DC)
  55. {
  56. DBG_ENTER("_mysqlnd_plugin_get_plugin_result_data");
  57. DBG_INF_FMT("plugin_id=%u", plugin_id);
  58. if (!result || plugin_id >= mysqlnd_plugin_count()) {
  59. return NULL;
  60. }
  61. DBG_RETURN((void *)((char *)result + sizeof(MYSQLND_RES) + plugin_id * sizeof(void *)));
  62. }
  63. /* }}} */
  64. /* {{{ _mysqlnd_plugin_get_plugin_result_unbuffered_data */
  65. PHPAPI void ** _mysqlnd_plugin_get_plugin_result_unbuffered_data(const MYSQLND_RES_UNBUFFERED * result, unsigned int plugin_id TSRMLS_DC)
  66. {
  67. DBG_ENTER("_mysqlnd_plugin_get_plugin_result_data");
  68. DBG_INF_FMT("plugin_id=%u", plugin_id);
  69. if (!result || plugin_id >= mysqlnd_plugin_count()) {
  70. return NULL;
  71. }
  72. DBG_RETURN((void *)((char *)result + sizeof(MYSQLND_RES_UNBUFFERED) + plugin_id * sizeof(void *)));
  73. }
  74. /* }}} */
  75. /* {{{ _mysqlnd_plugin_get_plugin_result_buffered_data */
  76. PHPAPI void ** _mysqlnd_plugin_get_plugin_result_buffered_data_zval(const MYSQLND_RES_BUFFERED_ZVAL * result, unsigned int plugin_id TSRMLS_DC)
  77. {
  78. DBG_ENTER("_mysqlnd_plugin_get_plugin_result_data");
  79. DBG_INF_FMT("plugin_id=%u", plugin_id);
  80. if (!result || plugin_id >= mysqlnd_plugin_count()) {
  81. return NULL;
  82. }
  83. DBG_RETURN((void *)((char *)result + sizeof(MYSQLND_RES_BUFFERED_ZVAL) + plugin_id * sizeof(void *)));
  84. }
  85. /* }}} */
  86. /* {{{ _mysqlnd_plugin_get_plugin_result_buffered_data */
  87. PHPAPI void ** _mysqlnd_plugin_get_plugin_result_buffered_data_c(const MYSQLND_RES_BUFFERED_C * 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_C) + plugin_id * sizeof(void *)));
  95. }
  96. /* }}} */
  97. /* {{{ _mysqlnd_plugin_get_plugin_protocol_data */
  98. PHPAPI void **
  99. _mysqlnd_plugin_get_plugin_protocol_data(const MYSQLND_PROTOCOL * protocol, unsigned int plugin_id TSRMLS_DC)
  100. {
  101. DBG_ENTER("_mysqlnd_plugin_get_plugin_protocol_data");
  102. DBG_INF_FMT("plugin_id=%u", plugin_id);
  103. if (!protocol || plugin_id >= mysqlnd_plugin_count()) {
  104. return NULL;
  105. }
  106. DBG_RETURN((void *)((char *)protocol + sizeof(MYSQLND_PROTOCOL) + plugin_id * sizeof(void *)));
  107. }
  108. /* }}} */
  109. /* {{{ _mysqlnd_plugin_get_plugin_stmt_data */
  110. PHPAPI void ** _mysqlnd_plugin_get_plugin_stmt_data(const MYSQLND_STMT * stmt, unsigned int plugin_id TSRMLS_DC)
  111. {
  112. DBG_ENTER("_mysqlnd_plugin_get_plugin_stmt_data");
  113. DBG_INF_FMT("plugin_id=%u", plugin_id);
  114. if (!stmt || plugin_id >= mysqlnd_plugin_count()) {
  115. return NULL;
  116. }
  117. DBG_RETURN((void *)((char *)stmt + sizeof(MYSQLND_STMT) + plugin_id * sizeof(void *)));
  118. }
  119. /* }}} */
  120. /* {{{ _mysqlnd_plugin_get_plugin_net_data */
  121. PHPAPI void ** _mysqlnd_plugin_get_plugin_net_data(const MYSQLND_NET * net, unsigned int plugin_id TSRMLS_DC)
  122. {
  123. DBG_ENTER("_mysqlnd_plugin_get_plugin_net_data");
  124. DBG_INF_FMT("plugin_id=%u", plugin_id);
  125. if (!net || plugin_id >= mysqlnd_plugin_count()) {
  126. return NULL;
  127. }
  128. DBG_RETURN((void *)((char *)net + sizeof(MYSQLND_NET) + plugin_id * sizeof(void *)));
  129. }
  130. /* }}} */
  131. /* {{{ mysqlnd_conn_get_methods */
  132. PHPAPI struct st_mysqlnd_conn_methods *
  133. mysqlnd_conn_get_methods()
  134. {
  135. return mysqlnd_conn_methods;
  136. }
  137. /* }}} */
  138. /* {{{ mysqlnd_conn_set_methods */
  139. PHPAPI void mysqlnd_conn_set_methods(struct st_mysqlnd_conn_methods *methods)
  140. {
  141. mysqlnd_conn_methods = methods;
  142. }
  143. /* }}} */
  144. /* {{{ mysqlnd_conn_get_methods */
  145. PHPAPI struct st_mysqlnd_conn_data_methods *
  146. mysqlnd_conn_data_get_methods()
  147. {
  148. return mysqlnd_conn_data_methods;
  149. }
  150. /* }}} */
  151. /* {{{ mysqlnd_conn_set_methods */
  152. PHPAPI void mysqlnd_conn_data_set_methods(struct st_mysqlnd_conn_data_methods * methods)
  153. {
  154. mysqlnd_conn_data_methods = methods;
  155. }
  156. /* }}} */
  157. /* {{{ mysqlnd_result_get_methods */
  158. PHPAPI struct st_mysqlnd_res_methods *
  159. mysqlnd_result_get_methods()
  160. {
  161. return &MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_res);
  162. }
  163. /* }}} */
  164. /* {{{ mysqlnd_result_set_methods */
  165. PHPAPI void
  166. mysqlnd_result_set_methods(struct st_mysqlnd_res_methods * methods)
  167. {
  168. MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_res) = *methods;
  169. }
  170. /* }}} */
  171. /* {{{ mysqlnd_result_unbuffered_get_methods */
  172. PHPAPI struct st_mysqlnd_result_unbuffered_methods *
  173. mysqlnd_result_unbuffered_get_methods()
  174. {
  175. return &MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_result_unbuffered);
  176. }
  177. /* }}} */
  178. /* {{{ mysqlnd_result_unbuffered_set_methods */
  179. PHPAPI void
  180. mysqlnd_result_unbuffered_set_methods(struct st_mysqlnd_result_unbuffered_methods * methods)
  181. {
  182. MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_result_unbuffered) = *methods;
  183. }
  184. /* }}} */
  185. /* {{{ mysqlnd_result_buffered_get_methods */
  186. PHPAPI struct st_mysqlnd_result_buffered_methods *
  187. mysqlnd_result_buffered_get_methods()
  188. {
  189. return &MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_result_buffered);
  190. }
  191. /* }}} */
  192. /* {{{ mysqlnd_result_buffered_set_methods */
  193. PHPAPI void
  194. mysqlnd_result_buffered_set_methods(struct st_mysqlnd_result_buffered_methods * methods)
  195. {
  196. MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_result_buffered) = *methods;
  197. }
  198. /* }}} */
  199. /* {{{ mysqlnd_stmt_get_methods */
  200. PHPAPI struct st_mysqlnd_stmt_methods *
  201. mysqlnd_stmt_get_methods()
  202. {
  203. return mysqlnd_stmt_methods;
  204. }
  205. /* }}} */
  206. /* {{{ mysqlnd_stmt_set_methods */
  207. PHPAPI void
  208. mysqlnd_stmt_set_methods(struct st_mysqlnd_stmt_methods *methods)
  209. {
  210. mysqlnd_stmt_methods = methods;
  211. }
  212. /* }}} */
  213. /* {{{ mysqlnd_protocol_get_methods */
  214. PHPAPI struct st_mysqlnd_protocol_methods *
  215. mysqlnd_protocol_get_methods()
  216. {
  217. return &MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_protocol);
  218. }
  219. /* }}} */
  220. /* {{{ mysqlnd_protocol_set_methods */
  221. PHPAPI void
  222. mysqlnd_protocol_set_methods(struct st_mysqlnd_protocol_methods * methods)
  223. {
  224. MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_protocol) = *methods;
  225. }
  226. /* }}} */
  227. /* {{{ mysqlnd_net_get_methods */
  228. PHPAPI struct st_mysqlnd_net_methods *
  229. mysqlnd_net_get_methods()
  230. {
  231. return &MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_net);
  232. }
  233. /* }}} */
  234. /* {{{ mysqlnd_net_set_methods */
  235. PHPAPI void
  236. mysqlnd_net_set_methods(struct st_mysqlnd_net_methods * methods)
  237. {
  238. MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_net) = *methods;
  239. }
  240. /* }}} */
  241. /*
  242. * Local variables:
  243. * tab-width: 4
  244. * c-basic-offset: 4
  245. * End:
  246. * vim600: noet sw=4 ts=4 fdm=marker
  247. * vim<600: noet sw=4 ts=4
  248. */