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