1 /* 2 +----------------------------------------------------------------------+ 3 | PHP Version 5 | 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: Stig S�ther Bakken <ssb@php.net> | 16 | Andreas Karajannis <Andreas.Karajannis@gmd.de> | 17 | Kevin N. Shallow <kshallow@tampabay.rr.com> (Birdstep) | 18 +----------------------------------------------------------------------+ 19 */ 20 21 /* $Id$ */ 22 23 #ifndef PHP_ODBC_INCLUDES_H 24 #define PHP_ODBC_INCLUDES_H 25 26 #if HAVE_UODBC 27 28 #define ODBCVER 0x0250 29 /*#ifndef MSVC5 30 #define FAR 31 #endif 32 */ 33 34 /* checking in the same order as in configure.in */ 35 36 #if defined(HAVE_SOLID) || defined(HAVE_SOLID_30) || defined(HAVE_SOLID_35) /* Solid Server */ 37 38 #define ODBC_TYPE "Solid" 39 #if defined(HAVE_SOLID) 40 # include <cli0core.h> 41 # include <cli0ext1.h> 42 # include <cli0env.h> 43 #elif defined(HAVE_SOLID_30) 44 # include <cli0cli.h> 45 # include <cli0defs.h> 46 # include <cli0env.h> 47 #elif defined(HAVE_SOLID_35) 48 # if !defined(PHP_WIN32) 49 # include <sqlunix.h> 50 # endif /* end: #if !defined(PHP_WIN32) */ 51 # include <sqltypes.h> 52 # include <sqlucode.h> 53 # include <sqlext.h> 54 # include <sql.h> 55 #endif /* end: #if defined(HAVE_SOLID) */ 56 #undef HAVE_SQL_EXTENDED_FETCH 57 PHP_FUNCTION(solid_fetch_prev); 58 #define SQLSMALLINT SWORD 59 #define SQLUSMALLINT UWORD 60 #ifndef SQL_SUCCEEDED 61 #define SQL_SUCCEEDED(rc) (((rc)&(~1))==0) 62 #endif 63 64 #elif defined(HAVE_EMPRESS) /* Empress */ 65 66 #define ODBC_TYPE "Empress" 67 #include <sql.h> 68 #include <sqlext.h> 69 #undef HAVE_SQL_EXTENDED_FETCH 70 71 #elif defined(HAVE_ADABAS) /* Adabas D */ 72 73 #define ODBC_TYPE "Adabas D" 74 #include <WINDOWS.H> 75 #include <sql.h> 76 #include <sqlext.h> 77 #define HAVE_SQL_EXTENDED_FETCH 1 78 #define SQL_SUCCEEDED(rc) (((rc)&(~1))==0) 79 #define SQLINTEGER ULONG 80 #define SQLUSMALLINT USHORT 81 82 #elif defined(HAVE_SAPDB) /* SAP DB */ 83 84 #define ODBC_TYPE "SAP DB" 85 #include <WINDOWS.H> 86 #include <sql.h> 87 #include <sqlext.h> 88 #define HAVE_SQL_EXTENDED_FETCH 1 89 #define SQL_SUCCEEDED(rc) (((rc)&(~1))==0) 90 91 #elif defined(HAVE_IODBC) /* iODBC library */ 92 93 #ifdef CHAR 94 #undef CHAR 95 #endif 96 97 #ifdef SQLCHAR 98 #undef SQLCHAR 99 #endif 100 101 #define ODBC_TYPE "iODBC" 102 #include <sql.h> 103 #include <sqlext.h> 104 #include <iodbcext.h> 105 #define HAVE_SQL_EXTENDED_FETCH 1 106 107 #elif defined(HAVE_UNIXODBC) /* unixODBC library */ 108 109 #ifdef CHAR 110 #undef CHAR 111 #endif 112 113 #ifdef SQLCHAR 114 #undef SQLCHAR 115 #endif 116 117 #define ODBC_TYPE "unixODBC" 118 #undef ODBCVER 119 #include <sql.h> 120 #include <sqlext.h> 121 #define HAVE_SQL_EXTENDED_FETCH 1 122 123 #elif defined(HAVE_ESOOB) /* Easysoft ODBC-ODBC Bridge library */ 124 125 #define ODBC_TYPE "ESOOB" 126 #include <sql.h> 127 #include <sqlext.h> 128 #define HAVE_SQL_EXTENDED_FETCH 1 129 130 #elif defined(HAVE_ODBC_ROUTER) /* ODBCRouter.com */ 131 132 #ifdef CHAR 133 #undef CHAR 134 #endif 135 136 #ifdef SQLCHAR 137 #undef SQLCHAR 138 #endif 139 140 #define ODBC_TYPE "ODBCRouter" 141 #include <odbcsdk.h> 142 #undef HAVE_SQL_EXTENDED_FETCH 143 144 #elif defined(HAVE_OPENLINK) /* OpenLink ODBC drivers */ 145 146 #define ODBC_TYPE "Openlink" 147 #include <iodbc.h> 148 #include <isql.h> 149 #include <isqlext.h> 150 #include <udbcext.h> 151 #define HAVE_SQL_EXTENDED_FETCH 1 152 #ifndef SQLSMALLINT 153 #define SQLSMALLINT SWORD 154 #endif 155 #ifndef SQLUSMALLINT 156 #define SQLUSMALLINT UWORD 157 #endif 158 159 #elif defined(HAVE_BIRDSTEP) /* Raima Birdstep */ 160 161 #define ODBC_TYPE "Birdstep" 162 #define UNIX 163 /* 164 * Extended Fetch in the Birdstep ODBC API is incapable of returning long varchar (memo) fields. 165 * So the following line has been commented-out to accommodate. - KNS 166 * 167 * #define HAVE_SQL_EXTENDED_FETCH 1 168 */ 169 #include <sql.h> 170 #include <sqlext.h> 171 #define SQLINTEGER SDWORD 172 #define SQLSMALLINT SWORD 173 #define SQLUSMALLINT UWORD 174 175 176 #elif defined(HAVE_DBMAKER) /* DBMaker */ 177 178 #define ODBC_TYPE "DBMaker" 179 #undef ODBCVER 180 #define ODBCVER 0x0300 181 #define HAVE_SQL_EXTENDED_FETCH 1 182 #include <odbc.h> 183 184 185 #elif defined(HAVE_CODBC) /* Custom ODBC */ 186 187 #define ODBC_TYPE "Custom ODBC" 188 #define HAVE_SQL_EXTENDED_FETCH 1 189 #include <odbc.h> 190 191 #elif defined(HAVE_IBMDB2) /* DB2 CLI */ 192 193 #define ODBC_TYPE "IBM DB2 CLI" 194 #define HAVE_SQL_EXTENDED_FETCH 1 195 #include <sqlcli1.h> 196 #ifdef DB268K 197 /* Need to include ASLM for 68K applications */ 198 #include <LibraryManager.h> 199 #endif 200 201 #else /* MS ODBC */ 202 203 #define HAVE_SQL_EXTENDED_FETCH 1 204 #include <WINDOWS.H> 205 #include <sql.h> 206 #include <sqlext.h> 207 #endif 208 209 210 /* Common defines */ 211 212 #if defined( HAVE_IBMDB2 ) || defined( HAVE_UNIXODBC ) || defined (HAVE_IODBC) 213 #define ODBC_SQL_ENV_T SQLHANDLE 214 #define ODBC_SQL_CONN_T SQLHANDLE 215 #define ODBC_SQL_STMT_T SQLHANDLE 216 #elif defined( HAVE_SOLID_35 ) || defined( HAVE_SAPDB ) || defined ( HAVE_EMPRESS ) 217 #define ODBC_SQL_ENV_T SQLHENV 218 #define ODBC_SQL_CONN_T SQLHDBC 219 #define ODBC_SQL_STMT_T SQLHSTMT 220 #else 221 #define ODBC_SQL_ENV_T HENV 222 #define ODBC_SQL_CONN_T HDBC 223 #define ODBC_SQL_STMT_T HSTMT 224 #endif 225 226 typedef struct odbc_connection { 227 ODBC_SQL_ENV_T henv; 228 ODBC_SQL_CONN_T hdbc; 229 char laststate[6]; 230 char lasterrormsg[SQL_MAX_MESSAGE_LENGTH]; 231 int id; 232 int persistent; 233 } odbc_connection; 234 235 typedef struct odbc_result_value { 236 char name[256]; 237 char *value; 238 SQLLEN vallen; 239 SQLLEN coltype; 240 } odbc_result_value; 241 242 typedef struct odbc_result { 243 ODBC_SQL_STMT_T stmt; 244 odbc_result_value *values; 245 SQLSMALLINT numcols; 246 SQLSMALLINT numparams; 247 # if HAVE_SQL_EXTENDED_FETCH 248 int fetch_abs; 249 # endif 250 long longreadlen; 251 int binmode; 252 int fetched; 253 odbc_connection *conn_ptr; 254 } odbc_result; 255 256 ZEND_BEGIN_MODULE_GLOBALS(odbc) 257 char *defDB; 258 char *defUser; 259 char *defPW; 260 long allow_persistent; 261 long check_persistent; 262 long max_persistent; 263 long max_links; 264 long num_persistent; 265 long num_links; 266 int defConn; 267 long defaultlrl; 268 long defaultbinmode; 269 long default_cursortype; 270 char laststate[6]; 271 char lasterrormsg[SQL_MAX_MESSAGE_LENGTH]; 272 HashTable *resource_list; 273 HashTable *resource_plist; 274 ZEND_END_MODULE_GLOBALS(odbc) 275 276 int odbc_add_result(HashTable *list, odbc_result *result); 277 odbc_result *odbc_get_result(HashTable *list, int count); 278 void odbc_del_result(HashTable *list, int count); 279 int odbc_add_conn(HashTable *list, HDBC conn); 280 odbc_connection *odbc_get_conn(HashTable *list, int count); 281 void odbc_del_conn(HashTable *list, int ind); 282 int odbc_bindcols(odbc_result *result TSRMLS_DC); 283 284 #define ODBC_SQL_ERROR_PARAMS odbc_connection *conn_resource, ODBC_SQL_STMT_T stmt, char *func 285 286 void odbc_sql_error(ODBC_SQL_ERROR_PARAMS); 287 288 #if defined(ODBCVER) && (ODBCVER >= 0x0300) 289 #define IS_SQL_LONG(x) (x == SQL_LONGVARBINARY || x == SQL_LONGVARCHAR || x == SQL_WLONGVARCHAR) 290 #else 291 #define IS_SQL_LONG(x) (x == SQL_LONGVARBINARY || x == SQL_LONGVARCHAR) 292 #endif 293 #define IS_SQL_BINARY(x) (x == SQL_BINARY || x == SQL_VARBINARY || x == SQL_LONGVARBINARY) 294 295 #ifdef ZTS 296 # define ODBCG(v) TSRMG(odbc_globals_id, zend_odbc_globals *, v) 297 #else 298 # define ODBCG(v) (odbc_globals.v) 299 extern ZEND_API zend_odbc_globals odbc_globals; 300 #endif 301 302 #endif /* HAVE_UODBC */ 303 #endif /* PHP_ODBC_INCLUDES_H */ 304 305 /* 306 * Local variables: 307 * tab-width: 4 308 * c-basic-offset: 4 309 * End: 310 */ 311