-
Notifications
You must be signed in to change notification settings - Fork 14
/
pdo_ibm.c
200 lines (175 loc) · 6.38 KB
/
pdo_ibm.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/*
+----------------------------------------------------------------------+
| (C) Copyright IBM Corporation 2006. |
+----------------------------------------------------------------------+
| |
| Licensed under the Apache License, Version 2.0 (the "License"); you |
| may not use this file except in compliance with the License. You may |
| obtain a copy of the License at |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| implied. See the License for the specific language governing |
| permissions and limitations under the License. |
+----------------------------------------------------------------------+
| Authors: Rick McGuire, Dan Scott, Krishna Raman, Kellen Bombardier, |
| Ambrish Bhargava, Rahul Priyadarshi |
+----------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "pdo/php_pdo_driver.h"
#include "php_pdo_ibm.h"
#include "php_pdo_ibm_int.h"
/* If you declare any globals in php_pdo_ibm.h uncomment this:
*/
#ifdef PASE
ZEND_DECLARE_MODULE_GLOBALS(pdo_ibm)
#endif
/* True global resources - no need for thread safety here */
static int le_pdo_ibm;
extern pdo_driver_t pdo_ibm_driver; /* the registration table */
#ifdef PASE /* PASE i5/OS start-up */
#include <as400_protos.h>
#endif /* PASE */
/* {{{ pdo_ibm_deps
*/
#if ZEND_MODULE_API_NO >= 20041225
static zend_module_dep pdo_ibm_deps[] = {
ZEND_MOD_REQUIRED("pdo")
{NULL, NULL, NULL}
};
#endif
/* }}} */
/* {{{ pdo_ibm_module_entry
*/
zend_module_entry pdo_ibm_module_entry =
{
#if ZEND_MODULE_API_NO >= 20041225
STANDARD_MODULE_HEADER_EX, NULL,
pdo_ibm_deps,
#else
STANDARD_MODULE_HEADER,
#endif
"pdo_ibm",
NULL,
PHP_MINIT(pdo_ibm),
PHP_MSHUTDOWN(pdo_ibm),
PHP_RINIT(pdo_ibm), /* Replace with NULL if there's nothing to do at request start */
PHP_RSHUTDOWN(pdo_ibm), /* Replace with NULL if there's nothing to do at request end */
PHP_MINFO(pdo_ibm),
PDO_IBM_VERSION, /* Replace with version number for your extension */
STANDARD_MODULE_PROPERTIES
};
/* }}} */
#ifdef COMPILE_DL_PDO_IBM
ZEND_GET_MODULE(pdo_ibm)
#endif
/* {{{ PHP_INI
*/
#ifdef PASE /* i5/OS specific functions */
PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("pdo_ibm.i5_override_ccsid", "0", PHP_INI_SYSTEM, OnUpdateLong,
i5_override_ccsid, zend_pdo_ibm_globals, pdo_ibm_globals)
STD_PHP_INI_ENTRY("pdo_ibm.i5_dbcs_alloc", "0", PHP_INI_SYSTEM, OnUpdateLong,
i5_dbcs_alloc, zend_pdo_ibm_globals, pdo_ibm_globals)
PHP_INI_END()
#endif /* PASE */
#ifdef PASE /* prior any CLI routine override ascii ccsid */
/* {{{ php_pdo_ibm_init_globals
*/
static void php_pdo_ibm_init_globals(zend_pdo_ibm_globals *pdo_ibm_globals)
{
if (pdo_ibm_globals->i5_override_ccsid) {
/* This routine should be called by the application prior
* to any other CLI routine to override the ascii ccsid
* being retrieved from the Qp2RunPase() routine. If this
* routine is called after any CLI routine is called in
* the process it will have no effect.
*/
SQLOverrideCCSID400(pdo_ibm_globals->i5_override_ccsid);
}
}
/* }}} */
#endif /* PASE */
/* {{{ PHP_MINIT_FUNCTION
*/
PHP_MINIT_FUNCTION(pdo_ibm)
{
#ifdef PASE
/* Only PASE has INI entries right now. */
ZEND_INIT_MODULE_GLOBALS(pdo_ibm, php_pdo_ibm_init_globals, NULL);
REGISTER_INI_ENTRIES();
#endif
#ifndef PASE /* i5/OS no support trusted */
REGISTER_PDO_CLASS_CONST_LONG("SQL_ATTR_USE_TRUSTED_CONTEXT", (long) PDO_SQL_ATTR_USE_TRUSTED_CONTEXT);
REGISTER_PDO_CLASS_CONST_LONG("SQL_ATTR_TRUSTED_CONTEXT_USERID", (long) PDO_SQL_ATTR_TRUSTED_CONTEXT_USERID);
REGISTER_PDO_CLASS_CONST_LONG("SQL_ATTR_TRUSTED_CONTEXT_PASSWORD", (long) PDO_SQL_ATTR_TRUSTED_CONTEXT_PASSWORD);
#else /* PASE i5/OS introduced (1.3.4) */
REGISTER_PDO_CLASS_CONST_LONG("I5_ATTR_DBC_SYS_NAMING", (long)PDO_I5_ATTR_DBC_SYS_NAMING);
REGISTER_PDO_CLASS_CONST_LONG("I5_ATTR_COMMIT", (long)PDO_I5_ATTR_COMMIT);
REGISTER_PDO_CLASS_CONST_LONG("I5_TXN_NO_COMMIT", (long)PDO_I5_TXN_NO_COMMIT);
REGISTER_PDO_CLASS_CONST_LONG("I5_TXN_READ_UNCOMMITTED", (long)PDO_I5_TXN_READ_UNCOMMITTED);
REGISTER_PDO_CLASS_CONST_LONG("I5_TXN_READ_COMMITTED", (long)PDO_I5_TXN_READ_COMMITTED);
REGISTER_PDO_CLASS_CONST_LONG("I5_TXN_REPEATABLE_READ", (long)PDO_I5_TXN_REPEATABLE_READ);
REGISTER_PDO_CLASS_CONST_LONG("I5_TXN_SERIALIZABLE", (long)PDO_I5_TXN_SERIALIZABLE);
REGISTER_PDO_CLASS_CONST_LONG("I5_ATTR_JOB_SORT", (long)PDO_I5_ATTR_JOB_SORT);
REGISTER_PDO_CLASS_CONST_LONG("I5_ATTR_DBC_LIBL", (long)PDO_I5_ATTR_DBC_LIBL);
REGISTER_PDO_CLASS_CONST_LONG("I5_ATTR_DBC_CURLIB", (long)PDO_I5_ATTR_DBC_CURLIB);
#endif /* PASE */
/* Client information variables */
REGISTER_PDO_CLASS_CONST_LONG("SQL_ATTR_INFO_USERID", (long) PDO_SQL_ATTR_INFO_USERID);
REGISTER_PDO_CLASS_CONST_LONG("SQL_ATTR_INFO_ACCTSTR", (long) PDO_SQL_ATTR_INFO_ACCTSTR);
REGISTER_PDO_CLASS_CONST_LONG("SQL_ATTR_INFO_APPLNAME", (long) PDO_SQL_ATTR_INFO_APPLNAME);
REGISTER_PDO_CLASS_CONST_LONG("SQL_ATTR_INFO_WRKSTNNAME", (long) PDO_SQL_ATTR_INFO_WRKSTNNAME);
php_pdo_register_driver(&pdo_ibm_driver);
return TRUE;
}
/* }}} */
/* {{{ PHP_MSHUTDOWN_FUNCTION
*/
PHP_MSHUTDOWN_FUNCTION(pdo_ibm)
{
/* uncomment this line if you have INI entries
UNREGISTER_INI_ENTRIES();
*/
php_pdo_unregister_driver(&pdo_ibm_driver);
return TRUE;
}
/* }}} */
/* Remove if there's nothing to do at request start */
/* {{{ PHP_RINIT_FUNCTION
*/
PHP_RINIT_FUNCTION(pdo_ibm)
{
return TRUE;
}
/* }}} */
/* Remove if there's nothing to do at request end */
/* {{{ PHP_RSHUTDOWN_FUNCTION
*/
PHP_RSHUTDOWN_FUNCTION(pdo_ibm)
{
return TRUE;
}
/* }}} */
/* {{{ PHP_MINFO_FUNCTION
*/
PHP_MINFO_FUNCTION(pdo_ibm)
{
php_info_print_table_start();
php_info_print_table_header(2, "pdo_ibm support", "enabled");
php_info_print_table_row(2, "Module release", PDO_IBM_VERSION);
php_info_print_table_end();
#ifdef PASE
DISPLAY_INI_ENTRIES();
#endif
}
/* }}} */
/* }}} */