#endif
/*
-#define IBDEBUG(a) printf("::: %s (%d)\n", a, __LINE__);
+#define IBDEBUG(a) php_printf("::: %s (%d)\n", a, __LINE__);
*/
#define IBDEBUG(a)
#endif
-#ifdef ZTS
-int ibase_globals_id;
-#else
-PHP_IBASE_API php_ibase_globals ibase_globals;
-#endif
+ZEND_DECLARE_MODULE_GLOBALS(ibase)
/* }}} */
Return error message */
PHP_FUNCTION(ibase_errmsg)
{
- char *errmsg = IBG(errmsg);
IBLS_FETCH();
- if (errmsg[0]) {
- RETURN_STRING(errmsg,1);
+ if (IBG(errmsg[0])) {
+ RETURN_STRING(IBG(errmsg),1);
}
RETURN_FALSE;
}
print interbase error and save it for ibase_errmsg() */
static void _php_ibase_error(void)
{
- char *s, *errmsg = IBG(errmsg);
- ISC_STATUS *statusp = IB_STATUS;
+ char *s;
+ ISC_STATUS *statusp;
+ IBLS_FETCH();
- s = errmsg;
- while ((s - errmsg) < MAX_ERRMSG - (IBASE_MSGSIZE + 2) && isc_interprete(s, &statusp)) {
- strcat(errmsg, " ");
- s = errmsg + strlen(errmsg);
+ s = IBG(errmsg);
+ statusp = IB_STATUS;
+ while ((s - IBG(errmsg)) < MAX_ERRMSG - (IBASE_MSGSIZE + 2) && isc_interprete(s, &statusp)) {
+ strcat(IBG(errmsg), " ");
+ s = IBG(errmsg) + strlen(IBG(errmsg));
}
- php_error(E_WARNING, "InterBase: %s", errmsg);
+ php_error(E_WARNING, "InterBase: %s", IBG(errmsg));
}
/* }}} */
print php interbase module error and save it for ibase_errmsg() */
static void _php_ibase_module_error(char *msg, ...)
{
- char *errmsg = IBG(errmsg);
va_list ap;
int len;
+ IBLS_FETCH();
va_start(ap, msg);
- len = vsnprintf(errmsg, MAX_ERRMSG - 1, msg, ap);
+ len = vsnprintf(IBG(errmsg), MAX_ERRMSG - 1, msg, ap);
va_end(ap);
- errmsg[len] = '\0';
+ IBG(errmsg[len]) = '\0';
- php_error(E_WARNING, "InterBase module: %s",errmsg);
+ php_error(E_WARNING, "InterBase module: %s", IBG(errmsg));
}
/* }}} */
static void _php_ibase_commit_link(ibase_db_link *link)
{
int i;
+ IBLS_FETCH();
+ IBDEBUG("Checking transactions to close...");
if (link->trans[0] != NULL) { /* commit default */
IBDEBUG("Committing default transaction...");
if (isc_commit_transaction(IB_STATUS, &link->trans[0])) {
/* {{{ _php_ibase_close_link() */
static void _php_ibase_close_link(ibase_db_link *link)
{
+ IBLS_FETCH();
+
_php_ibase_commit_link(link);
IBDEBUG("Closing normal link...");
isc_detach_database(IB_STATUS, &link->link);
/* {{{ _php_ibase_close_plink() */
static void _php_ibase_close_plink(ibase_db_link *link)
{
+ IBLS_FETCH();
+
_php_ibase_commit_link(link);
IBDEBUG("Closing permanent link...");
isc_detach_database(IB_STATUS, &link->link);
/* {{{ _php_ibase_free_result() */
static void _php_ibase_free_result(ibase_result *ib_result)
{
+ IBLS_FETCH();
+
IBDEBUG("Freeing result...");
if (ib_result){
_php_ibase_free_xsqlda(ib_result->out_sqlda);
/* {{{ _php_ibase_free_query() */
static void _php_ibase_free_query(ibase_query *ib_query)
{
+ IBLS_FETCH();
+
IBDEBUG("Freeing query...");
if (ib_query) {
if (ib_query->in_sqlda) {
/* {{{ _php_ibase_free_blob() */
static void _php_ibase_free_blob(ibase_blob_handle *ib_blob)
{
-
+ IBLS_FETCH();
+
if (ib_blob->bl_handle != NULL) { /* blob open*/
if (isc_cancel_blob(IB_STATUS, &ib_blob->bl_handle)) {
_php_ibase_error();
/* {{{ startup, shutdown and info functions */
PHP_INI_BEGIN()
- STD_PHP_INI_BOOLEAN("ibase.allow_persistent", "1", PHP_INI_SYSTEM, OnUpdateInt, allow_persistent, php_ibase_globals, ibase_globals)
- STD_PHP_INI_ENTRY_EX("ibase.max_persistent", "-1", PHP_INI_SYSTEM, OnUpdateInt, max_persistent, php_ibase_globals, ibase_globals, display_link_numbers)
- STD_PHP_INI_ENTRY_EX("ibase.max_links", "-1", PHP_INI_SYSTEM, OnUpdateInt, max_links, php_ibase_globals, ibase_globals, display_link_numbers)
- STD_PHP_INI_ENTRY("ibase.default_user", NULL, PHP_INI_ALL, OnUpdateString, default_user, php_ibase_globals, ibase_globals)
- STD_PHP_INI_ENTRY("ibase.default_password", NULL, PHP_INI_ALL, OnUpdateString, default_password, php_ibase_globals, ibase_globals)
- STD_PHP_INI_ENTRY("ibase.timestampformat", "%m/%d/%Y %H:%M:%S", PHP_INI_ALL, OnUpdateString, cfg_timestampformat, php_ibase_globals, ibase_globals)
- STD_PHP_INI_ENTRY("ibase.dateformat", "%m/%d/%Y", PHP_INI_ALL, OnUpdateString, cfg_dateformat, php_ibase_globals, ibase_globals)
- STD_PHP_INI_ENTRY("ibase.timeformat", "%H:%M:%S", PHP_INI_ALL, OnUpdateString, cfg_timeformat, php_ibase_globals, ibase_globals)
+ STD_PHP_INI_BOOLEAN("ibase.allow_persistent", "1", PHP_INI_SYSTEM, OnUpdateInt, allow_persistent, zend_ibase_globals, ibase_globals)
+ STD_PHP_INI_ENTRY_EX("ibase.max_persistent", "-1", PHP_INI_SYSTEM, OnUpdateInt, max_persistent, zend_ibase_globals, ibase_globals, display_link_numbers)
+ STD_PHP_INI_ENTRY_EX("ibase.max_links", "-1", PHP_INI_SYSTEM, OnUpdateInt, max_links, zend_ibase_globals, ibase_globals, display_link_numbers)
+ STD_PHP_INI_ENTRY("ibase.default_user", NULL, PHP_INI_ALL, OnUpdateString, default_user, zend_ibase_globals, ibase_globals)
+ STD_PHP_INI_ENTRY("ibase.default_password", NULL, PHP_INI_ALL, OnUpdateString, default_password, zend_ibase_globals, ibase_globals)
+ STD_PHP_INI_ENTRY("ibase.timestampformat", "%m/%d/%Y %H:%M:%S", PHP_INI_ALL, OnUpdateString, cfg_timestampformat, zend_ibase_globals, ibase_globals)
+ STD_PHP_INI_ENTRY("ibase.dateformat", "%m/%d/%Y", PHP_INI_ALL, OnUpdateString, cfg_dateformat, zend_ibase_globals, ibase_globals)
+ STD_PHP_INI_ENTRY("ibase.timeformat", "%H:%M:%S", PHP_INI_ALL, OnUpdateString, cfg_timeformat, zend_ibase_globals, ibase_globals)
PHP_INI_END()
-PHP_MINIT_FUNCTION(ibase)
+static void php_ibase_init_globals(IBLS_D)
{
- IBLS_FETCH();
-
IBG(timestampformat) = NULL;
IBG(dateformat) = NULL;
IBG(timeformat) = NULL;
IBG(errmsg) = NULL;
-
IBG(num_persistent) = 0;
+}
+
+PHP_MINIT_FUNCTION(ibase)
+{
+ IBLS_FETCH();
+
+ ZEND_INIT_MODULE_GLOBALS(ibase, php_ibase_init_globals, NULL);
REGISTER_INI_ENTRIES();
{
char dpb_buffer[256], *dpb, *p;
int dpb_length, len;
+ IBLS_FETCH();
dpb = dpb_buffer;
int link_id, trans_n;
IBLS_FETCH();
-
RESET_ERRMSG;
switch (ZEND_NUM_ARGS()) {
int i, dim, ar_cnt, ar_length;
XSQLVAR *var;
-
+ IBLS_FETCH();
IB_ARRAY = NULL;
static int _php_ibase_alloc_query(ibase_query **ib_queryp, isc_db_handle link, isc_tr_handle trans, char *query, int dialect)
{
#define IB_QUERY (*ib_queryp)
+ IBLS_FETCH();
IB_QUERY = emalloc(sizeof(ibase_query));
IB_QUERY->link = link;
XSQLDA *in_sqlda = NULL, *out_sqlda = NULL;
BIND_BUF *bind_buf = NULL;
int rv = FAILURE;
+ IBLS_FETCH();
IB_RESULT = NULL;
ibase_db_link *ib_link;
IBLS_FETCH();
-
RESET_ERRMSG;
link_id = IBG(default_link);
/* open default transaction */
static int _php_ibase_def_trans(ibase_db_link * ib_link, int trans_n)
{
+ IBLS_FETCH();
if (trans_n == 0 && ib_link->trans[0] == NULL) {
if (isc_start_transaction(IB_STATUS, &ib_link->trans[0], 1, &ib_link->link, 0, NULL)) {
int link_id = 0, trans_n = 0;
ibase_db_link *ib_link;
IBLS_FETCH();
-
RESET_ERRMSG;
ibase_query *ib_query;
ibase_result *ib_result;
IBLS_FETCH();
-
RESET_ERRMSG;
static int _php_ibase_var_pval(pval *val, void *data, int type, int len, int scale, int flag)
{
char string_data[255];
+ IBLS_FETCH();
+ PLS_FETCH();
switch(type & ~1) {
case SQL_VARYING:
ibase_query *ib_query;
char *query;
IBLS_FETCH();
-
RESET_ERRMSG;
ibase_query *ib_query;
ibase_result *ib_result;
IBLS_FETCH();
-
RESET_ERRMSG;
pval **query_arg;
ibase_query *ib_query;
IBLS_FETCH();
-
RESET_ERRMSG;
{
pval **result;
ibase_result *ib_result;
-
+ IBLS_FETCH();
RESET_ERRMSG;
int len;
XSQLVAR *var;
IBLS_FETCH();
-
RESET_ERRMSG;
};
char bl_inf[sizeof(long)*8], *p;
-
+ IBLS_FETCH();
bl_info->max_segment = 0;
bl_info->num_segments = 0;
ibase_db_link *ib_link;
ibase_blob_handle *ib_blob;
IBLS_FETCH();
-
RESET_ERRMSG;
pval *blob_arg;
ibase_blob_handle *ib_blob, *ib_blob_id;
IBLS_FETCH();
-
RESET_ERRMSG;
ibase_blob_handle *ib_blob;
IBLS_FETCH();
-
RESET_ERRMSG;
if (ZEND_NUM_ARGS()!=2 || getParameters(ht, 2, &blob_arg, &string_arg)==FAILURE) {
ibase_blob_handle *ib_blob;
IBLS_FETCH();
-
RESET_ERRMSG;
if (ZEND_NUM_ARGS() != 2 || getParameters(ht, 2, &blob_arg, &len_arg) == FAILURE) {
ibase_blob_handle *ib_blob;
IBLS_FETCH();
-
RESET_ERRMSG;
if (ZEND_NUM_ARGS()!=1 || getParameters(ht, 1, &blob_arg)==FAILURE) {
IBASE_BLOBINFO bl_info;
IBLS_FETCH();
-
RESET_ERRMSG;
if (ZEND_NUM_ARGS()!=1 || getParameters(ht, 1, &blob_arg)==FAILURE) {
char bl_data[IBASE_BLOB_SEG];
unsigned short seg_len;
ibase_blob_handle *ib_blob_id;
-
-
IBLS_FETCH();
RESET_ERRMSG;
FILE *fp;
IBLS_FETCH();
-
RESET_ERRMSG;
switch (ZEND_NUM_ARGS()) {