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 | https://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 #ifdef HAVE_CONFIG_H
18 #include "config.h"
19 #endif
20
21 #include "php.h"
22 #include "php_ini.h"
23 #include "ext/standard/info.h"
24 #include "pdo/php_pdo.h"
25 #include "pdo/php_pdo_driver.h"
26 #include "php_pdo_firebird.h"
27 #include "php_pdo_firebird_int.h"
28 #include "pdo_firebird_arginfo.h"
29
30 static zend_class_entry *PdoFirebird_ce;
31
32 /* {{{ pdo_firebird_deps */
33 static const zend_module_dep pdo_firebird_deps[] = {
34 ZEND_MOD_REQUIRED("pdo")
35 ZEND_MOD_END
36 };
37 /* }}} */
38
39 zend_module_entry pdo_firebird_module_entry = { /* {{{ */
40 STANDARD_MODULE_HEADER_EX, NULL,
41 pdo_firebird_deps,
42 "PDO_Firebird",
43 NULL,
44 PHP_MINIT(pdo_firebird),
45 PHP_MSHUTDOWN(pdo_firebird),
46 NULL,
47 NULL,
48 PHP_MINFO(pdo_firebird),
49 PHP_PDO_FIREBIRD_VERSION,
50 STANDARD_MODULE_PROPERTIES
51 };
52 /* }}} */
53
54 #ifdef COMPILE_DL_PDO_FIREBIRD
55 ZEND_GET_MODULE(pdo_firebird)
56 #endif
57
PHP_MINIT_FUNCTION(pdo_firebird)58 PHP_MINIT_FUNCTION(pdo_firebird) /* {{{ */
59 {
60 REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_DATE_FORMAT", (zend_long) PDO_FB_ATTR_DATE_FORMAT);
61 REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_TIME_FORMAT", (zend_long) PDO_FB_ATTR_TIME_FORMAT);
62 REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_TIMESTAMP_FORMAT", (zend_long) PDO_FB_ATTR_TIMESTAMP_FORMAT);
63 REGISTER_PDO_CLASS_CONST_LONG("FB_TRANSACTION_ISOLATION_LEVEL", (zend_long) PDO_FB_TRANSACTION_ISOLATION_LEVEL);
64 REGISTER_PDO_CLASS_CONST_LONG("FB_READ_COMMITTED", (zend_long) PDO_FB_READ_COMMITTED);
65 REGISTER_PDO_CLASS_CONST_LONG("FB_REPEATABLE_READ", (zend_long) PDO_FB_REPEATABLE_READ);
66 REGISTER_PDO_CLASS_CONST_LONG("FB_SERIALIZABLE", (zend_long) PDO_FB_SERIALIZABLE);
67 REGISTER_PDO_CLASS_CONST_LONG("FB_WRITABLE_TRANSACTION", (zend_long) PDO_FB_WRITABLE_TRANSACTION);
68
69 if (FAILURE == php_pdo_register_driver(&pdo_firebird_driver)) {
70 return FAILURE;
71 }
72
73 PdoFirebird_ce = register_class_PdoFirebird(pdo_dbh_ce);
74 PdoFirebird_ce->create_object = pdo_dbh_new;
75
76 #ifdef ZEND_SIGNALS
77 /* firebird replaces some signals at runtime, suppress warnings. */
78 SIGG(check) = 0;
79 #endif
80
81 return php_pdo_register_driver_specific_ce(&pdo_firebird_driver, PdoFirebird_ce);
82 }
83 /* }}} */
84
PHP_MSHUTDOWN_FUNCTION(pdo_firebird)85 PHP_MSHUTDOWN_FUNCTION(pdo_firebird) /* {{{ */
86 {
87 php_pdo_unregister_driver(&pdo_firebird_driver);
88
89 return SUCCESS;
90 }
91 /* }}} */
92
PHP_MINFO_FUNCTION(pdo_firebird)93 PHP_MINFO_FUNCTION(pdo_firebird) /* {{{ */
94 {
95 char version[64];
96 isc_get_client_version(version);
97
98 php_info_print_table_start();
99 php_info_print_table_row(2, "PDO Driver for Firebird", "enabled");
100 php_info_print_table_row(2, "Client Library Version", version);
101 php_info_print_table_end();
102 }
103 /* }}} */
104