fix package.xml
[m6w6/ext-pq] / src / php_pq_module.c
index 786430429b136319020f2de0ae1314da31336a54..cd992172d9e524bc9c6ccdd15d151fcdf43c806e 100644 (file)
 #include <php.h>
 #include <ext/standard/info.h>
 
-#include <libpq-fe.h>
-
-/*
-#include <Zend/zend_interfaces.h>
-#include <Zend/zend_exceptions.h>
-#include <ext/spl/spl_array.h>
-#include <ext/spl/spl_exceptions.h>
-#include <ext/raphf/php_raphf.h>
-
 #include <libpq-events.h>
-#include <libpq/libpq-fs.h>
-#include <fnmatch.h>
-*/
 
 #include "php_pq.h"
 #include "php_pq_misc.h"
 #include "php_pqcancel.h"
 #include "php_pqconn.h"
 #include "php_pqcopy.h"
+#include "php_pqcur.h"
 #include "php_pqexc.h"
 #include "php_pqlob.h"
 #include "php_pqres.h"
 #include "php_pqtxn.h"
 #include "php_pqtypes.h"
 
+ZEND_DECLARE_MODULE_GLOBALS(php_pq);
+
+static void php_pq_globals_init_once(zend_php_pq_globals *G)
+{
+       memset(G, 0, sizeof(*G));
+}
+
 #define PHP_MINIT_CALL(i) do { \
-       if (SUCCESS != PHP_MINIT(i)(type, module_number TSRMLS_CC)) { \
+       if (SUCCESS != PHP_MINIT(i)(type, module_number)) { \
                return FAILURE; \
        } \
 } while(0)
 
 static PHP_MINIT_FUNCTION(pq)
 {
+       ZEND_INIT_MODULE_GLOBALS(php_pq, php_pq_globals_init_once, NULL);
+
        PHP_MINIT_CALL(pq_misc);
        PHP_MINIT_CALL(pqexc);
 
@@ -67,21 +65,20 @@ static PHP_MINIT_FUNCTION(pq)
        PHP_MINIT_CALL(pqcopy);
        PHP_MINIT_CALL(pqlob);
 
-       return php_persistent_handle_provide(ZEND_STRL("pq\\Connection"), php_pqconn_get_resource_factory_ops(), NULL, NULL TSRMLS_CC);
+       return SUCCESS;
 }
 
 #define PHP_MSHUT_CALL(i) do { \
-       if (SUCCESS != PHP_MSHUTDOWN(i)(type, module_number TSRMLS_CC)) { \
+       if (SUCCESS != PHP_MSHUTDOWN(i)(type, module_number)) { \
                return FAILURE; \
        } \
 } while(0)
 
 static PHP_MSHUTDOWN_FUNCTION(pq)
 {
-       php_persistent_handle_cleanup(ZEND_STRL("pq\\Connection"), NULL, 0 TSRMLS_CC);
-
        PHP_MSHUT_CALL(pqlob);
        PHP_MSHUT_CALL(pqcopy);
+       PHP_MSHUT_CALL(pqcur);
        PHP_MSHUT_CALL(pqtxn);
        PHP_MSHUT_CALL(pqstm);
        PHP_MSHUT_CALL(pqres);
@@ -105,22 +102,23 @@ static PHP_MINFO_FUNCTION(pq)
        php_info_print_table_end();
 
        php_info_print_table_start();
-       php_info_print_table_header(2, "Used Library", "Version");
+       php_info_print_table_header(3, "Used Library", "Compiled", "Linked");
 #ifdef HAVE_PQLIBVERSION
        libpq_v = PQlibVersion();
        slprintf(libpq_version, sizeof(libpq_version), "%d.%d.%d", libpq_v/10000%100, libpq_v/100%100, libpq_v%100);
 #endif
-       php_info_print_table_row(2, "libpq", libpq_version);
+       php_info_print_table_row(3, "libpq", PHP_PQ_LIBVERSION, libpq_version);
        php_info_print_table_end();
 }
 
-const zend_function_entry pq_functions[] = {
+static const zend_function_entry pq_functions[] = {
        {0}
 };
 
 static zend_module_dep pq_module_deps[] = {
        ZEND_MOD_REQUIRED("raphf")
        ZEND_MOD_REQUIRED("spl")
+       ZEND_MOD_OPTIONAL("json")
        ZEND_MOD_END
 };