xref: /PHP-5.3/ext/pdo_dblib/php_pdo_dblib_int.h (revision a2045ff3)
1 /*
2   +----------------------------------------------------------------------+
3   | PHP Version 5                                                        |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 1997-2013 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: Wez Furlong <wez@php.net>                                    |
16   |         Frank M. Kromann <frank@kromann.info>                        |
17   +----------------------------------------------------------------------+
18 */
19 
20 /* $Id$ */
21 
22 #ifndef PHP_PDO_DBLIB_INT_H
23 #define PHP_PDO_DBLIB_INT_H
24 
25 #ifndef PDO_DBLIB_FLAVOUR
26 # define PDO_DBLIB_FLAVOUR "Generic DB-lib"
27 #endif
28 
29 #if PHP_DBLIB_IS_MSSQL
30 # include <sqlfront.h>
31 # include <sqldb.h>
32 
33 # define DBERRHANDLE(a, b)	dbprocerrhandle(a, b)
34 # define DBMSGHANDLE(a, b)	dbprocmsghandle(a, b)
35 # define EHANDLEFUNC		DBERRHANDLE_PROC
36 # define MHANDLEFUNC		DBMSGHANDLE_PROC
37 # define DBSETOPT(a, b, c)	dbsetopt(a, b, c)
38 # define SYBESMSG		SQLESMSG
39 # define SYBESEOF		SQLESEOF
40 # define SYBEFCON		SQLECONN		// SQLEFCON does not exist in MS SQL Server.
41 # define SYBEMEM		SQLEMEM
42 # define SYBEPWD		SQLEPWD
43 
44 #else
45 # include <sybfront.h>
46 # include <sybdb.h>
47 # include <syberror.h>
48 
49 /* alias some types */
50 # define SQLTEXT	SYBTEXT
51 # define SQLCHAR	SYBCHAR
52 # define SQLVARCHAR	SYBVARCHAR
53 # define SQLINT1	SYBINT1
54 # define SQLINT2	SYBINT2
55 # define SQLINT4	SYBINT4
56 # define SQLINTN	SYBINTN
57 # define SQLBIT		SYBBIT
58 # define SQLFLT4	SYBREAL
59 # define SQLFLT8	SYBFLT8
60 # define SQLFLTN	SYBFLTN
61 # define SQLDECIMAL	SYBDECIMAL
62 # define SQLNUMERIC	SYBNUMERIC
63 # define SQLDATETIME	SYBDATETIME
64 # define SQLDATETIM4	SYBDATETIME4
65 # define SQLDATETIMN	SYBDATETIMN
66 # define SQLMONEY		SYBMONEY
67 # define SQLMONEY4		SYBMONEY4
68 # define SQLMONEYN		SYBMONEYN
69 # define SQLIMAGE		SYBIMAGE
70 # define SQLBINARY		SYBBINARY
71 # define SQLVARBINARY	SYBVARBINARY
72 # ifdef SYBUNIQUE
73 #  define SQLUNIQUE		SYBUNIQUE
74 # endif
75 
76 # define DBERRHANDLE(a, b)	dberrhandle(b)
77 # define DBMSGHANDLE(a, b)	dbmsghandle(b)
78 # define DBSETOPT(a, b, c)	dbsetopt(a, b, c, -1)
79 # define NO_MORE_RPC_RESULTS	3
80 # define dbfreelogin		dbloginfree
81 # define dbrpcexec			dbrpcsend
82 
83 typedef short TDS_SHORT;
84 # ifndef PHP_WIN32
85 typedef unsigned char *LPBYTE;
86 # endif
87 typedef float			DBFLT4;
88 #endif
89 
90 int error_handler(DBPROCESS *dbproc, int severity, int dberr,
91 	int oserr, char *dberrstr, char *oserrstr);
92 
93 int msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate,
94 	int severity, char *msgtext, char *srvname, char *procname, DBUSMALLINT line);
95 
96 extern pdo_driver_t pdo_dblib_driver;
97 extern struct pdo_stmt_methods dblib_stmt_methods;
98 
99 typedef struct {
100 	int severity;
101 	int oserr;
102 	int dberr;
103 	char *oserrstr;
104 	char *dberrstr;
105 	char *sqlstate;
106 	char *lastmsg;
107 } pdo_dblib_err;
108 
109 typedef struct {
110 	LOGINREC	*login;
111 	DBPROCESS	*link;
112 
113 	pdo_dblib_err err;
114 } pdo_dblib_db_handle;
115 
116 typedef struct {
117 	int coltype;
118 	char *name;
119 	int maxlen;
120 	char *source;
121 } pdo_dblib_col;
122 
123 typedef struct {
124 	unsigned long len;
125 	char *data;
126 } pdo_dblib_colval;
127 
128 typedef struct {
129 	pdo_dblib_db_handle *H;
130 
131 	int ncols;
132 	pdo_dblib_col *cols;
133 
134 	pdo_dblib_colval *rows;
135 	int nrows;
136 
137 	int current;
138 
139 	pdo_dblib_err err;
140 } pdo_dblib_stmt;
141 
142 ZEND_BEGIN_MODULE_GLOBALS(dblib)
143 	pdo_dblib_err err;
144 	char sqlstate[6];
145 ZEND_END_MODULE_GLOBALS(dblib)
146 
147 #ifdef ZTS
148 # define DBLIB_G(v) TSRMG(dblib_globals_id, zend_dblib_globals *, v)
149 #else
150 # define DBLIB_G(v) (dblib_globals.v)
151 #endif
152 
153 ZEND_EXTERN_MODULE_GLOBALS(dblib);
154 
155 #endif
156 
157