Skip to content

Commit b0bfc80

Browse files
committed
Introduce _php_ibase_get_fbclient_symbol
1 parent 4f2edac commit b0bfc80

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

interbase.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,26 @@ PHP_INI_BEGIN()
783783
STD_PHP_INI_ENTRY_EX("ibase.default_lock_timeout", "0", PHP_INI_ALL, OnUpdateLongGEZero, default_lock_timeout, zend_ibase_globals, ibase_globals, display_link_numbers)
784784
PHP_INI_END()
785785

786+
#ifdef __GNUC__
787+
void* _php_ibase_get_fbclient_symbol(const char* sym)
788+
{
789+
return dlsym(RTLD_DEFAULT, sym);
790+
}
791+
#elif defined(PHP_WIN32)
792+
void* _php_ibase_get_fbclient_symbol(const char* sym)
793+
{
794+
HMODULE l = GetModuleHandle("fbclient");
795+
796+
if (!l && !(l = GetModuleHandle("gds32"))) {
797+
return NULL;
798+
}
799+
800+
return GetProcAddress(l, sym);
801+
}
802+
#else
803+
static_assert(false, "TODO: implement dynamic symbol name lookup for your platform");
804+
#endif
805+
786806
static PHP_GINIT_FUNCTION(ibase)
787807
{
788808
#if defined(COMPILE_DL_INTERBASE) && defined(ZTS)
@@ -791,6 +811,8 @@ static PHP_GINIT_FUNCTION(ibase)
791811
ibase_globals->num_persistent = ibase_globals->num_links = 0;
792812
ibase_globals->sql_code = *ibase_globals->errmsg = 0;
793813
ibase_globals->default_link = NULL;
814+
ibase_globals->fb_get_master_interface = _php_ibase_get_fbclient_symbol("fb_get_master_interface");
815+
ibase_globals->fb_get_statement_interface = _php_ibase_get_fbclient_symbol("fb_get_statement_interface");
794816
}
795817

796818
PHP_MINIT_FUNCTION(ibase)

php_ibase_includes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ ZEND_BEGIN_MODULE_GLOBALS(ibase)
7575
zend_long sql_code;
7676
zend_long default_trans_params;
7777
zend_long default_lock_timeout; // only used togetger with trans_param IBASE_LOCK_TIMEOUT
78+
void *fb_get_master_interface;
79+
void *fb_get_statement_interface;
7880
ZEND_END_MODULE_GLOBALS(ibase)
7981

8082
ZEND_EXTERN_MODULE_GLOBALS(ibase)

0 commit comments

Comments
 (0)