mysqlnd_reverse_api.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 317989 2011-10-10 20:49:28Z andrey $ */
  21. #include "php.h"
  22. #include "mysqlnd.h"
  23. #include "mysqlnd_priv.h"
  24. #include "mysqlnd_debug.h"
  25. #include "mysqlnd_reverse_api.h"
  26. static HashTable mysqlnd_api_ext_ht;
  27. /* {{{ mysqlnd_reverse_api_init */
  28. PHPAPI void
  29. mysqlnd_reverse_api_init(TSRMLS_D)
  30. {
  31. zend_hash_init(&mysqlnd_api_ext_ht, 3, NULL, NULL, 1);
  32. }
  33. /* }}} */
  34. /* {{{ mysqlnd_reverse_api_end */
  35. PHPAPI void
  36. mysqlnd_reverse_api_end(TSRMLS_D)
  37. {
  38. zend_hash_destroy(&mysqlnd_api_ext_ht);
  39. }
  40. /* }}} */
  41. /* {{{ myslqnd_get_api_extensions */
  42. PHPAPI HashTable *
  43. mysqlnd_reverse_api_get_api_list(TSRMLS_D)
  44. {
  45. return &mysqlnd_api_ext_ht;
  46. }
  47. /* }}} */
  48. /* {{{ mysqlnd_reverse_api_register_api */
  49. PHPAPI void
  50. mysqlnd_reverse_api_register_api(MYSQLND_REVERSE_API * apiext TSRMLS_DC)
  51. {
  52. zend_hash_add(&mysqlnd_api_ext_ht, apiext->module->name, strlen(apiext->module->name) + 1, &apiext,
  53. sizeof(MYSQLND_REVERSE_API *), NULL);
  54. }
  55. /* }}} */
  56. /* {{{ zval_to_mysqlnd */
  57. PHPAPI MYSQLND *
  58. zval_to_mysqlnd(zval * zv, const unsigned int client_api_capabilities, unsigned int * save_client_api_capabilities TSRMLS_DC)
  59. {
  60. MYSQLND * retval;
  61. MYSQLND_REVERSE_API ** elem;
  62. for (zend_hash_internal_pointer_reset(&mysqlnd_api_ext_ht);
  63. zend_hash_get_current_data(&mysqlnd_api_ext_ht, (void **)&elem) == SUCCESS;
  64. zend_hash_move_forward(&mysqlnd_api_ext_ht))
  65. {
  66. if ((*elem)->conversion_cb) {
  67. retval = (*elem)->conversion_cb(zv TSRMLS_CC);
  68. if (retval) {
  69. if (retval->data) {
  70. *save_client_api_capabilities = retval->data->m->negotiate_client_api_capabilities(retval->data, client_api_capabilities TSRMLS_CC);
  71. }
  72. return retval;
  73. }
  74. }
  75. }
  76. return NULL;
  77. }
  78. /* }}} */
  79. /*
  80. * Local variables:
  81. * tab-width: 4
  82. * c-basic-offset: 4
  83. * End:
  84. * vim600: noet sw=4 ts=4 fdm=marker
  85. * vim<600: noet sw=4 ts=4
  86. */