1 /*
2   +----------------------------------------------------------------------+
3   | Copyright (c) The PHP Group                                          |
4   +----------------------------------------------------------------------+
5   | This source file is subject to version 3.01 of the PHP license,      |
6   | that is bundled with this package in the file LICENSE, and is        |
7   | available through the world-wide-web at the following url:           |
8   | http://www.php.net/license/3_01.txt                                  |
9   | If you did not receive a copy of the PHP license and are unable to   |
10   | obtain it through the world-wide-web, please send a note to          |
11   | license@php.net so we can mail you a copy immediately.               |
12   +----------------------------------------------------------------------+
13   | Author: Wez Furlong <wez@php.net>                                    |
14   +----------------------------------------------------------------------+
15 */
16 
17 #ifndef PHP_PDO_SQLITE_INT_H
18 #define PHP_PDO_SQLITE_INT_H
19 
20 #include <sqlite3.h>
21 
22 typedef struct {
23 	const char *file;
24 	int line;
25 	unsigned int errcode;
26 	char *errmsg;
27 } pdo_sqlite_error_info;
28 
29 struct pdo_sqlite_fci {
30 	zend_fcall_info fci;
31 	zend_fcall_info_cache fcc;
32 };
33 
34 struct pdo_sqlite_func {
35 	struct pdo_sqlite_func *next;
36 
37 	zval func, step, fini;
38 	int argc;
39 	const char *funcname;
40 
41 	/* accelerated callback references */
42 	struct pdo_sqlite_fci afunc, astep, afini;
43 };
44 
45 struct pdo_sqlite_collation {
46 	struct pdo_sqlite_collation *next;
47 
48 	const char *name;
49 	zval callback;
50 	struct pdo_sqlite_fci fc;
51 };
52 
53 typedef struct {
54 	sqlite3 *db;
55 	pdo_sqlite_error_info einfo;
56 	struct pdo_sqlite_func *funcs;
57 	struct pdo_sqlite_collation *collations;
58 } pdo_sqlite_db_handle;
59 
60 typedef struct {
61 	pdo_sqlite_db_handle 	*H;
62 	sqlite3_stmt *stmt;
63 	unsigned pre_fetched:1;
64 	unsigned done:1;
65 } pdo_sqlite_stmt;
66 
67 extern const pdo_driver_t pdo_sqlite_driver;
68 
69 extern int _pdo_sqlite_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int line);
70 #define pdo_sqlite_error(s) _pdo_sqlite_error(s, NULL, __FILE__, __LINE__)
71 #define pdo_sqlite_error_stmt(s) _pdo_sqlite_error(stmt->dbh, stmt, __FILE__, __LINE__)
72 
73 extern const struct pdo_stmt_methods sqlite_stmt_methods;
74 
75 enum {
76 	PDO_SQLITE_ATTR_OPEN_FLAGS = PDO_ATTR_DRIVER_SPECIFIC,
77 	PDO_SQLITE_ATTR_READONLY_STATEMENT,
78 	PDO_SQLITE_ATTR_EXTENDED_RESULT_CODES
79 };
80 
81 #endif
82