You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

151 lines
4.1 KiB

18 years ago
12 years ago
18 years ago
12 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 7 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2014 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: Scott MacVicar <scottmac@php.net> |
  16. +----------------------------------------------------------------------+
  17. */
  18. /* $Id$ */
  19. #ifndef PHP_SQLITE_STRUCTS_H
  20. #define PHP_SQLITE_STRUCTS_H
  21. #include <sqlite3.h>
  22. /* for backwards compatibility reasons */
  23. #ifndef SQLITE_OPEN_READONLY
  24. #define SQLITE_OPEN_READONLY 0x00000001
  25. #endif
  26. #ifndef SQLITE_OPEN_READWRITE
  27. #define SQLITE_OPEN_READWRITE 0x00000002
  28. #endif
  29. #ifndef SQLITE_OPEN_CREATE
  30. #define SQLITE_OPEN_CREATE 0x00000004
  31. #endif
  32. /* Structure for SQLite Statement Parameter. */
  33. struct php_sqlite3_bound_param {
  34. zend_long param_number;
  35. zend_string *name;
  36. zend_long type;
  37. zval parameter;
  38. };
  39. struct php_sqlite3_fci {
  40. zend_fcall_info fci;
  41. zend_fcall_info_cache fcc;
  42. };
  43. /* Structure for SQLite function. */
  44. typedef struct _php_sqlite3_func {
  45. struct _php_sqlite3_func *next;
  46. const char *func_name;
  47. int argc;
  48. zval func, step, fini;
  49. struct php_sqlite3_fci afunc, astep, afini;
  50. } php_sqlite3_func;
  51. /* Structure for SQLite collation function */
  52. typedef struct _php_sqlite3_collation {
  53. struct _php_sqlite3_collation *next;
  54. const char *collation_name;
  55. zval cmp_func;
  56. struct php_sqlite3_fci fci;
  57. } php_sqlite3_collation;
  58. /* Structure for SQLite Database object. */
  59. typedef struct _php_sqlite3_db_object {
  60. int initialised;
  61. sqlite3 *db;
  62. php_sqlite3_func *funcs;
  63. php_sqlite3_collation *collations;
  64. zend_bool exception;
  65. zend_llist free_list;
  66. zend_object zo;
  67. } php_sqlite3_db_object;
  68. static inline php_sqlite3_db_object *php_sqlite3_db_from_obj(zend_object *obj) {
  69. return (php_sqlite3_db_object*)((char*)(obj) - XtOffsetOf(php_sqlite3_db_object, zo));
  70. }
  71. #define Z_SQLITE3_DB_P(zv) php_sqlite3_db_from_obj(Z_OBJ_P((zv)))
  72. /* Structure for SQLite Database object. */
  73. typedef struct _php_sqlite3_agg_context {
  74. zval zval_context;
  75. zend_long row_count;
  76. } php_sqlite3_agg_context;
  77. typedef struct _php_sqlite3_stmt_object php_sqlite3_stmt;
  78. typedef struct _php_sqlite3_result_object php_sqlite3_result;
  79. /* sqlite3 objects to be destroyed */
  80. typedef struct _php_sqlite3_free_list {
  81. zval stmt_obj_zval;
  82. php_sqlite3_stmt *stmt_obj;
  83. } php_sqlite3_free_list;
  84. /* Structure for SQLite Result object. */
  85. struct _php_sqlite3_result_object {
  86. php_sqlite3_db_object *db_obj;
  87. php_sqlite3_stmt *stmt_obj;
  88. zval stmt_obj_zval;
  89. int is_prepared_statement;
  90. int complete;
  91. zend_object zo;
  92. };
  93. static inline php_sqlite3_result *php_sqlite3_result_from_obj(zend_object *obj) {
  94. return (php_sqlite3_result*)((char*)(obj) - XtOffsetOf(php_sqlite3_result, zo));
  95. }
  96. #define Z_SQLITE3_RESULT_P(zv) php_sqlite3_result_from_obj(Z_OBJ_P((zv)))
  97. /* Structure for SQLite Statement object. */
  98. struct _php_sqlite3_stmt_object {
  99. sqlite3_stmt *stmt;
  100. php_sqlite3_db_object *db_obj;
  101. zval db_obj_zval;
  102. int initialised;
  103. /* Keep track of the zvals for bound parameters */
  104. HashTable *bound_params;
  105. zend_object zo;
  106. };
  107. static inline php_sqlite3_stmt *php_sqlite3_stmt_from_obj(zend_object *obj) {
  108. return (php_sqlite3_stmt*)((char*)(obj) - XtOffsetOf(php_sqlite3_stmt, zo));
  109. }
  110. #define Z_SQLITE3_STMT_P(zv) php_sqlite3_stmt_from_obj(Z_OBJ_P((zv)))
  111. #endif
  112. /*
  113. * Local variables:
  114. * tab-width: 4
  115. * c-basic-offset: 4
  116. * indent-tabs-mode: t
  117. * End:
  118. */