root/ext/sqlite3/php_sqlite3_structs.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. php_sqlite3_db_from_obj
  2. php_sqlite3_result_from_obj
  3. php_sqlite3_stmt_from_obj

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

/* [<][>][^][v][top][bottom][index][help] */