xref: /PHP-8.1/ext/pdo_firebird/pdo_firebird.c (revision 01b3fc03)
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 
29 /* {{{ pdo_firebird_deps */
30 static const zend_module_dep pdo_firebird_deps[] = {
31 	ZEND_MOD_REQUIRED("pdo")
32 	ZEND_MOD_END
33 };
34 /* }}} */
35 
36 zend_module_entry pdo_firebird_module_entry = { /* {{{ */
37 	STANDARD_MODULE_HEADER_EX, NULL,
38 	pdo_firebird_deps,
39 	"PDO_Firebird",
40 	NULL,
41 	PHP_MINIT(pdo_firebird),
42 	PHP_MSHUTDOWN(pdo_firebird),
43 	NULL,
44 	NULL,
45 	PHP_MINFO(pdo_firebird),
46 	PHP_PDO_FIREBIRD_VERSION,
47 	STANDARD_MODULE_PROPERTIES
48 };
49 /* }}} */
50 
51 #ifdef COMPILE_DL_PDO_FIREBIRD
52 ZEND_GET_MODULE(pdo_firebird)
53 #endif
54 
PHP_MINIT_FUNCTION(pdo_firebird)55 PHP_MINIT_FUNCTION(pdo_firebird) /* {{{ */
56 {
57 	REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_DATE_FORMAT", (zend_long) PDO_FB_ATTR_DATE_FORMAT);
58 	REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_TIME_FORMAT", (zend_long) PDO_FB_ATTR_TIME_FORMAT);
59 	REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_TIMESTAMP_FORMAT", (zend_long) PDO_FB_ATTR_TIMESTAMP_FORMAT);
60 
61 	if (FAILURE == php_pdo_register_driver(&pdo_firebird_driver)) {
62 		return FAILURE;
63 	}
64 
65 #ifdef ZEND_SIGNALS
66 	/* firebird replaces some signals at runtime, suppress warnings. */
67 	SIGG(check) = 0;
68 #endif
69 
70 	return SUCCESS;
71 }
72 /* }}} */
73 
PHP_MSHUTDOWN_FUNCTION(pdo_firebird)74 PHP_MSHUTDOWN_FUNCTION(pdo_firebird) /* {{{ */
75 {
76 	php_pdo_unregister_driver(&pdo_firebird_driver);
77 
78 	return SUCCESS;
79 }
80 /* }}} */
81 
PHP_MINFO_FUNCTION(pdo_firebird)82 PHP_MINFO_FUNCTION(pdo_firebird) /* {{{ */
83 {
84 	char version[64];
85 	isc_get_client_version(version);
86 
87 	php_info_print_table_start();
88 	php_info_print_table_header(2, "PDO Driver for Firebird", "enabled");
89 	php_info_print_table_row(2, "Client Library Version", version);
90 	php_info_print_table_end();
91 }
92 /* }}} */
93