more internal conversions
[m6w6/ext-pq] / src / php_pq_module.c
1 /*
2 +--------------------------------------------------------------------+
3 | PECL :: pq |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2013, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
11 */
12
13 #ifdef HAVE_CONFIG_H
14 # include "config.h"
15 #endif
16
17
18 #include <php.h>
19 #include <ext/standard/info.h>
20
21 #include <libpq-fe.h>
22
23 /*
24 #include <Zend/zend_interfaces.h>
25 #include <Zend/zend_exceptions.h>
26 #include <ext/spl/spl_array.h>
27 #include <ext/spl/spl_exceptions.h>
28 #include <ext/raphf/php_raphf.h>
29
30 #include <libpq-events.h>
31 #include <libpq/libpq-fs.h>
32 #include <fnmatch.h>
33 */
34
35 #include "php_pq.h"
36 #include "php_pq_misc.h"
37 #include "php_pqcancel.h"
38 #include "php_pqconn.h"
39 #include "php_pqcopy.h"
40 #include "php_pqexc.h"
41 #include "php_pqlob.h"
42 #include "php_pqres.h"
43 #include "php_pqstm.h"
44 #include "php_pqtxn.h"
45 #include "php_pqtypes.h"
46
47 #define PHP_MINIT_CALL(i) do { \
48 if (SUCCESS != PHP_MINIT(i)(type, module_number TSRMLS_CC)) { \
49 return FAILURE; \
50 } \
51 } while(0)
52
53 static PHP_MINIT_FUNCTION(pq)
54 {
55 PHP_MINIT_CALL(pq_misc);
56 PHP_MINIT_CALL(pqexc);
57
58 PHP_MINIT_CALL(pqconn);
59 PHP_MINIT_CALL(pqcancel);
60 PHP_MINIT_CALL(pqtypes);
61
62 PHP_MINIT_CALL(pqres);
63 PHP_MINIT_CALL(pqstm);
64 PHP_MINIT_CALL(pqtxn);
65 PHP_MINIT_CALL(pqcur);
66
67 PHP_MINIT_CALL(pqcopy);
68 PHP_MINIT_CALL(pqlob);
69
70 return php_persistent_handle_provide(ZEND_STRL("pq\\Connection"), php_pqconn_get_resource_factory_ops(), NULL, NULL TSRMLS_CC);
71 }
72
73 #define PHP_MSHUT_CALL(i) do { \
74 if (SUCCESS != PHP_MSHUTDOWN(i)(type, module_number TSRMLS_CC)) { \
75 return FAILURE; \
76 } \
77 } while(0)
78
79 static PHP_MSHUTDOWN_FUNCTION(pq)
80 {
81 php_persistent_handle_cleanup(ZEND_STRL("pq\\Connection"), NULL, 0 TSRMLS_CC);
82
83 PHP_MSHUT_CALL(pqlob);
84 PHP_MSHUT_CALL(pqcopy);
85 PHP_MSHUT_CALL(pqtxn);
86 PHP_MSHUT_CALL(pqstm);
87 PHP_MSHUT_CALL(pqres);
88 PHP_MSHUT_CALL(pqtypes);
89 PHP_MSHUT_CALL(pqcancel);
90 PHP_MSHUT_CALL(pqconn);
91
92 return SUCCESS;
93 }
94
95 static PHP_MINFO_FUNCTION(pq)
96 {
97 #ifdef HAVE_PQLIBVERSION
98 int libpq_v;
99 #endif
100 char libpq_version[10] = "pre-9.1";
101
102 php_info_print_table_start();
103 php_info_print_table_header(2, "PQ Support", "enabled");
104 php_info_print_table_row(2, "Extension Version", PHP_PQ_VERSION);
105 php_info_print_table_end();
106
107 php_info_print_table_start();
108 php_info_print_table_header(2, "Used Library", "Version");
109 #ifdef HAVE_PQLIBVERSION
110 libpq_v = PQlibVersion();
111 slprintf(libpq_version, sizeof(libpq_version), "%d.%d.%d", libpq_v/10000%100, libpq_v/100%100, libpq_v%100);
112 #endif
113 php_info_print_table_row(2, "libpq", libpq_version);
114 php_info_print_table_end();
115 }
116
117 const zend_function_entry pq_functions[] = {
118 {0}
119 };
120
121 static zend_module_dep pq_module_deps[] = {
122 ZEND_MOD_REQUIRED("raphf")
123 ZEND_MOD_REQUIRED("spl")
124 ZEND_MOD_END
125 };
126
127 zend_module_entry pq_module_entry = {
128 STANDARD_MODULE_HEADER_EX,
129 NULL,
130 pq_module_deps,
131 "pq",
132 pq_functions,
133 PHP_MINIT(pq),
134 PHP_MSHUTDOWN(pq),
135 NULL,/*PHP_RINIT(pq),*/
136 NULL,/*PHP_RSHUTDOWN(pq),*/
137 PHP_MINFO(pq),
138 PHP_PQ_VERSION,
139 STANDARD_MODULE_PROPERTIES
140 };
141
142 #ifdef COMPILE_DL_PQ
143 ZEND_GET_MODULE(pq)
144 #endif
145
146
147 /*
148 * Local variables:
149 * tab-width: 4
150 * c-basic-offset: 4
151 * End:
152 * vim600: noet sw=4 ts=4 fdm=marker
153 * vim<600: noet sw=4 ts=4
154 */