summaryrefslogtreecommitdiff
path: root/ext/odbc
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2006-06-15 18:33:09 +0000
committerDmitry Stogov <dmitry@php.net>2006-06-15 18:33:09 +0000
commit1dbaae2795b756a3875c53da00b277f241cc04b8 (patch)
treefd516b57354eb9480e89dcd0503fa990d3cc2068 /ext/odbc
parentc3ed91477a011e494559d6f65301ef6b2e38cd22 (diff)
downloadphp-git-1dbaae2795b756a3875c53da00b277f241cc04b8.tar.gz
Added automatic module globals management
Diffstat (limited to 'ext/odbc')
-rw-r--r--ext/odbc/php_odbc.c45
-rw-r--r--ext/odbc/php_odbc_includes.h6
2 files changed, 22 insertions, 29 deletions
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c
index 518d3bae76..0b7cee68e4 100644
--- a/ext/odbc/php_odbc.c
+++ b/ext/odbc/php_odbc.c
@@ -130,6 +130,9 @@ zend_function_entry odbc_functions[] = {
};
/* }}} */
+ZEND_DECLARE_MODULE_GLOBALS(odbc);
+static PHP_GINIT_FUNCTION(odbc);
+
/* {{{ odbc_module_entry
*/
zend_module_entry odbc_module_entry = {
@@ -142,16 +145,14 @@ zend_module_entry odbc_module_entry = {
PHP_RSHUTDOWN(odbc),
PHP_MINFO(odbc),
"1.0",
- STANDARD_MODULE_PROPERTIES
+ PHP_MODULE_GLOBALS(odbc),
+ PHP_GINIT(odbc),
+ NULL,
+ NULL,
+ STANDARD_MODULE_PROPERTIES_EX
};
/* }}} */
-#ifdef ZTS
-int odbc_globals_id;
-#else
-ZEND_API php_odbc_globals odbc_globals;
-#endif
-
#ifdef COMPILE_DL_ODBC
ZEND_GET_MODULE(odbc)
# ifdef PHP_WIN32
@@ -383,32 +384,30 @@ static PHP_INI_DISP(display_lrl)
*/
PHP_INI_BEGIN()
STD_PHP_INI_BOOLEAN("odbc.allow_persistent", "1", PHP_INI_SYSTEM, OnUpdateLong,
- allow_persistent, php_odbc_globals, odbc_globals)
+ allow_persistent, zend_odbc_globals, odbc_globals)
STD_PHP_INI_ENTRY_EX("odbc.max_persistent", "-1", PHP_INI_SYSTEM, OnUpdateLong,
- max_persistent, php_odbc_globals, odbc_globals, display_link_nums)
+ max_persistent, zend_odbc_globals, odbc_globals, display_link_nums)
STD_PHP_INI_ENTRY_EX("odbc.max_links", "-1", PHP_INI_SYSTEM, OnUpdateLong,
- max_links, php_odbc_globals, odbc_globals, display_link_nums)
+ max_links, zend_odbc_globals, odbc_globals, display_link_nums)
STD_PHP_INI_ENTRY("odbc.default_db", NULL, PHP_INI_ALL, OnUpdateString,
- defDB, php_odbc_globals, odbc_globals)
+ defDB, zend_odbc_globals, odbc_globals)
STD_PHP_INI_ENTRY("odbc.default_user", NULL, PHP_INI_ALL, OnUpdateString,
- defUser, php_odbc_globals, odbc_globals)
+ defUser, zend_odbc_globals, odbc_globals)
STD_PHP_INI_ENTRY_EX("odbc.default_pw", NULL, PHP_INI_ALL, OnUpdateString,
- defPW, php_odbc_globals, odbc_globals, display_defPW)
+ defPW, zend_odbc_globals, odbc_globals, display_defPW)
STD_PHP_INI_ENTRY_EX("odbc.defaultlrl", "4096", PHP_INI_ALL, OnUpdateLong,
- defaultlrl, php_odbc_globals, odbc_globals, display_lrl)
+ defaultlrl, zend_odbc_globals, odbc_globals, display_lrl)
STD_PHP_INI_ENTRY_EX("odbc.defaultbinmode", "1", PHP_INI_ALL, OnUpdateLong,
- defaultbinmode, php_odbc_globals, odbc_globals, display_binmode)
+ defaultbinmode, zend_odbc_globals, odbc_globals, display_binmode)
STD_PHP_INI_BOOLEAN("odbc.check_persistent", "1", PHP_INI_SYSTEM, OnUpdateLong,
- check_persistent, php_odbc_globals, odbc_globals)
+ check_persistent, zend_odbc_globals, odbc_globals)
PHP_INI_END()
/* }}} */
-#ifdef ZTS
-static void php_odbc_init_globals(php_odbc_globals *odbc_globals_p TSRMLS_DC)
+static PHP_GINIT_FUNCTION(odbc)
{
- ODBCG(num_persistent) = 0;
+ odbc_globals->num_persistent = 0;
}
-#endif
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(odbc)
@@ -418,12 +417,6 @@ PHP_MINIT_FUNCTION(odbc)
RETCODE rc;
#endif
-#ifdef ZTS
- ts_allocate_id(&odbc_globals_id, sizeof(php_odbc_globals), php_odbc_init_globals, NULL);
-#else
- ODBCG(num_persistent) = 0;
-#endif
-
REGISTER_INI_ENTRIES();
le_result = zend_register_list_destructors_ex(_free_odbc_result, NULL, "odbc result", module_number);
le_conn = zend_register_list_destructors_ex(_close_odbc_conn, NULL, "odbc link", module_number);
diff --git a/ext/odbc/php_odbc_includes.h b/ext/odbc/php_odbc_includes.h
index d3ee4d5ea3..bdb67ec5d2 100644
--- a/ext/odbc/php_odbc_includes.h
+++ b/ext/odbc/php_odbc_includes.h
@@ -249,7 +249,7 @@ typedef struct odbc_result {
odbc_connection *conn_ptr;
} odbc_result;
-typedef struct {
+ZEND_BEGIN_MODULE_GLOBALS(odbc)
char *defDB;
char *defUser;
char *defPW;
@@ -266,7 +266,7 @@ typedef struct {
char lasterrormsg[SQL_MAX_MESSAGE_LENGTH];
HashTable *resource_list;
HashTable *resource_plist;
-} php_odbc_globals;
+ZEND_END_MODULE_GLOBALS(odbc)
int odbc_add_result(HashTable *list, odbc_result *result);
odbc_result *odbc_get_result(HashTable *list, int count);
@@ -284,7 +284,7 @@ void odbc_sql_error(ODBC_SQL_ERROR_PARAMS);
#define IS_SQL_BINARY(x) (x == SQL_BINARY || x == SQL_VARBINARY || x == SQL_LONGVARBINARY)
#ifdef ZTS
-# define ODBCG(v) TSRMG(odbc_globals_id, php_odbc_globals *, v)
+# define ODBCG(v) TSRMG(odbc_globals_id, zend_odbc_globals *, v)
#else
# define ODBCG(v) (odbc_globals.v)
extern ZEND_API php_odbc_globals odbc_globals;