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 | Author: Ard Biesheuvel <abies@php.net> |
16 +----------------------------------------------------------------------+
17 */
18
19 #ifndef PHP_PDO_FIREBIRD_INT_H
20 #define PHP_PDO_FIREBIRD_INT_H
21
22 #include <ibase.h>
23
24 #ifdef SQLDA_VERSION
25 #define PDO_FB_SQLDA_VERSION SQLDA_VERSION
26 #else
27 #define PDO_FB_SQLDA_VERSION 1
28 #endif
29
30 #define PDO_FB_DIALECT 3
31
32 #define PDO_FB_DEF_DATE_FMT "%Y-%m-%d"
33 #define PDO_FB_DEF_TIME_FMT "%H:%M:%S"
34 #define PDO_FB_DEF_TIMESTAMP_FMT PDO_FB_DEF_DATE_FMT " " PDO_FB_DEF_TIME_FMT
35
36 #define SHORT_MAX (1 << (8*sizeof(short)-1))
37
38 #if SIZEOF_ZEND_LONG == 8 && !defined(PHP_WIN32)
39 # define LL_MASK "l"
40 # define LL_LIT(lit) lit ## L
41 #else
42 # ifdef PHP_WIN32
43 # define LL_MASK "I64"
44 # define LL_LIT(lit) lit ## I64
45 # else
46 # define LL_MASK "ll"
47 # define LL_LIT(lit) lit ## LL
48 # endif
49 #endif
50
51 /* Firebird API has a couple of missing const decls in its API */
52 #define const_cast(s) ((char*)(s))
53
54 #ifdef PHP_WIN32
55 typedef void (__stdcall *info_func_t)(char*);
56 #else
57 typedef void (*info_func_t)(char*);
58 #endif
59
60 #ifndef min
61 #define min(a,b) ((a)<(b)?(a):(b))
62 #endif
63
64 typedef struct {
65
66 /* the result of the last API call */
67 ISC_STATUS isc_status[20];
68
69 /* the connection handle */
70 isc_db_handle db;
71
72 /* the transaction handle */
73 isc_tr_handle tr;
74
75 /* the last error that didn't come from the API */
76 char const *last_app_error;
77
78 /* date and time format strings, can be set by the set_attribute method */
79 char *date_format;
80 char *time_format;
81 char *timestamp_format;
82
83 /* prepend table names on column names in fetch */
84 unsigned fetch_table_names:1;
85
86 unsigned _reserved:31;
87
88 } pdo_firebird_db_handle;
89
90
91 typedef struct {
92
93 /* the link that owns this statement */
94 pdo_firebird_db_handle *H;
95
96 /* the statement handle */
97 isc_stmt_handle stmt;
98
99 /* the name of the cursor (if it has one) */
100 char name[32];
101
102 /* the type of statement that was issued */
103 char statement_type:8;
104
105 /* whether EOF was reached for this statement */
106 unsigned exhausted:1;
107
108 /* successful isc_dsql_execute opens a cursor */
109 unsigned cursor_open:1;
110
111 unsigned _reserved:22;
112
113 /* the named params that were converted to ?'s by the driver */
114 HashTable *named_params;
115
116 /* allocated space to convert fields values to other types */
117 char **fetch_buf;
118
119 /* the input SQLDA */
120 XSQLDA *in_sqlda;
121
122 /* the output SQLDA */
123 XSQLDA out_sqlda; /* last member */
124
125 } pdo_firebird_stmt;
126
127 extern pdo_driver_t pdo_firebird_driver;
128
129 extern struct pdo_stmt_methods firebird_stmt_methods;
130
131 void _firebird_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, char const *file, zend_long line);
132
133 enum {
134 PDO_FB_ATTR_DATE_FORMAT = PDO_ATTR_DRIVER_SPECIFIC,
135 PDO_FB_ATTR_TIME_FORMAT,
136 PDO_FB_ATTR_TIMESTAMP_FORMAT,
137 };
138
139 #endif /* PHP_PDO_FIREBIRD_INT_H */
140
141 /*
142 * Local variables:
143 * tab-width: 4
144 * c-basic-offset: 4
145 * End:
146 * vim600: noet sw=4 ts=4 fdm=marker
147 * vim<600: noet sw=4 ts=4
148 */