[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2008-11-11 Thread Felipe Pena
felipe  Tue Nov 11 17:52:48 2008 UTC

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  - New parameter parsing API
  
http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/interbase.c?r1=1.242&r2=1.243&diff_format=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.242 
php-src/ext/interbase/interbase.c:1.243
--- php-src/ext/interbase/interbase.c:1.242 Tue Nov 11 13:26:26 2008
+++ php-src/ext/interbase/interbase.c   Tue Nov 11 17:52:47 2008
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.242 2008/11/11 13:26:26 felipe Exp $ */
+/* $Id: interbase.c,v 1.243 2008/11/11 17:52:47 felipe Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1098,30 +1098,24 @@
Close an InterBase connection */
 PHP_FUNCTION(ibase_close)
 {
-   zval **link_arg = NULL;
+   zval *link_arg = NULL;
ibase_db_link *ib_link;
int link_id;
 
RESET_ERRMSG;

-   switch (ZEND_NUM_ARGS()) {
-   case 0:
-   link_id = IBG(default_link);
-   IBG(default_link) = -1;
-   break;
-   case 1:
-   if (zend_get_parameters_ex(1, &link_arg) == FAILURE) {
-   RETURN_FALSE;
-   }
-   convert_to_long_ex(link_arg);
-   link_id = Z_LVAL_PP(link_arg);
-   break;
-   default:
-   WRONG_PARAM_COUNT;
-   break;
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|r", &link_arg) 
== FAILURE) {
+   return;
+   }
+   
+   if (ZEND_NUM_ARGS() == 0) {
+   link_id = IBG(default_link);
+   IBG(default_link) = -1;
+   } else {
+   link_id = Z_RESVAL_P(link_arg);
}
 
-   ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, link_arg, link_id, 
LE_LINK, le_link, le_plink);
+   ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, &link_arg, link_id, 
LE_LINK, le_link, le_plink);
zend_list_delete(link_id);
RETURN_TRUE;
 }
@@ -1131,31 +1125,25 @@
Drop an InterBase database */
 PHP_FUNCTION(ibase_drop_db)
 {
-   zval **link_arg = NULL;
+   zval *link_arg = NULL;
ibase_db_link *ib_link;
ibase_tr_list *l;
int link_id;
 
RESET_ERRMSG;
-
-   switch (ZEND_NUM_ARGS()) {
-   case 0:
-   link_id = IBG(default_link);
-   IBG(default_link) = -1;
-   break;
-   case 1:
-   if (zend_get_parameters_ex(1, &link_arg) == FAILURE) {
-   RETURN_FALSE;
-   }
-   convert_to_long_ex(link_arg);
-   link_id = Z_LVAL_PP(link_arg);
-   break;
-   default:
-   WRONG_PARAM_COUNT;
-   break;
+   
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|r", &link_arg) 
== FAILURE) {
+   return;
}

-   ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, link_arg, link_id, 
LE_LINK, le_link, le_plink);
+   if (ZEND_NUM_ARGS() == 0) {
+   link_id = IBG(default_link);
+   IBG(default_link) = -1;
+   } else {
+   link_id = Z_RESVAL_P(link_arg);
+   }
+   
+   ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, &link_arg, link_id, 
LE_LINK, le_link, le_plink);
 
if (isc_drop_database(IB_STATUS, &ib_link->handle)) {
_php_ibase_error(TSRMLS_C);
@@ -1197,9 +1185,9 @@
long trans_argl = 0;
char *tpb;
ISC_TEB *teb;
-   zval ***args = (zval ***) safe_emalloc(sizeof(zval **),argn,0);
+   zval ***args = NULL;
 
-   if (zend_get_parameters_array_ex(argn, args) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "+", 
&args, &argn) == FAILURE) {
efree(args);
efree(ib_link);
RETURN_FALSE;
@@ -1367,55 +1355,42 @@
ibase_trans *trans = NULL;
int res_id = 0;
ISC_STATUS result;
+   ibase_db_link *ib_link;
+   zval *arg = NULL;
+   int type;
 
RESET_ERRMSG;
+   
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|r", &arg) == 
FAILURE) {
+   return;
+   }
 
-   switch (ZEND_NUM_ARGS()) {
-
-   ibase_db_link *ib_link;
-   zval **arg;
-   int type;
+   if (ZEND_NUM_ARGS() == 0) {
+   ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, NULL, 
IBG(default_link), LE_LINK, le_link, le_plink);
+   if (ib_link->tr_list == NULL || ib_link->tr_li

[PHP-CVS] cvs: php-src /ext/interbase interbase.c /ext/interbase/tests bug46543.phpt ZendEngine2 zend_list.h

2008-11-11 Thread Felipe Pena
felipe  Tue Nov 11 13:26:26 2008 UTC

  Added files: 
/php-src/ext/interbase/testsbug46543.phpt 

  Modified files:  
/ZendEngine2zend_list.h 
/php-src/ext/interbase  interbase.c 
  Log:
  - Added ZEND_FETCH_RESOURCE2_NO_RETURN() (a version of ZEND_FETCH_RESOURCE2 
but without the ZEND_VERIFY_RESOURCE() which contains RETURN_FALSE)
  - Fixed bug #46543 (ibase_trans() memory leaks when using wrong parameters)
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_list.h?r1=1.52&r2=1.53&diff_format=u
Index: ZendEngine2/zend_list.h
diff -u ZendEngine2/zend_list.h:1.52 ZendEngine2/zend_list.h:1.53
--- ZendEngine2/zend_list.h:1.52Mon Dec 31 07:12:07 2007
+++ ZendEngine2/zend_list.h Tue Nov 11 13:26:26 2008
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: zend_list.h,v 1.52 2007/12/31 07:12:07 sebastian Exp $ */
+/* $Id: zend_list.h,v 1.53 2008/11/11 13:26:26 felipe Exp $ */
 
 #ifndef ZEND_LIST_H
 #define ZEND_LIST_H
@@ -99,6 +99,9 @@
 #define ZEND_FETCH_RESOURCE2(rsrc, rsrc_type, passed_id, default_id, 
resource_type_name, resource_type1, resource_type2)   \
rsrc = (rsrc_type) zend_fetch_resource(passed_id TSRMLS_CC, default_id, 
resource_type_name, NULL, 2, resource_type1, resource_type2);   \
ZEND_VERIFY_RESOURCE(rsrc);
+   
+#define ZEND_FETCH_RESOURCE2_NO_RETURN(rsrc, rsrc_type, passed_id, default_id, 
resource_type_name, resource_type1, resource_type2) \
+   (rsrc = (rsrc_type) zend_fetch_resource(passed_id TSRMLS_CC, 
default_id, resource_type_name, NULL, 2, resource_type1, resource_type2))
 
 #define ZEND_REGISTER_RESOURCE(rsrc_result, rsrc_pointer, rsrc_type)  \
 zend_register_resource(rsrc_result, rsrc_pointer, rsrc_type);
http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/interbase.c?r1=1.241&r2=1.242&diff_format=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.241 
php-src/ext/interbase/interbase.c:1.242
--- php-src/ext/interbase/interbase.c:1.241 Sun Nov  2 21:10:08 2008
+++ php-src/ext/interbase/interbase.c   Tue Nov 11 13:26:26 2008
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.241 2008/11/02 21:10:08 felipe Exp $ */
+/* $Id: interbase.c,v 1.242 2008/11/11 13:26:26 felipe Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1214,8 +1214,13 @@

if (Z_TYPE_PP(args[i]) == IS_RESOURCE) {

-   ZEND_FETCH_RESOURCE2(ib_link[link_cnt], 
ibase_db_link *, args[i], -1, 
-   LE_LINK, le_link, le_plink);
+   if 
(!ZEND_FETCH_RESOURCE2_NO_RETURN(ib_link[link_cnt], ibase_db_link *, args[i], 
-1, LE_LINK, le_link, le_plink)) {
+   efree(teb);
+   efree(tpb);
+   efree(ib_link);
+   efree(args);
+   RETURN_FALSE;
+   }

/* copy the most recent modifier string into 
tbp[] */
memcpy(&tpb[TPB_MAX_SIZE * link_cnt], last_tpb, 
TPB_MAX_SIZE);
@@ -1279,8 +1284,10 @@
 
if (link_cnt == 0) {
link_cnt = 1;
-   ZEND_FETCH_RESOURCE2(ib_link[0], ibase_db_link *, NULL, 
IBG(default_link), LE_LINK, 
-   le_link, le_plink);
+   if (!ZEND_FETCH_RESOURCE2_NO_RETURN(ib_link[0], ibase_db_link 
*, NULL, IBG(default_link), LE_LINK, le_link, le_plink)) {
+   efree(ib_link);
+   RETURN_FALSE;
+   }
result = isc_start_transaction(IB_STATUS, &tr_handle, 1, 
&ib_link[0]->handle, tpb_len, last_tpb);
}


http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/tests/bug46543.phpt?view=markup&rev=1.1
Index: php-src/ext/interbase/tests/bug46543.phpt
+++ php-src/ext/interbase/tests/bug46543.phpt
--TEST--
Bug #46543 (ibase_trans() memory leaks when using wrong parameters)
--SKIPIF--

--FILE--

--EXPECTF--
Warning: ibase_trans(): no Firebird/InterBase link resource supplied in %s on 
line %d

Warning: ibase_trans(): no Firebird/InterBase link resource supplied in %s on 
line %d

Warning: ibase_trans(): no Firebird/InterBase link resource supplied in %s on 
line %d

Warning: ibase_trans(): supplied resource is not a valid Firebird/InterBase 
link resource in %s on line %d



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2008-07-07 Thread Felipe Pena
felipe  Mon Jul  7 17:34:07 2008 UTC

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  MFB: - Added arginfo
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/interbase.c?r1=1.238&r2=1.239&diff_format=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.238 
php-src/ext/interbase/interbase.c:1.239
--- php-src/ext/interbase/interbase.c:1.238 Thu Feb 28 14:16:12 2008
+++ php-src/ext/interbase/interbase.c   Mon Jul  7 17:34:07 2008
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.238 2008/02/28 14:16:12 felipe Exp $ */
+/* $Id: interbase.c,v 1.239 2008/07/07 17:34:07 felipe Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -46,64 +46,384 @@
 ZEND_DECLARE_MODULE_GLOBALS(ibase)
 static PHP_GINIT_FUNCTION(ibase);
 
+/* {{{ arginfo */
+static
+ZEND_BEGIN_ARG_INFO(arginfo_ibase_errmsg, 0)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO(arginfo_ibase_errcode, 0)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_connect, 0, 0, 1)
+   ZEND_ARG_INFO(0, database)
+   ZEND_ARG_INFO(0, username)
+   ZEND_ARG_INFO(0, password)
+   ZEND_ARG_INFO(0, charset)
+   ZEND_ARG_INFO(0, buffers)
+   ZEND_ARG_INFO(0, dialect)
+   ZEND_ARG_INFO(0, role)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_pconnect, 0, 0, 1)
+   ZEND_ARG_INFO(0, database)
+   ZEND_ARG_INFO(0, username)
+   ZEND_ARG_INFO(0, password)
+   ZEND_ARG_INFO(0, charset)
+   ZEND_ARG_INFO(0, buffers)
+   ZEND_ARG_INFO(0, dialect)
+   ZEND_ARG_INFO(0, role)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_close, 0, 0, 0)
+   ZEND_ARG_INFO(0, link_identifier)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_drop_db, 0, 0, 0)
+   ZEND_ARG_INFO(0, link_identifier)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_trans, 0, 0, 0)
+   ZEND_ARG_INFO(0, trans_args)
+   ZEND_ARG_INFO(0, link_identifier)
+   ZEND_ARG_INFO(0, trans_args)
+   ZEND_ARG_INFO(0, link_identifier)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_commit, 0, 0, 1)
+   ZEND_ARG_INFO(0, link_identifier)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_rollback, 0, 0, 1)
+   ZEND_ARG_INFO(0, link_identifier)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_commit_ret, 0, 0, 1)
+   ZEND_ARG_INFO(0, link_identifier)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_rollback_ret, 0, 0, 1)
+   ZEND_ARG_INFO(0, link_identifier)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_gen_id, 0, 0, 1)
+   ZEND_ARG_INFO(0, generator)
+   ZEND_ARG_INFO(0, increment)
+   ZEND_ARG_INFO(0, link_identifier)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_blob_create, 0, 0, 0)
+   ZEND_ARG_INFO(0, link_identifier)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_blob_open, 0, 0, 0)
+   ZEND_ARG_INFO(0, link_identifier)
+   ZEND_ARG_INFO(0, blob_id)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_blob_add, 0, 0, 2)
+   ZEND_ARG_INFO(0, blob_handle)
+   ZEND_ARG_INFO(0, data)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_blob_get, 0, 0, 2)
+   ZEND_ARG_INFO(0, blob_handle)
+   ZEND_ARG_INFO(0, len)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_blob_close, 0, 0, 1)
+   ZEND_ARG_INFO(0, blob_handle)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_blob_cancel, 0, 0, 1)
+   ZEND_ARG_INFO(0, blob_handle)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_blob_info, 0, 0, 0)
+   ZEND_ARG_INFO(0, link_identifier)
+   ZEND_ARG_INFO(0, blob_id)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_blob_echo, 0, 0, 0)
+   ZEND_ARG_INFO(0, link_identifier)
+   ZEND_ARG_INFO(0, blob_id)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_blob_import, 0, 0, 0)
+   ZEND_ARG_INFO(0, link_identifier)
+   ZEND_ARG_INFO(0, file)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_query, 0, 0, 0)
+   ZEND_ARG_INFO(0, link_identifier)
+   ZEND_ARG_INFO(0, link_identifier)
+   ZEND_ARG_INFO(0, query)
+   ZEND_ARG_INFO(0, bind_arg)
+   ZEND_ARG_INFO(0, bind_arg)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_affected_rows, 0, 0, 0)
+   ZEND_ARG_INFO(0, link_identifier)
+ZEND_END_ARG_INFO()
+
+#if abies_0
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_num_rows, 0, 0, 1)
+   ZEND_ARG_INFO(0, result_identifier)
+ZEND_END_ARG_INFO()
+#endif
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_fetch_row, 0, 0, 1)
+   ZEND_ARG_INFO(0, result)
+   ZEND_ARG_INFO(0, fetch_flags)

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2007-02-28 Thread Hannes Magnusson
bjori   Wed Feb 28 10:46:16 2007 UTC

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Typo
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/interbase.c?r1=1.234&r2=1.235&diff_format=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.234 
php-src/ext/interbase/interbase.c:1.235
--- php-src/ext/interbase/interbase.c:1.234 Sat Feb 24 16:25:54 2007
+++ php-src/ext/interbase/interbase.c   Wed Feb 28 10:46:16 2007
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.234 2007/02/24 16:25:54 helly Exp $ */
+/* $Id: interbase.c,v 1.235 2007/02/28 10:46:16 bjori Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1193,7 +1193,7 @@
 #if SIZEOF_LONG < 8
if (result < LONG_MIN || result > LONG_MAX) {
char *res;
-   int l
+   int l;
 
l = spprintf(&res, 0, "%" LL_MASK "d", result);
RETURN_STRINGL(res, l, 0);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2007-01-18 Thread Antony Dovgal
tony2001Thu Jan 18 15:53:54 2007 UTC

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  fix the previous patch
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/interbase.c?r1=1.232&r2=1.233&diff_format=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.232 
php-src/ext/interbase/interbase.c:1.233
--- php-src/ext/interbase/interbase.c:1.232 Thu Jan 18 15:40:54 2007
+++ php-src/ext/interbase/interbase.c   Thu Jan 18 15:53:53 2007
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.232 2007/01/18 15:40:54 tony2001 Exp $ */
+/* $Id: interbase.c,v 1.233 2007/01/18 15:53:53 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -595,19 +595,19 @@
 
for (i = 0; i < sizeof(dpb_args); ++i) {
if (dpb_args[i] && args[i] && len[i] && buf_len > 0) {
-   dpb_len += snprintf(dpb, buf_len, "%c%c%s", 
dpb_args[i],(unsigned char)len[i],args[i]);
+   dpb_len = snprintf(dpb, buf_len, "%c%c%s", 
dpb_args[i],(unsigned char)len[i],args[i]);
dpb += dpb_len;
buf_len -= dpb_len;
}
}
if (largs[BUF] && buf_len > 0) {
-   dpb_len += snprintf(dpb, buf_len, "%c\2%c%c", 
isc_dpb_num_buffers, 
+   dpb_len = snprintf(dpb, buf_len, "%c\2%c%c", 
isc_dpb_num_buffers, 
(char)(largs[BUF] >> 8), (char)(largs[BUF] & 0xff));
dpb += dpb_len;
buf_len -= dpb_len;
}
if (largs[SYNC] && buf_len > 0) {
-   dpb_len += sprintf(dpb, buf_len, "%c\1%c", isc_dpb_force_write, 
largs[SYNC] == isc_spb_prp_wm_sync ? 1 : 0);
+   dpb_len = sprintf(dpb, buf_len, "%c\1%c", isc_dpb_force_write, 
largs[SYNC] == isc_spb_prp_wm_sync ? 1 : 0);
dpb += dpb_len;
buf_len -= dpb_len;
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2007-01-18 Thread Antony Dovgal
tony2001Thu Jan 18 15:40:54 2007 UTC

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  use snprintf()
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/interbase.c?r1=1.231&r2=1.232&diff_format=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.231 
php-src/ext/interbase/interbase.c:1.232
--- php-src/ext/interbase/interbase.c:1.231 Mon Jan  1 09:29:24 2007
+++ php-src/ext/interbase/interbase.c   Thu Jan 18 15:40:54 2007
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.231 2007/01/01 09:29:24 sebastian Exp $ */
+/* $Id: interbase.c,v 1.232 2007/01/18 15:40:54 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -588,22 +588,28 @@

 int _php_ibase_attach_db(char **args, int *len, long *largs, isc_db_handle *db 
TSRMLS_DC)
 {
-   short i;
+   short i, dpb_len, buf_len = 256;
char dpb_buffer[256] = { isc_dpb_version1 }, *dpb;
 
dpb = dpb_buffer + 1;
 
for (i = 0; i < sizeof(dpb_args); ++i) {
-   if (dpb_args[i] && args[i] && len[i]) {
-   dpb += sprintf(dpb, "%c%c%s", dpb_args[i],(unsigned 
char)len[i],args[i]);
+   if (dpb_args[i] && args[i] && len[i] && buf_len > 0) {
+   dpb_len += snprintf(dpb, buf_len, "%c%c%s", 
dpb_args[i],(unsigned char)len[i],args[i]);
+   dpb += dpb_len;
+   buf_len -= dpb_len;
}
}
-   if (largs[BUF]) {
-   dpb += sprintf(dpb, "%c\2%c%c", isc_dpb_num_buffers, 
+   if (largs[BUF] && buf_len > 0) {
+   dpb_len += snprintf(dpb, buf_len, "%c\2%c%c", 
isc_dpb_num_buffers, 
(char)(largs[BUF] >> 8), (char)(largs[BUF] & 0xff));
+   dpb += dpb_len;
+   buf_len -= dpb_len;
}
-   if (largs[SYNC]) {
-   dpb += sprintf(dpb, "%c\1%c", isc_dpb_force_write, largs[SYNC] 
== isc_spb_prp_wm_sync ? 1 : 0);
+   if (largs[SYNC] && buf_len > 0) {
+   dpb_len += sprintf(dpb, buf_len, "%c\1%c", isc_dpb_force_write, 
largs[SYNC] == isc_spb_prp_wm_sync ? 1 : 0);
+   dpb += dpb_len;
+   buf_len -= dpb_len;
}
if (isc_attach_database(IB_STATUS, (short)len[DB], args[DB], db, 
(short)(dpb-dpb_buffer), dpb_buffer)) {
_php_ibase_error(TSRMLS_C);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2005-12-11 Thread Marcus Boerger
helly   Sun Dec 11 12:46:51 2005 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  - Revert accidential 'drop in' from 1.227
  
http://cvs.php.net/diff.php/php-src/ext/interbase/interbase.c?r1=1.227&r2=1.228&ty=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.227 
php-src/ext/interbase/interbase.c:1.228
--- php-src/ext/interbase/interbase.c:1.227 Tue Dec  6 02:24:34 2005
+++ php-src/ext/interbase/interbase.c   Sun Dec 11 12:46:51 2005
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.227 2005/12/06 02:24:34 sniper Exp $ */
+/* $Id: interbase.c,v 1.228 2005/12/11 12:46:51 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -36,7 +36,7 @@
 #include "php_interbase.h"
 #include "php_ibase_includes.h"
 #include "SAPI.h"
-5B
+
 #include 
 
 #define ROLLBACK   0

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2005-02-23 Thread Ard Biesheuvel
abies   Wed Feb 23 15:20:27 2005 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Fixed bug #31597: ibase_connect() - incorrect warning
  
http://cvs.php.net/diff.php/php-src/ext/interbase/interbase.c?r1=1.223&r2=1.224&ty=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.223 
php-src/ext/interbase/interbase.c:1.224
--- php-src/ext/interbase/interbase.c:1.223 Tue Jul  6 09:46:18 2004
+++ php-src/ext/interbase/interbase.c   Wed Feb 23 15:20:25 2005
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.223 2004/07/06 13:46:18 abies Exp $ */
+/* $Id: interbase.c,v 1.224 2005/02/23 20:20:25 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -591,7 +591,7 @@
dpb = dpb_buffer + 1;
 
for (i = 0; i < sizeof(dpb_args); ++i) {
-   if (dpb_args[i] && args[i]) {
+   if (dpb_args[i] && args[i] && len[i]) {
dpb += sprintf(dpb, "%c%c%s", dpb_args[i],(unsigned 
char)len[i],args[i]);
}
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2004-06-30 Thread Ard Biesheuvel
abies   Wed Jun 30 06:55:03 2004 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Fixed Ilia's alloca() issue/exploit
  Removed pointless RINIT()
  Use macros for consistent resource type names
  
  
http://cvs.php.net/diff.php/php-src/ext/interbase/interbase.c?r1=1.221&r2=1.222&ty=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.221 php-src/ext/interbase/interbase.c:1.222
--- php-src/ext/interbase/interbase.c:1.221 Tue Jun  1 04:38:33 2004
+++ php-src/ext/interbase/interbase.c   Wed Jun 30 06:55:03 2004
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.221 2004/06/01 08:38:33 abies Exp $ */
+/* $Id: interbase.c,v 1.222 2004/06/30 10:55:03 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -174,7 +174,7 @@
ibase_functions,
PHP_MINIT(ibase),
PHP_MSHUTDOWN(ibase),
-   PHP_RINIT(ibase),
+   NULL,
PHP_RSHUTDOWN(ibase),
PHP_MINFO(ibase),
NO_VERSION_YET,
@@ -284,7 +284,7 @@
/* Transaction resource: make sure it refers to one link only, 
then 
   fetch it; database link is stored in ib_trans->db_link[]. */
IBDEBUG("Type is le_trans");
-   ZEND_FETCH_RESOURCE(*trans, ibase_trans *, link_id, -1, 
"InterBase transaction", le_trans);
+   ZEND_FETCH_RESOURCE(*trans, ibase_trans *, link_id, -1, 
LE_TRANS, le_trans);
if ((*trans)->link_cnt > 1) {
_php_ibase_module_error("Link id is ambiguous: 
transaction spans multiple connections."
TSRMLS_CC);
@@ -297,7 +297,7 @@
IBDEBUG("Type is le_[p]link or id not found");
/* Database link resource, use default transaction. */
*trans = NULL;
-   ZEND_FETCH_RESOURCE2(*ib_link, ibase_db_link *, link_id, -1, "InterBase link", 
le_link, le_plink);
+   ZEND_FETCH_RESOURCE2(*ib_link, ibase_db_link *, link_id, -1, LE_LINK, le_link, 
le_plink);
 }
 /* }}} */  
 
@@ -450,8 +450,9 @@
 
 static void php_ibase_init_globals(zend_ibase_globals *ibase_globals)
 {
-   ibase_globals->num_persistent = 0;
-   ibase_globals->sql_code = 0;
+   ibase_globals->num_persistent = ibase_globals->num_links = 0;
+   ibase_globals->sql_code = *ibase_globals->errmsg = 0;
+   ibase_globals->default_link = -1;
 }
 
 PHP_MINIT_FUNCTION(ibase)
@@ -460,9 +461,9 @@
 
REGISTER_INI_ENTRIES();
 
-   le_link = zend_register_list_destructors_ex(_php_ibase_close_link, NULL, 
"interbase link", module_number);
-   le_plink = zend_register_list_destructors_ex(php_ibase_commit_link_rsrc, 
_php_ibase_close_plink, "interbase link persistent", module_number);
-   le_trans = zend_register_list_destructors_ex(_php_ibase_free_trans, NULL, 
"interbase transaction", module_number);
+   le_link = zend_register_list_destructors_ex(_php_ibase_close_link, NULL, 
LE_LINK, module_number);
+   le_plink = zend_register_list_destructors_ex(php_ibase_commit_link_rsrc, 
_php_ibase_close_plink, LE_PLINK, module_number);
+   le_trans = zend_register_list_destructors_ex(_php_ibase_free_trans, NULL, 
LE_TRANS, module_number);
 
REGISTER_LONG_CONSTANT("IBASE_DEFAULT", PHP_IBASE_DEFAULT, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IBASE_CREATE", PHP_IBASE_CREATE, CONST_PERSISTENT);
@@ -490,16 +491,6 @@
return SUCCESS;  
 }
  
-PHP_RINIT_FUNCTION(ibase)
-{
-   IBG(default_link)= -1;
-   IBG(num_links) = IBG(num_persistent);
-
-   RESET_ERRMSG;
-
-   return SUCCESS;
-}
-
 PHP_MSHUTDOWN_FUNCTION(ibase)
 {
 #ifndef PHP_WIN32
@@ -527,6 +518,11 @@
 
 PHP_RSHUTDOWN_FUNCTION(ibase)
 {
+   IBG(num_links) = IBG(num_persistent);
+   IBG(default_link)= -1;
+
+   RESET_ERRMSG;
+
return SUCCESS;
 } 
  
@@ -794,8 +790,7 @@
break;
}
 
-   ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, link_arg, link_id, "InterBase 
link",
-   le_link, le_plink);
+   ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, link_arg, link_id, LE_LINK, 
le_link, le_plink);
zend_list_delete(link_id);
RETURN_TRUE;
 }
@@ -829,8 +824,8 @@
break;
}

-   ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, link_arg, link_id, "InterBase 
link",
-   le_link, le_plink);
+   ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, link_arg, link_id, LE_LINK, 
le_link, le_plink);
+
if (isc_drop_database(IB_STATUS, &ib_link->handle)) {
_php_ibase_error(TSRMLS_C);
RETURN_FALSE;
@@ -865,22 +860,22 @@
argn = ZEND_NUM_ARGS();
 
/* (1+argn) is an upper bound for the number of links this trans connects to *

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2004-05-30 Thread Ard Biesheuvel
abies   Sun May 30 12:41:28 2004 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Fix HTML/table layout in info() entry
  
  
http://cvs.php.net/diff.php/php-src/ext/interbase/interbase.c?r1=1.218&r2=1.219&ty=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.218 php-src/ext/interbase/interbase.c:1.219
--- php-src/ext/interbase/interbase.c:1.218 Sun May 30 12:20:24 2004
+++ php-src/ext/interbase/interbase.c   Sun May 30 12:41:28 2004
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.218 2004/05/30 16:20:24 abies Exp $ */
+/* $Id: interbase.c,v 1.219 2004/05/30 16:41:28 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -28,7 +28,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.218 $"
+#define FILE_REVISION "$Revision: 1.219 $"
 
 #if HAVE_IBASE
 
@@ -37,6 +37,7 @@
 #include "ext/standard/md5.h"
 #include "php_interbase.h"
 #include "php_ibase_includes.h"
+#include "SAPI.h"
 
 #include 
 
@@ -420,13 +421,16 @@
 }
 /* }}} */
 
-static ZEND_INI_DISP(php_ibase_password_displayer_cb)
+/* TODO this function should be part of either Zend or PHP API */
+static PHP_INI_DISP(php_ibase_password_displayer_cb)
 {
-   if ((type == ZEND_INI_DISPLAY_ORIG && ini_entry->orig_value) 
-   || (type != ZEND_INI_DISPLAY_ORIG && ini_entry->value)) {
-   ZEND_PUTS("");
+   if ((type == PHP_INI_DISPLAY_ORIG && ini_entry->orig_value) 
+   || (type == PHP_INI_DISPLAY_ACTIVE && ini_entry->value)) {
+   PUTS("");
+   } else if (!sapi_module.phpinfo_as_text) {
+   PUTS("no value");
} else {
-   ZEND_PUTS("no value");
+   PUTS("no value");
}
 }
 
@@ -569,10 +573,10 @@
php_info_print_table_row(2, "Run-time Client Library Version", s);
} while (0);
 #endif 
+   php_info_print_table_end();
 
DISPLAY_INI_ENTRIES();
 
-   php_info_print_table_end();
 }
 /* }}} */
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c php_ibase_includes.h /ext/interbase/tests 003.phpt 006.phpt 007.phpt

2004-05-30 Thread Ard Biesheuvel
abies   Sun May 30 12:20:25 2004 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c php_ibase_includes.h 
/php-src/ext/interbase/tests003.phpt 006.phpt 007.phpt 
  Log:
  Removed ibase_timefmt() - use ini_set() instead
  Improved phpinfo() appearance
  
  http://cvs.php.net/diff.php/php-src/ext/interbase/interbase.c?r1=1.217&r2=1.218&ty=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.217 php-src/ext/interbase/interbase.c:1.218
--- php-src/ext/interbase/interbase.c:1.217 Fri May 28 19:39:33 2004
+++ php-src/ext/interbase/interbase.c   Sun May 30 12:20:24 2004
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.217 2004/05/28 23:39:33 abies Exp $ */
+/* $Id: interbase.c,v 1.218 2004/05/30 16:20:24 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -28,7 +28,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.217 $"
+#define FILE_REVISION "$Revision: 1.218 $"
 
 #if HAVE_IBASE
 
@@ -59,7 +59,6 @@
PHP_FE(ibase_prepare, NULL)
PHP_FE(ibase_execute, NULL)
PHP_FE(ibase_free_query, NULL)
-   PHP_FE(ibase_timefmt, NULL)
PHP_FE(ibase_gen_id, NULL)
PHP_FE(ibase_num_fields, NULL)
PHP_FE(ibase_num_params, NULL)
@@ -124,7 +123,6 @@
PHP_FALIAS(fbird_prepare,ibase_prepare, NULL)
PHP_FALIAS(fbird_execute,ibase_execute, NULL)
PHP_FALIAS(fbird_free_query,ibase_free_query, NULL)
-   PHP_FALIAS(fbird_timefmt,ibase_timefmt, NULL)
PHP_FALIAS(fbird_gen_id,ibase_gen_id, NULL)
PHP_FALIAS(fbird_num_fields,ibase_num_fields, NULL)
PHP_FALIAS(fbird_num_params,ibase_num_params, NULL)
@@ -186,13 +184,6 @@
 
 #ifdef COMPILE_DL_INTERBASE
 ZEND_GET_MODULE(ibase)
-#define DL_MALLOC(size) malloc(size)
-#define DL_STRDUP(str) strdup(str)
-#define DL_FREE(ptr) free(ptr)
-#else
-#define DL_MALLOC(size) emalloc(size)
-#define DL_STRDUP(str) estrdup(str)
-#define DL_FREE(ptr) efree(ptr)
 #endif
 
 /* True globals, no need for thread safety */
@@ -429,6 +420,16 @@
 }
 /* }}} */
 
+static ZEND_INI_DISP(php_ibase_password_displayer_cb)
+{
+   if ((type == ZEND_INI_DISPLAY_ORIG && ini_entry->orig_value) 
+   || (type != ZEND_INI_DISPLAY_ORIG && ini_entry->value)) {
+   ZEND_PUTS("");
+   } else {
+   ZEND_PUTS("no value");
+   }
+}
+
 /* {{{ startup, shutdown and info functions */
 PHP_INI_BEGIN()
STD_PHP_INI_BOOLEAN("ibase.allow_persistent", "1", PHP_INI_SYSTEM, 
OnUpdateBool, allow_persistent, zend_ibase_globals, ibase_globals)
@@ -436,18 +437,15 @@
STD_PHP_INI_ENTRY_EX("ibase.max_links", "-1", PHP_INI_SYSTEM, OnUpdateLong, 
max_links, zend_ibase_globals, ibase_globals, display_link_numbers)
STD_PHP_INI_ENTRY("ibase.default_db", NULL, PHP_INI_SYSTEM, OnUpdateString, 
default_db, zend_ibase_globals, ibase_globals)
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_EX("ibase.default_password", NULL, PHP_INI_ALL, 
OnUpdateString, default_password, zend_ibase_globals, 
ibase_globals,php_ibase_password_displayer_cb)
STD_PHP_INI_ENTRY("ibase.default_charset", NULL, PHP_INI_ALL, OnUpdateString, 
default_charset, zend_ibase_globals, ibase_globals)
-   STD_PHP_INI_ENTRY("ibase.timestampformat", IB_DEF_DATE_FMT " " 
IB_DEF_TIME_FMT, PHP_INI_ALL, OnUpdateString, cfg_timestampformat, zend_ibase_globals, 
ibase_globals)
-   STD_PHP_INI_ENTRY("ibase.dateformat", IB_DEF_DATE_FMT, PHP_INI_ALL, 
OnUpdateString, cfg_dateformat, zend_ibase_globals, ibase_globals)
-   STD_PHP_INI_ENTRY("ibase.timeformat", IB_DEF_TIME_FMT, PHP_INI_ALL, 
OnUpdateString, cfg_timeformat, zend_ibase_globals, ibase_globals)
+   STD_PHP_INI_ENTRY("ibase.timestampformat", IB_DEF_DATE_FMT " " 
IB_DEF_TIME_FMT, PHP_INI_ALL, OnUpdateString, timestampformat, zend_ibase_globals, 
ibase_globals)
+   STD_PHP_INI_ENTRY("ibase.dateformat", IB_DEF_DATE_FMT, PHP_INI_ALL, 
OnUpdateString, dateformat, zend_ibase_globals, ibase_globals)
+   STD_PHP_INI_ENTRY("ibase.timeformat", IB_DEF_TIME_FMT, PHP_INI_ALL, 
OnUpdateString, timeformat, zend_ibase_globals, ibase_globals)
 PHP_INI_END()
 
 static void php_ibase_init_globals(zend_ibase_globals *ibase_globals)
 {
-   ibase_globals->timestampformat = NULL;
-   ibase_globals->dateformat = NULL;
-   ibase_globals->timeformat = NULL;
ibase_globals->num_persistent = 0;
ibase_globals->sql_code = 0;
 }
@@ -467,9 +465,6 @@
REGISTER_LONG_CONSTANT("IBASE_FETCH_BLOBS", PHP_IBASE_FETCH_BLOBS, 
CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IBASE_FETCH_ARRAYS", PHP_IBASE_FETCH_ARRAYS

[PHP-CVS] cvs: php-src /ext/interbase interbase.c php_ibase_includes.h

2004-05-28 Thread Ard Biesheuvel
abies   Fri May 28 19:39:33 2004 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c php_ibase_includes.h 
  Log:
  Changed default date format to ISO
  Enable sync flag in connect()
  
http://cvs.php.net/diff.php/php-src/ext/interbase/interbase.c?r1=1.216&r2=1.217&ty=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.216 php-src/ext/interbase/interbase.c:1.217
--- php-src/ext/interbase/interbase.c:1.216 Fri May 28 16:11:34 2004
+++ php-src/ext/interbase/interbase.c   Fri May 28 19:39:33 2004
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.216 2004/05/28 20:11:34 abies Exp $ */
+/* $Id: interbase.c,v 1.217 2004/05/28 23:39:33 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -28,7 +28,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.216 $"
+#define FILE_REVISION "$Revision: 1.217 $"
 
 #if HAVE_IBASE
 
@@ -431,16 +431,16 @@
 
 /* {{{ startup, shutdown and info functions */
 PHP_INI_BEGIN()
-   STD_PHP_INI_BOOLEAN("ibase.allow_persistent", "1", PHP_INI_SYSTEM, 
OnUpdateLong, allow_persistent, zend_ibase_globals, ibase_globals)
+   STD_PHP_INI_BOOLEAN("ibase.allow_persistent", "1", PHP_INI_SYSTEM, 
OnUpdateBool, allow_persistent, zend_ibase_globals, ibase_globals)
STD_PHP_INI_ENTRY_EX("ibase.max_persistent", "-1", PHP_INI_SYSTEM, 
OnUpdateLong, max_persistent, zend_ibase_globals, ibase_globals, display_link_numbers)
STD_PHP_INI_ENTRY_EX("ibase.max_links", "-1", PHP_INI_SYSTEM, OnUpdateLong, 
max_links, zend_ibase_globals, ibase_globals, display_link_numbers)
STD_PHP_INI_ENTRY("ibase.default_db", NULL, PHP_INI_SYSTEM, OnUpdateString, 
default_db, zend_ibase_globals, ibase_globals)
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.default_charset", NULL, PHP_INI_ALL, OnUpdateString, 
default_charset, 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)
+   STD_PHP_INI_ENTRY("ibase.timestampformat", IB_DEF_DATE_FMT " " 
IB_DEF_TIME_FMT, PHP_INI_ALL, OnUpdateString, cfg_timestampformat, zend_ibase_globals, 
ibase_globals)
+   STD_PHP_INI_ENTRY("ibase.dateformat", IB_DEF_DATE_FMT, PHP_INI_ALL, 
OnUpdateString, cfg_dateformat, zend_ibase_globals, ibase_globals)
+   STD_PHP_INI_ENTRY("ibase.timeformat", IB_DEF_TIME_FMT, PHP_INI_ALL, 
OnUpdateString, cfg_timeformat, zend_ibase_globals, ibase_globals)
 PHP_INI_END()
 
 static void php_ibase_init_globals(zend_ibase_globals *ibase_globals)
@@ -628,10 +628,10 @@
 }
 /* }}} */
 
-enum connect_args { DB = 0, USER = 1, PASS = 2, CSET = 3, ROLE = 4, BUF = 0, DLECT = 
1 };
+enum connect_args { DB = 0, USER = 1, PASS = 2, CSET = 3, ROLE = 4, BUF = 0, DLECT = 
1, SYNC = 2 };

 static char const dpb_args[] = { 
-   0, isc_dpb_user_name, isc_dpb_password, isc_dpb_lc_ctype, isc_dpb_sql_role_name
+   0, isc_dpb_user_name, isc_dpb_password, isc_dpb_lc_ctype, 
isc_dpb_sql_role_name, 0
 };

 int _php_ibase_attach_db(char **args, int *len, long *largs, isc_db_handle *db 
TSRMLS_DC)
@@ -650,6 +650,9 @@
dpb += sprintf(dpb, "%c\2%c%c", isc_dpb_num_buffers, 
(char)(largs[BUF] >> 8), (char)(largs[BUF] & 0xff));
}
+   if (largs[SYNC]) {
+   dpb += sprintf(dpb, "%c\1%c", isc_dpb_force_write, largs[SYNC] == 
isc_spb_prp_wm_sync ? 1 : 0);
+   }
if (isc_attach_database(IB_STATUS, (short)len[DB], args[DB], db, 
(short)(dpb-dpb_buffer), dpb_buffer)) {
_php_ibase_error(TSRMLS_C);
return FAILURE;
@@ -662,7 +665,7 @@
 {
char hash[16], *args[] = { NULL, NULL, NULL, NULL, NULL };
int i, len[] = { 0, 0, 0, 0, 0 };
-   long largs[] = { 0, 0 };
+   long largs[] = { 0, 0, 0 };
PHP_MD5_CTX hash_context;
list_entry new_index_ptr, *le;
isc_db_handle db_handle = NULL;
@@ -670,9 +673,10 @@
 
RESET_ERRMSG;
 
-   if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lls",
+   if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|llsl",
&args[DB], &len[DB], &args[USER], &len[USER], &args[PASS], 
&len[PASS],
-   &args[CSET], &len[CSET], &largs[BUF], &largs[DLECT

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2004-05-28 Thread Ard Biesheuvel
abies   Fri May 28 16:11:35 2004 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Fix commit/rollback of multi-link transactions
  Some CS
  
http://cvs.php.net/diff.php/php-src/ext/interbase/interbase.c?r1=1.215&r2=1.216&ty=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.215 php-src/ext/interbase/interbase.c:1.216
--- php-src/ext/interbase/interbase.c:1.215 Sat May 22 14:50:58 2004
+++ php-src/ext/interbase/interbase.c   Fri May 28 16:11:34 2004
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.215 2004/05/22 18:50:58 abies Exp $ */
+/* $Id: interbase.c,v 1.216 2004/05/28 20:11:34 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -28,7 +28,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.215 $"
+#define FILE_REVISION "$Revision: 1.216 $"
 
 #if HAVE_IBASE
 
@@ -721,65 +721,67 @@
zend_hash_del(&EG(regular_list), hash, sizeof(hash));
}
}   
+
/* ... or a persistent one */
-   if (SUCCESS == zend_hash_find(&EG(persistent_list), hash, sizeof(hash), (void 
*) &le)) {
+   switch (zend_hash_find(&EG(persistent_list), hash, sizeof(hash), (void *) 
&le)) {
static char info[] = { isc_info_base_level, isc_info_end };
char result[8];
ISC_STATUS status[20];
 
+   case SUCCESS:
+
if (Z_TYPE_P(le) != le_plink) {
RETURN_FALSE;
}
/* check if connection has timed out */
ib_link = (ibase_db_link *) le->ptr;
-   if (isc_database_info(status, &ib_link->handle, sizeof(info), info, 
sizeof(result), result)) {
-   zend_hash_del(&EG(persistent_list), hash, sizeof(hash));
-   } else {
+   if (!isc_database_info(status, &ib_link->handle, sizeof(info), info, 
sizeof(result), result)) {
ZEND_REGISTER_RESOURCE(return_value, ib_link, le_plink);
-   goto register_link_resource;
+   break;
}
-   }
-
-   /* no link found, so we have to open one */
-
-   if (IBG(max_links) != -1 && IBG(num_links) >= IBG(max_links)) {
-   _php_ibase_module_error("Too many open links (%ld)" TSRMLS_CC, 
IBG(num_links));
-   RETURN_FALSE;
-   }
-
-   /* create the ib_link */
-   if (FAILURE == _php_ibase_attach_db(args, len, largs, &db_handle TSRMLS_CC)) {
-   RETURN_FALSE;
-   }
-
-   /* use non-persistent if allowed number of persistent links is exceeded */
-   if (!persistent || (IBG(max_persistent) != -1 && IBG(num_persistent) >= 
IBG(max_persistent))) {
-   ib_link = (ibase_db_link *) emalloc(sizeof(ibase_db_link));
-   ZEND_REGISTER_RESOURCE(return_value, ib_link, le_link);
-   } else {
-   list_entry new_le;
-   
-   ib_link = (ibase_db_link *) malloc(sizeof(ibase_db_link));
+   zend_hash_del(&EG(persistent_list), hash, sizeof(hash));
+   
+   default:
 
-   /* hash it up */
-   Z_TYPE(new_le) = le_plink;
-   new_le.ptr = ib_link;
-   if (FAILURE == zend_hash_update(&EG(persistent_list), hash, 
sizeof(hash),
-   (void *) &new_le, sizeof(list_entry), NULL)) {
-   free(ib_link);
+   /* no link found, so we have to open one */
+   
+   if (IBG(max_links) != -1 && IBG(num_links) >= IBG(max_links)) {
+   _php_ibase_module_error("Too many open links (%ld)" TSRMLS_CC, 
IBG(num_links));
RETURN_FALSE;
}
-   ZEND_REGISTER_RESOURCE(return_value, ib_link, le_plink);
-   ++IBG(num_persistent);
+   
+   /* create the ib_link */
+   if (FAILURE == _php_ibase_attach_db(args, len, largs, &db_handle 
TSRMLS_CC)) {
+   RETURN_FALSE;
+   }
+   
+   /* use non-persistent if allowed number of persistent links is 
exceeded */
+   if (!persistent || (IBG(max_persistent) != -1 && IBG(num_persistent) 
>= IBG(max_persistent))) {
+   ib_link = (ibase_db_link *) emalloc(sizeof(ibase_db_link));
+   ZEND_REGISTER_RESOURCE(return_value, ib_link, le_link);
+   } else {
+   list_entry new_le;
+   
+   ib_link = (ibase_db_link *) malloc(sizeof(ibase_db_link));
+   
+   /* hash it up */
+   Z_TYPE(new_le) = le_plink;
+   new_le.ptr = ib_link;
+   if (FAILURE == zend_hash_update(&EG(persistent_list), hash, 
sizeof(

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2004-05-22 Thread Ard Biesheuvel
abies   Sat May 22 14:50:59 2004 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Use dummy status vector in ibase_connect()
  Added fbird_ aliases for all ibase_ functions
  # See comment in code for more info
  # Please let me know if there are any namespace issues involved
  
  
http://cvs.php.net/diff.php/php-src/ext/interbase/interbase.c?r1=1.214&r2=1.215&ty=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.214 php-src/ext/interbase/interbase.c:1.215
--- php-src/ext/interbase/interbase.c:1.214 Wed May 12 10:29:42 2004
+++ php-src/ext/interbase/interbase.c   Sat May 22 14:50:58 2004
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.214 2004/05/12 14:29:42 abies Exp $ */
+/* $Id: interbase.c,v 1.215 2004/05/22 18:50:58 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -28,7 +28,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.214 $"
+#define FILE_REVISION "$Revision: 1.215 $"
 
 #if HAVE_IBASE
 
@@ -103,6 +103,71 @@
PHP_FE(ibase_wait_event, NULL)
PHP_FE(ibase_set_event_handler, NULL)
PHP_FE(ibase_free_event_handler, NULL)
+
+   /**
+   * These aliases are provided in order to maintain forward compatibility. As 
Firebird
+   * and InterBase are developed independently, functionality might be different 
between
+   * the two branches in future versions.
+   * Firebird users should use the aliases, so future InterBase-specific changes 
will
+   * not affect their code
+   */
+   PHP_FALIAS(fbird_connect,ibase_connect, NULL)
+   PHP_FALIAS(fbird_pconnect,ibase_pconnect, NULL)
+   PHP_FALIAS(fbird_close,ibase_close, NULL)
+   PHP_FALIAS(fbird_drop_db,ibase_drop_db, NULL)
+   PHP_FALIAS(fbird_query,ibase_query, NULL)
+   PHP_FALIAS(fbird_fetch_row,ibase_fetch_row, NULL)
+   PHP_FALIAS(fbird_fetch_assoc,ibase_fetch_assoc, NULL)
+   PHP_FALIAS(fbird_fetch_object,ibase_fetch_object, NULL)
+   PHP_FALIAS(fbird_free_result,ibase_free_result, NULL)
+   PHP_FALIAS(fbird_name_result,ibase_name_result, NULL)
+   PHP_FALIAS(fbird_prepare,ibase_prepare, NULL)
+   PHP_FALIAS(fbird_execute,ibase_execute, NULL)
+   PHP_FALIAS(fbird_free_query,ibase_free_query, NULL)
+   PHP_FALIAS(fbird_timefmt,ibase_timefmt, NULL)
+   PHP_FALIAS(fbird_gen_id,ibase_gen_id, NULL)
+   PHP_FALIAS(fbird_num_fields,ibase_num_fields, NULL)
+   PHP_FALIAS(fbird_num_params,ibase_num_params, NULL)
+#if abies_0
+   PHP_FALIAS(fbird_num_rows,ibase_num_rows, NULL)
+#endif
+   PHP_FALIAS(fbird_affected_rows,ibase_affected_rows, NULL)
+   PHP_FALIAS(fbird_field_info,ibase_field_info, NULL)
+   PHP_FALIAS(fbird_param_info,ibase_param_info, NULL)
+
+   PHP_FALIAS(fbird_trans,ibase_trans, NULL)
+   PHP_FALIAS(fbird_commit,ibase_commit, NULL)
+   PHP_FALIAS(fbird_rollback,ibase_rollback, NULL)
+   PHP_FALIAS(fbird_commit_ret,ibase_commit_ret, NULL)
+   PHP_FALIAS(fbird_rollback_ret,ibase_rollback_ret, NULL)
+
+   PHP_FALIAS(fbird_blob_info,ibase_blob_info, NULL)
+   PHP_FALIAS(fbird_blob_create,ibase_blob_create, NULL)
+   PHP_FALIAS(fbird_blob_add,ibase_blob_add, NULL)
+   PHP_FALIAS(fbird_blob_cancel,ibase_blob_cancel, NULL)
+   PHP_FALIAS(fbird_blob_close,ibase_blob_close, NULL)
+   PHP_FALIAS(fbird_blob_open,ibase_blob_open, NULL)
+   PHP_FALIAS(fbird_blob_get,ibase_blob_get, NULL)
+   PHP_FALIAS(fbird_blob_echo,ibase_blob_echo, NULL)
+   PHP_FALIAS(fbird_blob_import,ibase_blob_import, NULL)
+   PHP_FALIAS(fbird_errmsg,ibase_errmsg, NULL)
+   PHP_FALIAS(fbird_errcode,ibase_errcode, NULL)
+
+   PHP_FALIAS(fbird_add_user,ibase_add_user, NULL)
+   PHP_FALIAS(fbird_modify_user,ibase_modify_user, NULL)
+   PHP_FALIAS(fbird_delete_user,ibase_delete_user, NULL)
+
+   PHP_FALIAS(fbird_service_attach,ibase_service_attach, NULL)
+   PHP_FALIAS(fbird_service_detach,ibase_service_detach, NULL)
+   PHP_FALIAS(fbird_backup,ibase_backup, NULL)
+   PHP_FALIAS(fbird_restore,ibase_restore, NULL)
+   PHP_FALIAS(fbird_maintain_db,ibase_maintain_db, NULL)
+   PHP_FALIAS(fbird_db_info,ibase_db_info, NULL)
+   PHP_FALIAS(fbird_server_info,ibase_server_info, NULL)
+
+   PHP_FALIAS(fbird_wait_event,ibase_wait_event, NULL)
+   PHP_FALIAS(fbird_set_event_handler,ibase_set_event_handler, NULL)
+   PHP_FALIAS(fbird_free_event_handler,ibase_free_event_handler, NULL)
{NULL, NULL, NULL}
 };
 
@@ -660,13 +725,14 @@
if (SUCCESS == zend_hash_find(&EG(persistent_list), hash, sizeof(hash), (void 
*) &le)) {
static char info[] = { isc_info_base_level, isc_info_end };
char result[8];
+   ISC_STATUS status[20];
 
if (Z_TYPE_P(le) != le_plink) {
RETURN_FAL

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2004-05-12 Thread Ard Biesheuvel
abies   Wed May 12 09:14:55 2004 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Made ibase_timefmt() check its args more thoroughly and nuked a pointless malloc()
  
http://cvs.php.net/diff.php/php-src/ext/interbase/interbase.c?r1=1.212&r2=1.213&ty=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.212 php-src/ext/interbase/interbase.c:1.213
--- php-src/ext/interbase/interbase.c:1.212 Wed May 12 09:07:35 2004
+++ php-src/ext/interbase/interbase.c   Wed May 12 09:14:55 2004
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.212 2004/05/12 13:07:35 abies Exp $ */
+/* $Id: interbase.c,v 1.213 2004/05/12 13:14:55 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -30,7 +30,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.212 $"
+#define FILE_REVISION "$Revision: 1.213 $"
 
 #if HAVE_IBASE
 
@@ -1136,34 +1136,18 @@
 #endif
 /* }}} */
 
-#if HAVE_STRFTIME
 /* {{{ proto bool ibase_timefmt(string format [, int type ])
Sets the format of timestamp, date and time columns returned from queries */
 PHP_FUNCTION(ibase_timefmt)
 {
-   zval ***args;
-   char *fmt = NULL;
-   int type = PHP_IBASE_TIMESTAMP;
-   
-   if (ZEND_NUM_ARGS() < 1 || ZEND_NUM_ARGS() > 2) {
-   WRONG_PARAM_COUNT;
-   }
+   char *fmt;
+   int fmt_len;
+   long type = PHP_IBASE_TIMESTAMP;

-   args = (zval ***) safe_emalloc(sizeof(zval **), ZEND_NUM_ARGS(), 0);
-   if (zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {
-   efree(args);
+   if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &fmt, 
&fmt_len, &type)) {
RETURN_FALSE;
}
 
-   switch (ZEND_NUM_ARGS()) {
-   case 2:
-   convert_to_long_ex(args[1]);
-   type = Z_LVAL_PP(args[1]);
-   case 1:
-   convert_to_string_ex(args[0]);
-   fmt = Z_STRVAL_PP(args[0]);
-   }
-
switch (type) {
case PHP_IBASE_TIMESTAMP:
if (IBG(timestampformat)) {
@@ -1183,13 +1167,13 @@
}
IBG(timeformat) = DL_STRDUP(fmt);
break;
+   default:
+   RETURN_FALSE;
}
 
-   efree(args);
RETURN_TRUE;
 }
 /* }}} */
-#endif
 
 /* {{{ proto int ibase_gen_id(string generator [, int increment [, resource 
link_identifier ]])
Increments the named generator and returns its new value */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2004-05-12 Thread Ard Biesheuvel
abies   Wed May 12 09:07:35 2004 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Made ibase_gen_id() bail out on incorrect args
  
http://cvs.php.net/diff.php/php-src/ext/interbase/interbase.c?r1=1.211&r2=1.212&ty=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.211 php-src/ext/interbase/interbase.c:1.212
--- php-src/ext/interbase/interbase.c:1.211 Mon Apr  5 09:22:33 2004
+++ php-src/ext/interbase/interbase.c   Wed May 12 09:07:35 2004
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.211 2004/04/05 13:22:33 abies Exp $ */
+/* $Id: interbase.c,v 1.212 2004/05/12 13:07:35 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -30,7 +30,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.211 $"
+#define FILE_REVISION "$Revision: 1.212 $"
 
 #if HAVE_IBASE
 
@@ -1210,7 +1210,10 @@
 
RESET_ERRMSG;
 
-   zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lr", &generator, &gen_len, 
&inc, &link);
+   if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lr", 
&generator, &gen_len,
+   &inc, &link)) {
+   RETURN_FALSE;
+   }
 
PHP_IBASE_LINK_TRANS(link, ib_link, trans);


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2004-04-03 Thread Ard Biesheuvel
abies   Sat Apr  3 06:00:23 2004 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Change definition of ISC_LONG_[MIN|MAX] to please MSVC.
  
http://cvs.php.net/diff.php/php-src/ext/interbase/interbase.c?r1=1.209&r2=1.210&ty=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.209 php-src/ext/interbase/interbase.c:1.210
--- php-src/ext/interbase/interbase.c:1.209 Thu Apr  1 06:38:23 2004
+++ php-src/ext/interbase/interbase.c   Sat Apr  3 06:00:14 2004
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.209 2004/04/01 11:38:23 abies Exp $ */
+/* $Id: interbase.c,v 1.210 2004/04/03 11:00:14 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -30,7 +30,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.209 $"
+#define FILE_REVISION "$Revision: 1.210 $"
 
 #if HAVE_IBASE
 
@@ -50,8 +50,8 @@
 #define IBDEBUG(a)
 #endif
 
-#define ISC_LONG_MIN   (1 << (8*sizeof(ISC_LONG)-1))
-#define ISC_LONG_MAX   ~ISC_LONG_MIN
+#define ISC_LONG_MIN   INT_MIN
+#define ISC_LONG_MAX   INT_MAX
 
 #define QUERY_RESULT   1
 #define EXECUTE_RESULT 2
@@ -872,7 +872,7 @@
 {
char hash[16], *args[] = { NULL, NULL, NULL, NULL, NULL };
int i, len[] = { 0, 0, 0, 0, 0 };
-   long largs[] = { 0, SQL_DIALECT_CURRENT };
+   long largs[] = { 0, 0 };
PHP_MD5_CTX hash_context;
list_entry new_index_ptr, *le;
isc_db_handle db_handle = NULL;
@@ -2373,7 +2373,7 @@
ib_link->dialect = SQL_DIALECT_CURRENT;
ib_link->tr_list = NULL;
ib_link->event_head = NULL;
-   
+   
ZEND_REGISTER_RESOURCE(return_value, 
ib_link, le_link);

zend_list_addref(Z_LVAL_P(return_value));
IBG(default_link) = 
Z_LVAL_P(return_value);
@@ -2518,11 +2518,9 @@
 * - num_rows() for SELECT ... FOR UPDATE is broken -> never returns a
 *   higher number than the number of records fetched so far (no pre-fetch);
 * - the result of num_rows() for other statements is merely a lower bound 
-* on the number of records => calling ibase_num_rows() again after a couple
-* of fetches will most likely return a new (higher) figure for large result 
-* sets.
-*
-* 12-aug-2003 Ard Biesheuvel
+*   on the number of records => calling ibase_num_rows() again after a couple
+*   of fetches will most likely return a new (higher) figure for large result 
+*   sets.
 */

zval **result_arg;
@@ -3466,7 +3464,7 @@
}
 
/* don't return the generator value as a string unless it doesn't fit in a 
long */
-#ifdef SQL_INT64
+#if SQL_INT64 && SIZEOF_LONG < 8
if (result < LONG_MIN || result > LONG_MAX) {
char res[24];
 
@@ -3478,7 +3476,7 @@
 }
 
 /* }}} */
-
+
 #endif /* HAVE_IBASE */
 
 /*

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2004-04-01 Thread Ard Biesheuvel
abies   Thu Apr  1 06:38:25 2004 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  WS
  
  
http://cvs.php.net/diff.php/php-src/ext/interbase/interbase.c?r1=1.208&r2=1.209&ty=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.208 php-src/ext/interbase/interbase.c:1.209
--- php-src/ext/interbase/interbase.c:1.208 Thu Apr  1 05:56:28 2004
+++ php-src/ext/interbase/interbase.c   Thu Apr  1 06:38:23 2004
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.208 2004/04/01 10:56:28 abies Exp $ */
+/* $Id: interbase.c,v 1.209 2004/04/01 11:38:23 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -30,7 +30,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.208 $"
+#define FILE_REVISION "$Revision: 1.209 $"
 
 #if HAVE_IBASE
 
@@ -2372,7 +2372,7 @@
ib_link->handle = db;
ib_link->dialect = SQL_DIALECT_CURRENT;
ib_link->tr_list = NULL;
-ib_link->event_head = NULL;
+   ib_link->event_head = NULL;

ZEND_REGISTER_RESOURCE(return_value, 
ib_link, le_link);

zend_list_addref(Z_LVAL_P(return_value));

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2004-04-01 Thread Ard Biesheuvel
abies   Thu Apr  1 05:56:29 2004 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Fix unregistered bug (crash when closing db opened with "CREATE DATABASE ...")
  
http://cvs.php.net/diff.php/php-src/ext/interbase/interbase.c?r1=1.207&r2=1.208&ty=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.207 php-src/ext/interbase/interbase.c:1.208
--- php-src/ext/interbase/interbase.c:1.207 Mon Mar  8 05:49:17 2004
+++ php-src/ext/interbase/interbase.c   Thu Apr  1 05:56:28 2004
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.207 2004/03/08 10:49:17 abies Exp $ */
+/* $Id: interbase.c,v 1.208 2004/04/01 10:56:28 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -30,7 +30,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.207 $"
+#define FILE_REVISION "$Revision: 1.208 $"
 
 #if HAVE_IBASE
 
@@ -2372,6 +2372,7 @@
ib_link->handle = db;
ib_link->dialect = SQL_DIALECT_CURRENT;
ib_link->tr_list = NULL;
+ib_link->event_head = NULL;

ZEND_REGISTER_RESOURCE(return_value, 
ib_link, le_link);

zend_list_addref(Z_LVAL_P(return_value));

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2004-03-08 Thread Ard Biesheuvel
abies   Mon Mar  8 05:49:21 2004 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Merged some more odd fixes from my own branch
  
  
http://cvs.php.net/diff.php/php-src/ext/interbase/interbase.c?r1=1.206&r2=1.207&ty=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.206 php-src/ext/interbase/interbase.c:1.207
--- php-src/ext/interbase/interbase.c:1.206 Mon Mar  8 05:32:23 2004
+++ php-src/ext/interbase/interbase.c   Mon Mar  8 05:49:17 2004
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.206 2004/03/08 10:32:23 abies Exp $ */
+/* $Id: interbase.c,v 1.207 2004/03/08 10:49:17 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -30,7 +30,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.206 $"
+#define FILE_REVISION "$Revision: 1.207 $"
 
 #if HAVE_IBASE
 
@@ -860,7 +860,7 @@
dpb += sprintf(dpb, "%c\2%c%c", isc_dpb_num_buffers, 
(char)(largs[BUF] >> 8), (char)(largs[BUF] & 0xff));
}
-   if (isc_attach_database(IB_STATUS, len[DB], args[DB], db, 
(short)(dpb-dpb_buffer), dpb_buffer)) {
+   if (isc_attach_database(IB_STATUS, (short)len[DB], args[DB], db, 
(short)(dpb-dpb_buffer), dpb_buffer)) {
_php_ibase_error(TSRMLS_C);
return FAILURE;
}
@@ -1757,15 +1757,16 @@
 static void _php_ibase_alloc_xsqlda(XSQLDA *sqlda) /* {{{ */
 {
int i;
-   XSQLVAR *var = sqlda->sqlvar;
 
-   for (i = 0; i < sqlda->sqld; i++, var++) {
+   for (i = 0; i < sqlda->sqld; i++) {
+   XSQLVAR *var = &sqlda->sqlvar[i];
+
switch (var->sqltype & ~1) {
case SQL_TEXT:
-   var->sqldata = safe_emalloc(sizeof(char), 
(var->sqllen), 0);
+   var->sqldata = safe_emalloc(sizeof(char), var->sqllen, 
0);
break;
case SQL_VARYING:
-   var->sqldata = safe_emalloc(sizeof(char), (var->sqllen 
+ sizeof(short)), 0);
+   var->sqldata = safe_emalloc(sizeof(char), var->sqllen 
+ sizeof(short), 0);
break;
case SQL_SHORT:
var->sqldata = emalloc(sizeof(short));
@@ -2316,17 +2317,20 @@
 
/* use stack to avoid leaks */
args = (zval ***) do_alloca(sizeof(zval **) * ZEND_NUM_ARGS());
+
+   RETVAL_FALSE;
+
if (zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {
-   free_alloca(args);
-   RETURN_FALSE;
+   goto ibase_query_end;
+
}

i = 0;
while (Z_TYPE_PP(args[i++]) != IS_STRING) {
if (i >= ZEND_NUM_ARGS()) {
_php_ibase_module_error("Query argument missing" TSRMLS_CC);
-   free_alloca(args);
-   RETURN_FALSE;
+   goto ibase_query_end;
+
}
}
 
@@ -2347,8 +2351,7 @@
if (isc_dsql_execute_immediate(IB_STATUS, &db, &trans, 
0, query, 
SQL_DIALECT_CURRENT, NULL)) {
_php_ibase_error(TSRMLS_C);
-   free_alloca(args);
-   RETURN_FALSE;
+   goto ibase_query_end;
}

/* has a new database been created ? */
@@ -2359,8 +2362,7 @@
/* too many links already ? => close 
it up immediately */
if (isc_detach_database(IB_STATUS, 
&db)) {
_php_ibase_error(TSRMLS_C);
-   free_alloca(args);
-   RETURN_FALSE;
+   goto ibase_query_end;
}
} else {

@@ -2375,9 +2377,7 @@

zend_list_addref(Z_LVAL_P(return_value));
IBG(default_link) = 
Z_LVAL_P(return_value);
IBG(num_links)++;
-
-   free_alloca(args);
-   return;
+   goto ibase_query_end;
}
}
  

[PHP-CVS] cvs: php-src /ext/interbase interbase.c php_ibase_includes.h

2004-03-08 Thread Ard Biesheuvel
abies   Mon Mar  8 05:32:31 2004 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c php_ibase_includes.h 
  Log:
  Cleaned up array handling and optimize for the case where no array fields are used
  Fix timestamp binding for Win32 (which doesn't have gmtime_r())
  CS
  
  
  http://cvs.php.net/diff.php/php-src/ext/interbase/interbase.c?r1=1.205&r2=1.206&ty=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.205 php-src/ext/interbase/interbase.c:1.206
--- php-src/ext/interbase/interbase.c:1.205 Sun Mar  7 13:01:12 2004
+++ php-src/ext/interbase/interbase.c   Mon Mar  8 05:32:23 2004
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.205 2004/03/07 18:01:12 abies Exp $ */
+/* $Id: interbase.c,v 1.206 2004/03/08 10:32:23 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -30,7 +30,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.205 $"
+#define FILE_REVISION "$Revision: 1.206 $"
 
 #if HAVE_IBASE
 
@@ -488,8 +488,7 @@
 }
 /* }}} */
 
-/* {{{ php_ibase_free_query_rsrc() */
-static void php_ibase_free_query_rsrc(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+static void php_ibase_free_query_rsrc(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ */
 {
ibase_query *ib_query = (ibase_query *)rsrc->ptr;
 
@@ -785,17 +784,16 @@
 
 #if defined(__GNUC__) || defined(PHP_WIN32)
do {
+   info_func_t info_func = NULL;
 #ifdef __GNUC__
-   void (*info_func)(char*) = (void(*)(char*))dlsym(RTLD_DEFAULT, 
"isc_get_client_version");
+   info_func = (info_func_t)dlsym(RTLD_DEFAULT, "isc_get_client_version");
 #else
-   void (__stdcall *info_func)(char*);
-
HMODULE l = GetModuleHandle("fbclient");
 
if (!l && !(l = GetModuleHandle("gds32"))) {
break;
}
-   info_func = (void (__stdcall *)(char*))GetProcAddress(l, 
"isc_get_client_version");
+   info_func = (info_func_t)GetProcAddress(l, "isc_get_client_version");
 #endif
if (info_func) {
info_func(s = tmp);
@@ -984,7 +982,7 @@
++IBG(num_persistent);
}
ib_link->handle = db_handle;
-   ib_link->dialect = (unsigned short)largs[DLECT];
+   ib_link->dialect = largs[DLECT] ? (unsigned short)largs[DLECT] : 
SQL_DIALECT_CURRENT;
ib_link->tr_list = NULL;
ib_link->event_head = NULL;
 
@@ -1061,9 +1059,9 @@
ibase_db_link *ib_link;
ibase_tr_list *l;
int link_id;
-   
+
RESET_ERRMSG;
-   
+
switch (ZEND_NUM_ARGS()) {
case 0:
link_id = IBG(default_link);
@@ -1099,75 +1097,82 @@
 /* }}} */
 
 static int _php_ibase_alloc_array(ibase_array **ib_arrayp, XSQLDA *sqlda, /* {{{ */
-   isc_db_handle link, isc_tr_handle trans TSRMLS_DC)
+   isc_db_handle link, isc_tr_handle trans, unsigned short *array_cnt TSRMLS_DC)
 {
-#define IB_ARRAY (*ib_arrayp)
-
-   unsigned short i;
-   XSQLVAR *var = sqlda->sqlvar;
+   unsigned short i, n;
+   ibase_array *ar;
 
-   IB_ARRAY = safe_emalloc(sizeof(ibase_array), sqlda->sqld, 0);
+   /* first check if we have any arrays at all */
+   for (i = *array_cnt = 0; i < sqlda->sqld; ++i) {
+   if ((sqlda->sqlvar[i].sqltype & ~1) == SQL_ARRAY) {
+   ++*array_cnt;
+   }
+   }
+   if (! *array_cnt) return SUCCESS;

-   for (i = 0; i < sqlda->sqld; i++, var++) {
+   ar = safe_emalloc(sizeof(ibase_array), *array_cnt, 0);
+   
+   for (i = n = 0; i < sqlda->sqld; ++i) {
unsigned short dim;
unsigned long ar_size = 1;
+   XSQLVAR *var = &sqlda->sqlvar[i];

if ((var->sqltype & ~1) == SQL_ARRAY) {
-   ISC_ARRAY_DESC *ar_desc = &IB_ARRAY[i].ar_desc;
+   ibase_array *a = &ar[n++];
+   ISC_ARRAY_DESC *ar_desc = &a->ar_desc;

if (isc_array_lookup_bounds(IB_STATUS, &link, &trans, 
var->relname,
var->sqlname, ar_desc)) {
_php_ibase_error(TSRMLS_C);
-   efree(IB_ARRAY);
-   IB_ARRAY = NULL;
+   efree(ar);
return FAILURE;
}
 
switch (ar_desc->array_desc_dtype) {
case blr_text:
case blr_text2:
-   IB_ARRAY[i].el_type = SQL_TEXT;
-   IB_ARRAY[i].el_size = 
ar_desc->array_desc_length;
+   a->el_type

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2004-03-07 Thread Ard Biesheuvel
abies   Sun Mar  7 13:01:14 2004 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Simplify / fix
  
  
http://cvs.php.net/diff.php/php-src/ext/interbase/interbase.c?r1=1.204&r2=1.205&ty=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.204 php-src/ext/interbase/interbase.c:1.205
--- php-src/ext/interbase/interbase.c:1.204 Sun Mar  7 09:25:08 2004
+++ php-src/ext/interbase/interbase.c   Sun Mar  7 13:01:12 2004
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.204 2004/03/07 14:25:08 abies Exp $ */
+/* $Id: interbase.c,v 1.205 2004/03/07 18:01:12 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -30,7 +30,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.204 $"
+#define FILE_REVISION "$Revision: 1.205 $"
 
 #if HAVE_IBASE
 
@@ -1571,6 +1571,8 @@
var->sqltype = SQL_TEXT;
}
 
+   var->sqldata = (void*)&buf[i];
+   
switch (var->sqltype & ~1) {
struct tm t;
 
@@ -1579,9 +1581,9 @@
if (Z_LVAL_P(b_var) > SHRT_MAX || 
Z_LVAL_P(b_var) < SHRT_MIN) {
_php_ibase_module_error("Parameter %d 
exceeds field width" TSRMLS_CC, i+1);
rv = FAILURE;
+   break;
}
buf[i].val.sval = (short) Z_LVAL_P(b_var);
-   var->sqldata = (void *) &buf[i].val.sval;
break;
case SQL_LONG:
convert_to_long(b_var);
@@ -1590,10 +1592,10 @@
if (Z_LVAL_P(b_var) > ISC_LONG_MAX || 
Z_LVAL_P(b_var) < ISC_LONG_MIN) {
_php_ibase_module_error("Parameter %d 
exceeds field width" TSRMLS_CC, i+1);
rv = FAILURE;
+   break;
}
 #endif
buf[i].val.lval = (ISC_LONG) Z_LVAL_P(b_var);
-   var->sqldata = (void *) &buf[i].val.lval;
break;
 #if defined(SQL_INT64) && (SIZEOF_LONG == 8)
case SQL_INT64:
@@ -1604,7 +1606,6 @@
case SQL_FLOAT:
convert_to_double(b_var);
buf[i].val.fval = (float) Z_DVAL_P(b_var);
-   var->sqldata = (void *) &buf[i].val.fval;
break;
case SQL_DOUBLE:
convert_to_double(b_var);
@@ -1660,22 +1661,16 @@
 
 #ifndef SQL_TIMESTAMP
isc_encode_date(&t, &buf[i].val.qval);
-   var->sqldata = (void *) (&buf[i].val.qval);
 #else
switch (var->sqltype & ~1) {
default: /* == case SQL_TIMESTAMP */
isc_encode_timestamp(&t, 
&buf[i].val.tsval);
-   var->sqldata = (void *) 
(&buf[i].val.tsval);
break;
case SQL_TYPE_DATE:
-   strptime(Z_STRVAL_P(b_var), 
IBG(dateformat), &t);
isc_encode_sql_date(&t, 
&buf[i].val.dtval);
-   var->sqldata = (void *) 
(&buf[i].val.dtval);
break;
case SQL_TYPE_TIME:
-   strptime(Z_STRVAL_P(b_var), 
IBG(timeformat), &t);
isc_encode_sql_time(&t, 
&buf[i].val.tmval);
-   var->sqldata = (void *) 
(&buf[i].val.tmval);
break;
 #endif
}
@@ -1705,7 +1700,6 @@
}
buf[i].val.qval = ib_blob.bl_qd;
}
-   var->sqldata = (void *) &buf[i].val.qval;

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2004-03-07 Thread Ard Biesheuvel
abies   Sun Mar  7 09:25:09 2004 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Added missing support for binding timestamps
  # Returning timestamps was already supported
  
  
http://cvs.php.net/diff.php/php-src/ext/interbase/interbase.c?r1=1.203&r2=1.204&ty=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.203 php-src/ext/interbase/interbase.c:1.204
--- php-src/ext/interbase/interbase.c:1.203 Fri Feb 20 05:59:23 2004
+++ php-src/ext/interbase/interbase.c   Sun Mar  7 09:25:08 2004
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.203 2004/02/20 10:59:23 abies Exp $ */
+/* $Id: interbase.c,v 1.204 2004/03/07 14:25:08 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -30,7 +30,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.203 $"
+#define FILE_REVISION "$Revision: 1.204 $"
 
 #if HAVE_IBASE
 
@@ -252,7 +252,7 @@
float fval;
ISC_LONG lval;
ISC_QUAD qval;
-#ifdef ISC_TIMESTAMP
+#ifdef SQL_TIMESTAMP
ISC_TIMESTAMP tsval;
ISC_DATE dtval;
ISC_TIME tmval;
@@ -796,7 +796,7 @@
break;
}
info_func = (void (__stdcall *)(char*))GetProcAddress(l, 
"isc_get_client_version");
-#endif 
+#endif
if (info_func) {
info_func(s = tmp);
} else {
@@ -1026,7 +1026,7 @@
zval **link_arg = NULL;
ibase_db_link *ib_link;
int link_id;
-   
+
RESET_ERRMSG;

switch (ZEND_NUM_ARGS()) {
@@ -1200,7 +1200,7 @@

/* calculate elements count */
for (dim = 0; dim < ar_desc->array_desc_dimensions; dim++) {
-   ar_size *= 1 + 
ar_desc->array_desc_bounds[dim].array_bound_upper 
+   ar_size *= 1 + 
ar_desc->array_desc_bounds[dim].array_bound_upper

-ar_desc->array_desc_bounds[dim].array_bound_lower;
}
IB_ARRAY[i].ar_size = IB_ARRAY[i].el_size * ar_size;
@@ -1347,8 +1347,8 @@
{
subval = &pnull_val;
}
-   
-   if (_php_ibase_bind_array(*subval, buf, slice_size, array, 
dim+1 TSRMLS_CC) == FAILURE) 
+
+   if (_php_ibase_bind_array(*subval, buf, slice_size, array, 
dim+1 TSRMLS_CC) == FAILURE)
{
return FAILURE;
}
@@ -1549,16 +1549,16 @@
XSQLVAR *var = sqlda->sqlvar;
 
for (i = 0; i < sqlda->sqld; ++var, ++i) { /* bound vars */
-   
+
zval *b_var = b_vars[i];
 
var->sqlind = &buf[i].sqlind;
-   
+
if (Z_TYPE_P(b_var) == IS_NULL) {
-   if ((var->sqltype & 1) != 1) {
-   _php_ibase_module_error("Parameter %d must have a 
value" TSRMLS_CC, i+1);
-   rv = FAILURE;
-   }
+   if ((var->sqltype & 1) != 1) {
+   _php_ibase_module_error("Parameter %d must have a 
value" TSRMLS_CC, i+1);
+   rv = FAILURE;
+   }
buf[i].sqlind = -1;
} else {
buf[i].sqlind = 0;
@@ -1570,8 +1570,10 @@
*/
var->sqltype = SQL_TEXT;
}
-   
+
switch (var->sqltype & ~1) {
+   struct tm t;
+
case SQL_SHORT:
convert_to_long(b_var);
if (Z_LVAL_P(b_var) > SHRT_MAX || 
Z_LVAL_P(b_var) < SHRT_MIN) {
@@ -1608,80 +1610,91 @@
convert_to_double(b_var);
var->sqldata = (void *) &Z_DVAL_P(b_var);
break;
+
+   case SQL_DATE: /* == SQL_TIMESTAMP: */
+#ifdef SQL_TIMESTAMP
+   case SQL_TYPE_DATE:
+   case SQL_TYPE_TIME:
+#endif
+   if (Z_TYPE_P(b_var) == IS_LONG) {
+   /* insert timestamp directly */
+   gmtime_r(&Z_LVAL_P(b_var),&t);
+   } else {
+#ifndef HAVE_STRPTIME
 #ifndef SQL_TIMESTAMP
-   case SQL_DATE:
- 

[PHP-CVS] cvs: php-src /ext/interbase interbase.c php_ibase_includes.h

2004-02-20 Thread Ard Biesheuvel
abies   Fri Feb 20 05:59:24 2004 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c php_ibase_includes.h 
  Log:
  Fix some issues with persistent links
  
  http://cvs.php.net/diff.php/php-src/ext/interbase/interbase.c?r1=1.202&r2=1.203&ty=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.202 php-src/ext/interbase/interbase.c:1.203
--- php-src/ext/interbase/interbase.c:1.202 Tue Feb 17 07:53:53 2004
+++ php-src/ext/interbase/interbase.c   Fri Feb 20 05:59:23 2004
@@ -14,11 +14,11 @@
+--+
| Authors: Jouni Ahto <[EMAIL PROTECTED]>|
|  Andrew Avdeev <[EMAIL PROTECTED]>  |
-   |  Ard Biesheuvel <[EMAIL PROTECTED]>  |
+   |  Ard Biesheuvel <[EMAIL PROTECTED]>  |
+--+
  */
 
-/* $Id: interbase.c,v 1.202 2004/02/17 12:53:53 abies Exp $ */
+/* $Id: interbase.c,v 1.203 2004/02/20 10:59:23 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -30,12 +30,13 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.202 $"
+#define FILE_REVISION "$Revision: 1.203 $"
 
 #if HAVE_IBASE
 
 #include "php_ini.h"
 #include "ext/standard/php_standard.h"
+#include "ext/standard/md5.h"
 #include "php_interbase.h"
 #include "php_ibase_includes.h"
 
@@ -49,10 +50,8 @@
 #define IBDEBUG(a)
 #endif
 
-#define SAFE_STRING(s) ((s)?(s):"")
-
-#define ISC_LONG_MIN (-ISC_LONG_MAX - 1)
-#define ISC_LONG_MAX 2147483647
+#define ISC_LONG_MIN   (1 << (8*sizeof(ISC_LONG)-1))
+#define ISC_LONG_MAX   ~ISC_LONG_MIN
 
 #define QUERY_RESULT   1
 #define EXECUTE_RESULT 2
@@ -64,8 +63,6 @@
 #define FETCH_ROW  1
 #define FETCH_ARRAY2
 
-#define HASH_MASK  "ibase_%s_%s_%s_%s_%s_%s_%s"
-
 /* {{{ extension definition structures */
 function_entry ibase_functions[] = {
PHP_FE(ibase_connect, NULL)
@@ -581,8 +578,10 @@
STD_PHP_INI_BOOLEAN("ibase.allow_persistent", "1", PHP_INI_SYSTEM, 
OnUpdateLong, allow_persistent, zend_ibase_globals, ibase_globals)
STD_PHP_INI_ENTRY_EX("ibase.max_persistent", "-1", PHP_INI_SYSTEM, 
OnUpdateLong, max_persistent, zend_ibase_globals, ibase_globals, display_link_numbers)
STD_PHP_INI_ENTRY_EX("ibase.max_links", "-1", PHP_INI_SYSTEM, OnUpdateLong, 
max_links, zend_ibase_globals, ibase_globals, display_link_numbers)
+   STD_PHP_INI_ENTRY("ibase.default_db", NULL, PHP_INI_SYSTEM, OnUpdateString, 
default_db, zend_ibase_globals, ibase_globals)
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.default_charset", NULL, PHP_INI_ALL, OnUpdateString, 
default_charset, 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)
@@ -839,60 +838,31 @@
 }
 /* }}} */
 
-int _php_ibase_attach_db(char *server, char *uname, char *passwd, char *charset, /* 
{{{ */
-   int buffers, char *role, isc_db_handle *db TSRMLS_DC)
+enum connect_args { DB = 0, USER = 1, PASS = 2, CSET = 3, ROLE = 4, BUF = 0, DLECT = 
1 };
+   
+static char const dpb_args[] = { 0, isc_dpb_user_name, isc_dpb_password, 
isc_dpb_lc_ctype
+#ifdef isc_dpb_sql_role_name
+   , isc_dpb_sql_role_name
+#endif
+};
+   
+int _php_ibase_attach_db(char **args, int *len, long *largs, isc_db_handle *db 
TSRMLS_DC)
 {
-   char dpb_buffer[256], *dpb, *p;
-   int dpb_length, len;
-
-   dpb = dpb_buffer;
-
-   *dpb++ = isc_dpb_version1;
-
-   if (uname != NULL && (len = strlen(uname))) {
-   *dpb++ = isc_dpb_user_name;
-   *dpb++ = len;
-   for (p = uname; *p;) {
-   *dpb++ = *p++;
-   }
-   }
+   short i;
+   char dpb_buffer[256] = { isc_dpb_version1 }, *dpb;
 
-   if (passwd != NULL && (len = strlen(passwd))) {
-   *dpb++ = isc_dpb_password;
-   *dpb++ = strlen(passwd);
-   for (p = passwd; *p;) {
-   *dpb++ = *p++;
-   }
-   }
+   dpb = dpb_buffer + 1;
 
-   if (charset != NULL && (len = strlen(charset))) {
-   *dpb++ = isc_dpb_lc_ctype;
-   *dpb++ = strlen(charset);
-   for (p = charset; 

[PHP-CVS] cvs: php-src /ext/interbase interbase.c /ext/interbase/tests 003.phpt

2004-02-15 Thread Ard Biesheuvel
abies   Sun Feb 15 13:34:48 2004 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
/php-src/ext/interbase/tests003.phpt 
  Log:
  Reintroduce param NULL testing (see bug #26777)
  
  
http://cvs.php.net/diff.php/php-src/ext/interbase/interbase.c?r1=1.200&r2=1.201&ty=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.200 php-src/ext/interbase/interbase.c:1.201
--- php-src/ext/interbase/interbase.c:1.200 Wed Feb 11 07:08:44 2004
+++ php-src/ext/interbase/interbase.c   Sun Feb 15 13:34:46 2004
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.200 2004/02/11 12:08:44 abies Exp $ */
+/* $Id: interbase.c,v 1.201 2004/02/15 18:34:46 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -30,7 +30,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.200 $"
+#define FILE_REVISION "$Revision: 1.201 $"
 
 #if HAVE_IBASE
 
@@ -754,7 +754,7 @@
 #ifdef __GNUC__
void (*info_func)(char*) = dlsym(RTLD_DEFAULT, 
"isc_get_client_version");
 #else
-   void (__stdcall *info_func)(char*) = NULL;
+   void (__stdcall *info_func)(char*);
 
HMODULE l = GetModuleHandle("fbclient");
 
@@ -1615,8 +1615,8 @@
 }  
 /* }}} */
 
-static int _php_ibase_bind(XSQLDA *sqlda, zval **b_vars, BIND_BUF *buf,
-   ibase_query *ib_query TSRMLS_DC) /* {{{ */
+static int _php_ibase_bind(XSQLDA *sqlda, zval **b_vars, BIND_BUF *buf, /* {{{ */
+   ibase_query *ib_query TSRMLS_DC)
 {
int i, rv = SUCCESS;
XSQLVAR *var = sqlda->sqlvar;
@@ -1628,6 +1628,10 @@
var->sqlind = &buf[i].sqlind;

if (Z_TYPE_P(b_var) == IS_NULL) {
+   if ((var->sqltype & 1) != 1) {
+   _php_ibase_module_error("Parameter %d must have a 
value" TSRMLS_CC, i+1);
+   rv = FAILURE;
+   }
buf[i].sqlind = -1;
} else {
buf[i].sqlind = 0;
http://cvs.php.net/diff.php/php-src/ext/interbase/tests/003.phpt?r1=1.5&r2=1.6&ty=u
Index: php-src/ext/interbase/tests/003.phpt
diff -u php-src/ext/interbase/tests/003.phpt:1.5 
php-src/ext/interbase/tests/003.phpt:1.6
--- php-src/ext/interbase/tests/003.phpt:1.5Fri Sep  5 13:02:02 2003
+++ php-src/ext/interbase/tests/003.phptSun Feb 15 13:34:47 2004
@@ -5,14 +5,14 @@
 --POST--
 --GET--
 --FILE--
-V_NUMERIC15_15\n";
 }
-if($row->V_NUMERIC15_0 != $v_numeric15_0){
+if($row->V_NUMERIC15_0 != (string)$v_numeric15_0){
 echo " NUMERIC15_0 fail\n";
 echo " in:  $v_numeric15_0\n";
 echo " out: $row->V_NUMERIC15_0\n";

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2004-02-11 Thread Ard Biesheuvel
abies   Wed Feb 11 07:08:45 2004 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Add version info about run-time client library
  # A number of user crashes appear to be caused
  # by using incorrect combinations of libraries
  
  
http://cvs.php.net/diff.php/php-src/ext/interbase/interbase.c?r1=1.199&r2=1.200&ty=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.199 php-src/ext/interbase/interbase.c:1.200
--- php-src/ext/interbase/interbase.c:1.199 Fri Feb  6 10:11:17 2004
+++ php-src/ext/interbase/interbase.c   Wed Feb 11 07:08:44 2004
@@ -18,15 +18,19 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.199 2004/02/06 15:11:17 abies Exp $ */
+/* $Id: interbase.c,v 1.200 2004/02/11 12:08:44 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
+#ifdef __GNUC__
+#define _GNU_SOURCE
+#endif
+
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.199 $"
+#define FILE_REVISION "$Revision: 1.200 $"
 
 #if HAVE_IBASE
 
@@ -727,21 +731,50 @@
  
 PHP_MINFO_FUNCTION(ibase)
 {
-   char tmp[64];
+   char tmp[64], *s;
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
 
-#if (SQLDA_CURRENT_VERSION > 1) || defined(FB_SQLDA)
-   isc_get_client_version(tmp);
-   php_info_print_table_row(2, "Client Library", tmp);
+#ifdef FB_API_VER
+   sprintf( (s = tmp), "Firebird API version %d", FB_API_VER);
+#elif (SQLDA_CURRENT_VERSION > 1)
+   s =  "Interbase 7.0 and up";
 #elif (SQL_DIALECT_CURRENT == 1)
-   php_info_print_table_row(2, "Client Library", "Interbase 5.6 or earlier");
+   s =  "Interbase 5.6 or earlier";
 #elif !defined(DSC_null)
-   php_info_print_table_row(2, "Client Library", "Interbase 6");
+   s = "Interbase 6";
+#else
+   s = "Firebird 1.0";
+#endif
+   php_info_print_table_row(2, "Compile-time Client Library Version", s);
+
+#if defined(__GNUC__) || defined(PHP_WIN32)
+   do {
+#ifdef __GNUC__
+   void (*info_func)(char*) = dlsym(RTLD_DEFAULT, 
"isc_get_client_version");
+#else
+   void (__stdcall *info_func)(char*) = NULL;
+
+   HMODULE l = GetModuleHandle("fbclient");
+
+   if (!l && !(l = GetModuleHandle("gds32"))) {
+   break;
+   }
+   info_func = (void (__stdcall *)(char*))GetProcAddress(l, 
"isc_get_client_version");
+#endif 
+   if (info_func) {
+   info_func(s = tmp);
+   } else {
+#if HAVE_IBASE6_API
+   s = "Firebird 1.0/Interbase 6";
 #else
-   php_info_print_table_row(2, "Client Library", "Firebird 1.0");
+   s = "Firebird 1.0/Interbase 6 or earlier";
 #endif
+   }
+   php_info_print_table_row(2, "Run-time Client Library Version", s);
+   } while (0);
+#endif 
 
php_info_print_table_row(2, "Revision", FILE_REVISION);
 #ifdef COMPILE_DL_INTERBASE

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2004-01-21 Thread Ard Biesheuvel
abies   Wed Jan 21 05:22:05 2004 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  MFB
  
  
http://cvs.php.net/diff.php/php-src/ext/interbase/interbase.c?r1=1.193&r2=1.194&ty=u
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.193 php-src/ext/interbase/interbase.c:1.194
--- php-src/ext/interbase/interbase.c:1.193 Mon Jan 12 15:03:49 2004
+++ php-src/ext/interbase/interbase.c   Wed Jan 21 05:22:04 2004
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.193 2004/01/12 20:03:49 abies Exp $ */
+/* $Id: interbase.c,v 1.194 2004/01/21 10:22:04 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -26,7 +26,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.193 $"
+#define FILE_REVISION "$Revision: 1.194 $"
 
 #if HAVE_IBASE
 
@@ -696,6 +696,25 @@
 
 PHP_MSHUTDOWN_FUNCTION(ibase)
 {
+#ifndef PHP_WIN32
+   /**
+* When the Interbase client API library libgds.so is first loaded, it 
registers a call to 
+* gds__cleanup() with atexit(), in order to clean up after itself when the 
process exits.
+* This means that the library is called at process shutdown, and cannot be 
unloaded beforehand.
+* PHP tries to unload modules after every request [dl()'ed modules], and 
right before the 
+* process shuts down [modules loaded from php.ini]. This results in a 
segfault for this module.
+* By NULLing the dlopen() handle in the module entry, Zend omits the call to 
dlclose(),
+* ensuring that the module will remain present until the process exits. 
However, the functions
+* and classes exported by the module will not be available until the module 
is 'reloaded'. 
+* When reloaded, dlopen() will return the handle of the already loaded 
module. The module will
+* be unloaded automatically when the process exits.
+*/
+   zend_module_entry *ibase_entry;
+   if (SUCCESS == zend_hash_find(&module_registry, ibase_module_entry.name, 
strlen(ibase_module_entry.name) +1, (void*) &ibase_entry))
+   {
+   ibase_entry->handle = NULL;
+   }
+#endif
UNREGISTER_INI_ENTRIES();
return SUCCESS;
 }

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2004-01-12 Thread Ard Biesheuvel
abies   Mon Jan 12 15:03:50 2004 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  More handsome solution for previous fix
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.192 php-src/ext/interbase/interbase.c:1.193
--- php-src/ext/interbase/interbase.c:1.192 Mon Jan 12 14:47:28 2004
+++ php-src/ext/interbase/interbase.c   Mon Jan 12 15:03:49 2004
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.192 2004/01/12 19:47:28 abies Exp $ */
+/* $Id: interbase.c,v 1.193 2004/01/12 20:03:49 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -26,7 +26,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.192 $"
+#define FILE_REVISION "$Revision: 1.193 $"
 
 #if HAVE_IBASE
 
@@ -831,6 +831,7 @@
 {
zval ***args;
char *ib_server = NULL, *ib_uname, *ib_passwd, *ib_charset = NULL, *ib_buffers 
= NULL, *ib_dialect = NULL, *ib_role = NULL;
+   unsigned short sql_dialect = SQL_DIALECT_CURRENT;
int ib_uname_len, ib_passwd_len;
isc_db_handle db_handle = NULL;
char *hashed_details;
@@ -855,6 +856,8 @@
}
 
switch (ZEND_NUM_ARGS()) {
+   unsigned short d;
+   
case 7:
convert_to_string_ex(args[6]);
ib_role = Z_STRVAL_PP(args[6]);
@@ -863,6 +866,10 @@
case 6:
convert_to_string_ex(args[5]);
ib_dialect = Z_STRVAL_PP(args[5]);
+   if ((d = (unsigned short)strtoul(ib_dialect, NULL, 10))) 
+   {
+   sql_dialect = d;
+   }
hashed_details_length += Z_STRLEN_PP(args[5]);
/* fallout */
case 5:
@@ -940,10 +947,7 @@
 
ib_link = (ibase_db_link *) malloc(sizeof(ibase_db_link));
ib_link->handle = db_handle;
-   if (ib_dialect) {
-   unsigned short d = (unsigned short)strtoul(ib_dialect, 
NULL, 10);
-   ib_link->dialect = (d ? d : SQL_DIALECT_CURRENT);
-   }
+   ib_link->dialect = sql_dialect;
ib_link->tr_list = NULL;
 
/* hash it up */
@@ -1005,10 +1009,7 @@
 
ib_link = (ibase_db_link *) emalloc(sizeof(ibase_db_link));
ib_link->handle = db_handle;
-   if (ib_dialect) {
-   unsigned short d = (unsigned short)strtoul(ib_dialect, NULL, 
10);
-   ib_link->dialect = (d ? d : SQL_DIALECT_CURRENT);
-   }
+   ib_link->dialect = sql_dialect;
ib_link->tr_list = NULL;

ZEND_REGISTER_RESOURCE(return_value, ib_link, le_link);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2004-01-12 Thread Ard Biesheuvel
abies   Mon Jan 12 14:47:29 2004 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Added sanity check on ibase_[p]connect() dialect argument (fixes obscure 
unregistered bug)
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.191 php-src/ext/interbase/interbase.c:1.192
--- php-src/ext/interbase/interbase.c:1.191 Thu Jan  8 03:15:50 2004
+++ php-src/ext/interbase/interbase.c   Mon Jan 12 14:47:28 2004
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.191 2004/01/08 08:15:50 andi Exp $ */
+/* $Id: interbase.c,v 1.192 2004/01/12 19:47:28 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -26,7 +26,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.191 $"
+#define FILE_REVISION "$Revision: 1.192 $"
 
 #if HAVE_IBASE
 
@@ -940,7 +940,10 @@
 
ib_link = (ibase_db_link *) malloc(sizeof(ibase_db_link));
ib_link->handle = db_handle;
-   ib_link->dialect = (ib_dialect ? (unsigned short) 
strtoul(ib_dialect, NULL, 10) : SQL_DIALECT_CURRENT);
+   if (ib_dialect) {
+   unsigned short d = (unsigned short)strtoul(ib_dialect, 
NULL, 10);
+   ib_link->dialect = (d ? d : SQL_DIALECT_CURRENT);
+   }
ib_link->tr_list = NULL;
 
/* hash it up */
@@ -1002,7 +1005,10 @@
 
ib_link = (ibase_db_link *) emalloc(sizeof(ibase_db_link));
ib_link->handle = db_handle;
-   ib_link->dialect = (ib_dialect ? (unsigned short) strtoul(ib_dialect, 
NULL, 10) : SQL_DIALECT_CURRENT);
+   if (ib_dialect) {
+   unsigned short d = (unsigned short)strtoul(ib_dialect, NULL, 
10);
+   ib_link->dialect = (d ? d : SQL_DIALECT_CURRENT);
+   }
ib_link->tr_list = NULL;

ZEND_REGISTER_RESOURCE(return_value, ib_link, le_link);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2004-01-07 Thread Ard Biesheuvel
abies   Wed Jan  7 04:43:56 2004 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Let DB handle NULL params, fixes bug #26777
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.189 php-src/ext/interbase/interbase.c:1.190
--- php-src/ext/interbase/interbase.c:1.189 Fri Sep 26 06:06:22 2003
+++ php-src/ext/interbase/interbase.c   Wed Jan  7 04:43:55 2004
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.189 2003/09/26 10:06:22 abies Exp $ */
+/* $Id: interbase.c,v 1.190 2004/01/07 09:43:55 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -26,7 +26,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.189 $"
+#define FILE_REVISION "$Revision: 1.190 $"
 
 #if HAVE_IBASE
 
@@ -1578,12 +1578,6 @@
var->sqlind = &buf[i].sqlind;

if (Z_TYPE_P(b_var) == IS_NULL) {
-
-   if ((var->sqltype & 1) != 1) {
-   _php_ibase_module_error("Parameter %d must have a 
value" TSRMLS_CC, i+1);
-   rv = FAILURE;
-   }
-
buf[i].sqlind = -1;
} else {
buf[i].sqlind = 0;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c php_interbase.h

2003-09-26 Thread Ard Biesheuvel
abies   Fri Sep 26 06:06:23 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c php_interbase.h 
  Log:
  Let client library pick its own transaction param defaults
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.188 php-src/ext/interbase/interbase.c:1.189
--- php-src/ext/interbase/interbase.c:1.188 Tue Sep 23 19:08:59 2003
+++ php-src/ext/interbase/interbase.c   Fri Sep 26 06:06:22 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.188 2003/09/23 23:08:59 abies Exp $ */
+/* $Id: interbase.c,v 1.189 2003/09/26 10:06:22 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -26,7 +26,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.188 $"
+#define FILE_REVISION "$Revision: 1.189 $"
 
 #if HAVE_IBASE
 
@@ -2068,7 +2068,7 @@
convert_to_long_ex(args[i]);
trans_argl = Z_LVAL_PP(args[i]);
 
-   if (trans_argl) {
+   if (trans_argl != PHP_IBASE_DEFAULT) {
last_tpb[tpb_len++] = isc_tpb_version3;
 
/* access mode */
Index: php-src/ext/interbase/php_interbase.h
diff -u php-src/ext/interbase/php_interbase.h:1.62 
php-src/ext/interbase/php_interbase.h:1.63
--- php-src/ext/interbase/php_interbase.h:1.62  Tue Sep 23 16:58:14 2003
+++ php-src/ext/interbase/php_interbase.h   Fri Sep 26 06:06:22 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: php_interbase.h,v 1.62 2003/09/23 20:58:14 abies Exp $ */
+/* $Id: php_interbase.h,v 1.63 2003/09/26 10:06:22 abies Exp $ */
 
 #ifndef PHP_INTERBASE_H
 #define PHP_INTERBASE_H
@@ -186,17 +186,17 @@
PHP_IBASE_DATE  = 2,
PHP_IBASE_TIME  = 4,
/* transaction access mode */   
-   PHP_IBASE_WRITE = 0, /* default */
-   PHP_IBASE_READ  = 1,
+   PHP_IBASE_WRITE = 1,
+   PHP_IBASE_READ  = 2,
/* transaction isolation level */
-   PHP_IBASE_CONCURRENCY   = 0, /* default */
-   PHP_IBASE_COMMITTED = 2,
- PHP_IBASE_REC_NO_VERSION  = 0, /* default */
- PHP_IBASE_REC_VERSION = 4,
-   PHP_IBASE_CONSISTENCY   = 8,
+   PHP_IBASE_CONCURRENCY   = 4,
+   PHP_IBASE_COMMITTED = 8,
+ PHP_IBASE_REC_NO_VERSION  = 32,
+ PHP_IBASE_REC_VERSION = 64,
+   PHP_IBASE_CONSISTENCY   = 16,
/* transaction lock resolution */
-   PHP_IBASE_WAIT  = 0, /* default */
-   PHP_IBASE_NOWAIT= 16
+   PHP_IBASE_WAIT  = 128,
+   PHP_IBASE_NOWAIT= 256
 };
 
 #ifdef ZTS

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-09-23 Thread Ard Biesheuvel
abies   Tue Sep 23 19:09:08 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Always return long from ibase_gen_id() on IB < 6 
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.187 php-src/ext/interbase/interbase.c:1.188
--- php-src/ext/interbase/interbase.c:1.187 Tue Sep 23 18:17:40 2003
+++ php-src/ext/interbase/interbase.c   Tue Sep 23 19:08:59 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.187 2003/09/23 22:17:40 sniper Exp $ */
+/* $Id: interbase.c,v 1.188 2003/09/23 23:08:59 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -26,7 +26,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.187 $"
+#define FILE_REVISION "$Revision: 1.188 $"
 
 #if HAVE_IBASE
 
@@ -3306,7 +3306,7 @@
precision = 9;
break;
 #ifdef SQL_INT64
-   case SQL_INT64: 
+   case SQL_INT64:
precision = 18;
break;
 #endif
@@ -3317,8 +3317,8 @@
} else {
switch (var->sqltype & ~1) {
case SQL_TEXT:
-   s = "CHAR"; 
-   break;
+   s = "CHAR"; 
+   break;
case SQL_VARYING:
s = "VARCHAR"; 
break;
@@ -3328,13 +3328,13 @@
case SQL_LONG:
s = "INTEGER"; 
break;
-   case SQL_FLOAT: 
+   case SQL_FLOAT:
s = "FLOAT"; break;
-   case SQL_DOUBLE:
-   case SQL_D_FLOAT:   
+   case SQL_DOUBLE:
+   case SQL_D_FLOAT:
s = "DOUBLE PRECISION"; break;
 #ifdef SQL_INT64
-   case SQL_INT64: 
+   case SQL_INT64: 
s = "BIGINT"; 
break;
 #endif
@@ -4412,14 +4412,14 @@
zval **arg1, **arg2, **arg3, **query_arg;
ibase_db_link *ib_link;
ibase_trans *trans = NULL;
-   long increment;
-#ifdef SQL_INT64
-   ISC_INT64 result;
-#else
-   ISC_LONG result;
-#endif
-
-   XSQLDA out_sqlda;
+   long increment;
+#ifdef SQL_INT64
+   ISC_INT64 result;
+#else
+   ISC_LONG result;
+#endif
+
+   XSQLDA out_sqlda;
 
RESET_ERRMSG;
 
@@ -4429,8 +4429,8 @@
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, NULL, 
IBG(default_link), "InterBase link", le_link, le_plink);
-   query_arg = arg1;
-   increment = 1;
+   query_arg = arg1;
+   increment = 1;
break;
case 2:
if (zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
@@ -4438,14 +4438,14 @@
}
 
if (Z_TYPE_PP(arg1) == IS_STRING) /* first param is generator, 
second is inc */
-   {
+   {
query_arg = arg1;
convert_to_long_ex(arg2);
increment = Z_LVAL_PP(arg2);
 
ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, NULL, 
IBG(default_link), "InterBase link", le_link, le_plink);
} else {
-   
_php_ibase_get_link_trans(INTERNAL_FUNCTION_PARAM_PASSTHRU, arg1, &ib_link, &trans);
+   
_php_ibase_get_link_trans(INTERNAL_FUNCTION_PARAM_PASSTHRU, arg1, &ib_link, &trans);
query_arg = arg2;
increment = 1;
}
@@ -4455,7 +4455,7 @@
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link*, arg1, -1, 
"InterBase link", le_link, le_plink);
-   
+   
query_arg = arg2;
convert_to_long_ex(arg3);
increment = Z_LVAL_PP(arg3);
@@ -4467,45 +4467,45 @@
}

convert_to_string_ex(query_arg);
-   sprintf(query, "SELECT GEN_ID(%s,%ld) FROM rdb$database", 
Z_STRVAL_PP(query_arg), increment);
+   sprintf(query, "SELECT GEN_ID(%s,%ld) FROM rdb$database", 
Z_STRVAL_PP(query_arg), increment);
 
/* open default transaction */
if (_php_ibase_def_trans(ib_link, &trans TSRMLS_CC) == 

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-09-23 Thread Jani Taskinen
sniper  Tue Sep 23 18:17:41 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  ws fix
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.186 php-src/ext/interbase/interbase.c:1.187
--- php-src/ext/interbase/interbase.c:1.186 Tue Sep 23 16:58:13 2003
+++ php-src/ext/interbase/interbase.c   Tue Sep 23 18:17:40 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.186 2003/09/23 20:58:13 abies Exp $ */
+/* $Id: interbase.c,v 1.187 2003/09/23 22:17:40 sniper Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -26,7 +26,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.186 $"
+#define FILE_REVISION "$Revision: 1.187 $"
 
 #if HAVE_IBASE
 
@@ -116,7 +116,7 @@
 #if HAVE_STRFTIME
PHP_FE(ibase_timefmt, NULL)
 #endif
-PHP_FE(ibase_gen_id, NULL)
+   PHP_FE(ibase_gen_id, NULL)
PHP_FE(ibase_num_fields, NULL)
PHP_FE(ibase_num_params, NULL)
 #if abies_0
@@ -267,9 +267,9 @@
 /* {{{ internal macros, functions and structures */
 
 typedef struct {
-isc_db_handle *db_ptr;
-long tpb_len;
-char *tpb_ptr;
+   isc_db_handle *db_ptr;
+   long tpb_len;
+   char *tpb_ptr;
 } ISC_TEB;
 
 typedef struct {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c php_interbase.h

2003-09-23 Thread Ard Biesheuvel
abies   Tue Sep 23 16:58:14 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c php_interbase.h 
  Log:
  Added ibase_gen_id()
  # Lightweight shortcut to SELECT GEN_ID() ... function
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.185 php-src/ext/interbase/interbase.c:1.186
--- php-src/ext/interbase/interbase.c:1.185 Mon Sep 22 02:54:29 2003
+++ php-src/ext/interbase/interbase.c   Tue Sep 23 16:58:13 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.185 2003/09/22 06:54:29 hholzgra Exp $ */
+/* $Id: interbase.c,v 1.186 2003/09/23 20:58:13 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -26,7 +26,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.185 $"
+#define FILE_REVISION "$Revision: 1.186 $"
 
 #if HAVE_IBASE
 
@@ -69,11 +69,11 @@
 #ifdef PHP_WIN32
 #define LL_MASK "I64"
 #define LL_LIT(lit) lit ## I64
-#ifdef FB_SQLDA
-#pragma comment(lib, "fbclient_ms.lib")
-#else
-#pragma comment(lib, "gds32_ms.lib")
-#endif
+#ifdef FB_SQLDA
+#pragma comment(lib, "fbclient_ms.lib")
+#else
+#pragma comment(lib, "gds32_ms.lib")
+#endif
 #else
 #define LL_MASK "ll"
 #define LL_LIT(lit) lit ## ll
@@ -116,7 +116,7 @@
 #if HAVE_STRFTIME
PHP_FE(ibase_timefmt, NULL)
 #endif
-
+PHP_FE(ibase_gen_id, NULL)
PHP_FE(ibase_num_fields, NULL)
PHP_FE(ibase_num_params, NULL)
 #if abies_0
@@ -728,8 +728,8 @@
php_info_print_table_row(2, "Interbase Support", "enabled");
 
 #if (SQLDA_CURRENT_VERSION > 1) || defined(FB_SQLDA)
-   isc_get_client_version(tmp);
-   php_info_print_table_row(2, "Client Library", tmp);
+   isc_get_client_version(tmp);
+   php_info_print_table_row(2, "Client Library", tmp);
 #elif (SQL_DIALECT_CURRENT == 1)
php_info_print_table_row(2, "Client Library", "Interbase 5.6 or earlier");
 #elif !defined(DSC_null)
@@ -4403,6 +4403,113 @@
 }  
 /* }}} */
   
+/* {{{ proto int ibase_gen_id([ resource link_identifier, ] string generator [, int 
increment ])
+   Increments the named generator and returns its new value */
+PHP_FUNCTION(ibase_gen_id)
+{
+   char query[128];
+   
+   zval **arg1, **arg2, **arg3, **query_arg;
+   ibase_db_link *ib_link;
+   ibase_trans *trans = NULL;
+   long increment;
+#ifdef SQL_INT64
+   ISC_INT64 result;
+#else
+   ISC_LONG result;
+#endif
+
+   XSQLDA out_sqlda;
+
+   RESET_ERRMSG;
+
+   switch (ZEND_NUM_ARGS()) {
+   case 1:
+   if (zend_get_parameters_ex(1, &arg1) == FAILURE) {
+   RETURN_FALSE;
+   }
+   ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, NULL, 
IBG(default_link), "InterBase link", le_link, le_plink);
+   query_arg = arg1;
+   increment = 1;
+   break;
+   case 2:
+   if (zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
+   RETURN_FALSE;
+   }
+
+   if (Z_TYPE_PP(arg1) == IS_STRING) /* first param is generator, 
second is inc */
+   {
+   query_arg = arg1;
+   convert_to_long_ex(arg2);
+   increment = Z_LVAL_PP(arg2);
+
+   ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, NULL, 
IBG(default_link), "InterBase link", le_link, le_plink);
+   } else {
+   
_php_ibase_get_link_trans(INTERNAL_FUNCTION_PARAM_PASSTHRU, arg1, &ib_link, &trans);
+   query_arg = arg2;
+   increment = 1;
+   }
+   break;
+   case 3:
+   if (zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) 
{
+   RETURN_FALSE;
+   }
+   ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link*, arg1, -1, 
"InterBase link", le_link, le_plink);
+   
+   query_arg = arg2;
+   convert_to_long_ex(arg3);
+   increment = Z_LVAL_PP(arg3);
+   
+   break;  
+   default:
+   WRONG_PARAM_COUNT;
+   break;
+   }
+   
+   convert_to_string_ex(query_arg);
+   sprintf(query, "SELECT GEN_ID(%s,%ld) FROM rdb$database", 
Z_STRVAL_PP(query_arg), increment);
+
+   /* open default transaction */
+   if (_php_ibase_def_trans(ib_link, &trans TSRMLS_CC) == FAILURE) {
+   RETURN_FALSE;
+   }
+   
+   /* allocate a minimal descriptor area */
+   out_sqlda.sqln = out_sqlda.sqld = 1;
+

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-09-21 Thread Hartmut Holzgraefe
hholzgraMon Sep 22 02:54:30 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  proto thiko fix
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.184 php-src/ext/interbase/interbase.c:1.185
--- php-src/ext/interbase/interbase.c:1.184 Tue Sep 16 21:25:08 2003
+++ php-src/ext/interbase/interbase.c   Mon Sep 22 02:54:29 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.184 2003/09/17 01:25:08 abies Exp $ */
+/* $Id: interbase.c,v 1.185 2003/09/22 06:54:29 hholzgra Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -26,7 +26,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.184 $"
+#define FILE_REVISION "$Revision: 1.185 $"
 
 #if HAVE_IBASE
 
@@ -2508,7 +2508,7 @@
 }
 /* }}} */
 
-/* {{{ proto ibase_num_rows( resource result_identifier ) 
+/* {{{ proto int ibase_num_rows( resource result_identifier ) 
  */
 #if abies_0
 PHP_FUNCTION(ibase_num_rows) 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c interbase.dsp interbase.rc

2003-09-16 Thread Ard Biesheuvel
abies   Tue Sep 16 21:25:09 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c interbase.dsp interbase.rc 
  Log:
  Link to fbclient.dll if available
  Add client lib name to dll version info
  Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.183 php-src/ext/interbase/interbase.c:1.184
--- php-src/ext/interbase/interbase.c:1.183 Tue Sep 16 16:28:27 2003
+++ php-src/ext/interbase/interbase.c   Tue Sep 16 21:25:08 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.183 2003/09/16 20:28:27 abies Exp $ */
+/* $Id: interbase.c,v 1.184 2003/09/17 01:25:08 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -26,9 +26,9 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.183 $"
+#define FILE_REVISION "$Revision: 1.184 $"
 
-#if HAVE_IBASE && !defined(VERSION_INFO_ONLY)
+#if HAVE_IBASE
 
 #include "php_ini.h"
 #include "ext/standard/php_standard.h"
@@ -71,6 +71,8 @@
 #define LL_LIT(lit) lit ## I64
 #ifdef FB_SQLDA
 #pragma comment(lib, "fbclient_ms.lib")
+#else
+#pragma comment(lib, "gds32_ms.lib")
 #endif
 #else
 #define LL_MASK "ll"
Index: php-src/ext/interbase/interbase.dsp
diff -u php-src/ext/interbase/interbase.dsp:1.9 
php-src/ext/interbase/interbase.dsp:1.10
--- php-src/ext/interbase/interbase.dsp:1.9 Sun Sep  7 20:41:03 2003
+++ php-src/ext/interbase/interbase.dsp Tue Sep 16 21:25:08 2003
@@ -54,7 +54,7 @@
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib 
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib 
ib_util_ms.lib gds32_ms.lib php4ts_debug.lib /nologo /dll /debug /machine:I386 
/pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib 
shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib gds32_ms.lib 
php4ts_debug.lib /nologo /dll /debug /machine:I386 
/out:"..\..\Debug_TS/php_interbase.dll" /pdbtype:sept 
/libpath:"..\..\..\php_build\Interbase SDK\lib_ms" /libpath:"..\..\Debug_TS"
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib 
shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts_debug.lib 
/nologo /dll /debug /machine:I386 /out:"..\..\Debug_TS/php_interbase.dll" 
/pdbtype:sept /libpath:"..\..\..\php_build\Interbase SDK\lib_ms" 
/libpath:"..\..\Debug_TS"
 
 !ELSEIF  "$(CFG)" == "interbase - Win32 Release_TS"
 
@@ -81,7 +81,7 @@
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 php4ts.lib kernel32.lib user32.lib gdi32.lib winspool.lib 
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib 
odbccp32.lib ib_util_ms.lib gds32_ms.lib /nologo /dll /machine:I386
-# ADD LINK32 php4ts.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib 
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib 
gds32_ms.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_interbase.dll" 
/libpath:"..\..\..\php_build\Interbase SDK\lib_ms" /libpath:"..\..\Release_TS" 
/libpath:"..\..\Release_TS_Inline"
+# ADD LINK32 php4ts.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib 
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib 
/nologo /dll /machine:I386 /out:"..\..\Release_TS/php_interbase.dll" 
/libpath:"..\..\..\php_build\Interbase SDK\lib_ms" /libpath:"..\..\Release_TS" 
/libpath:"..\..\Release_TS_Inline"
 
 !ENDIF 
 
@@ -111,9 +111,7 @@
 # Begin Source File
 
 SOURCE=.\interbase.rc
-
-# ADD RSC /i "..\..\main" /i "..\..\win32"
-
+# ADD RSC /i "..\..\main" /i "..\..\win32" /d "PHP_H"
 # End Source File
 # End Group
 # End Target
Index: php-src/ext/interbase/interbase.rc
diff -u php-src/ext/interbase/interbase.rc:1.3 php-src/ext/interbase/interbase.rc:1.4
--- php-src/ext/interbase/interbase.rc:1.3  Sun Sep  7 20:32:22 2003
+++ php-src/ext/interbase/interbase.rc  Tue Sep 16 21:25:08 2003
@@ -1,76 +1,82 @@
-/*
-   +--+
-   | PHP Version 4|
-   +--+
-   | Copyright (c) 1997-2003 The PHP Group|
-   +--+
-   | This source file is subject to version 3.0 of the PHP license,   |
-   | that is bundled with this package in the file LICENSE, and is|
-   | available through the world-wide-web at the following url:   |
-   | http://www.php.net/license/3_0.txt.  |
-   | If you did not receive a copy of the PHP license and are unable to   |
-   | obtain it through the world-wide-web, please send a note to  |
-   | [EMAIL PROTECTED] so we can mail you a copy immediately.  

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-09-16 Thread Ard Biesheuvel
abies   Tue Sep 16 16:28:29 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Use isc_get_version() for client lib info if available
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.182 php-src/ext/interbase/interbase.c:1.183
--- php-src/ext/interbase/interbase.c:1.182 Tue Sep 16 15:44:56 2003
+++ php-src/ext/interbase/interbase.c   Tue Sep 16 16:28:27 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.182 2003/09/16 19:44:56 hholzgra Exp $ */
+/* $Id: interbase.c,v 1.183 2003/09/16 20:28:27 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -26,7 +26,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.182 $"
+#define FILE_REVISION "$Revision: 1.183 $"
 
 #if HAVE_IBASE && !defined(VERSION_INFO_ONLY)
 
@@ -69,6 +69,9 @@
 #ifdef PHP_WIN32
 #define LL_MASK "I64"
 #define LL_LIT(lit) lit ## I64
+#ifdef FB_SQLDA
+#pragma comment(lib, "fbclient_ms.lib")
+#endif
 #else
 #define LL_MASK "ll"
 #define LL_LIT(lit) lit ## ll
@@ -717,22 +720,20 @@
  
 PHP_MINFO_FUNCTION(ibase)
 {
-   char tmp[32];
+   char tmp[64];
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
 
-   php_info_print_table_row(2, "Client Library",
-#if (SQLDA_CURRENT_VERSION == 1 && SQL_DIALECT_CURRENT == 1)
-   "Interbase 5.6 or earlier");
-#elif (SQLDA_CURRENT_VERSION == 2 && SQL_DIALECT_CURRENT == 3)
-   "Interbase 7 or later");
+#if (SQLDA_CURRENT_VERSION > 1) || defined(FB_SQLDA)
+   isc_get_client_version(tmp);
+   php_info_print_table_row(2, "Client Library", tmp);
+#elif (SQL_DIALECT_CURRENT == 1)
+   php_info_print_table_row(2, "Client Library", "Interbase 5.6 or earlier");
 #elif !defined(DSC_null)
-   "Interbase 6");
-#elif !defined(FB_SQLDA)
-   "Firebird 1.0");
+   php_info_print_table_row(2, "Client Library", "Interbase 6");
 #else
-   "Firebird 1.5 or later");
+   php_info_print_table_row(2, "Client Library", "Firebird 1.0");
 #endif
 
php_info_print_table_row(2, "Revision", FILE_REVISION);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-09-16 Thread Hartmut Holzgraefe
hholzgraTue Sep 16 15:44:56 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  proto fix
  
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.181 php-src/ext/interbase/interbase.c:1.182
--- php-src/ext/interbase/interbase.c:1.181 Fri Sep 12 17:02:43 2003
+++ php-src/ext/interbase/interbase.c   Tue Sep 16 15:44:56 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.181 2003/09/12 21:02:43 abies Exp $ */
+/* $Id: interbase.c,v 1.182 2003/09/16 19:44:56 hholzgra Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -26,7 +26,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.181 $"
+#define FILE_REVISION "$Revision: 1.182 $"
 
 #if HAVE_IBASE && !defined(VERSION_INFO_ONLY)
 
@@ -2505,7 +2505,8 @@
 }
 /* }}} */
 
-/* {{{ ibase_num_rows( resource result_identifier ) */
+/* {{{ proto ibase_num_rows( resource result_identifier ) 
+ */
 #if abies_0
 PHP_FUNCTION(ibase_num_rows) 
 {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-09-12 Thread Ard Biesheuvel
abies   Fri Sep 12 17:02:44 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Pointer size fix
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.180 php-src/ext/interbase/interbase.c:1.181
--- php-src/ext/interbase/interbase.c:1.180 Thu Sep 11 19:11:18 2003
+++ php-src/ext/interbase/interbase.c   Fri Sep 12 17:02:43 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.180 2003/09/11 23:11:18 abies Exp $ */
+/* $Id: interbase.c,v 1.181 2003/09/12 21:02:43 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -26,7 +26,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.180 $"
+#define FILE_REVISION "$Revision: 1.181 $"
 
 #if HAVE_IBASE && !defined(VERSION_INFO_ONLY)
 
@@ -963,12 +963,14 @@
 * and add a pointer to it with hashed_details as the key.
 */
if ( (zend_hash_find(&EG(regular_list), hashed_details, 
hashed_details_length + 1, (void *) &index_ptr) == SUCCESS) ) {
-   int type, xlink;
+   int type;
+   long xlink;
void *ptr;
+   
if (Z_TYPE_P(index_ptr) != le_index_ptr) {
RETURN_FALSE;
}
-   xlink = (int) index_ptr->ptr;
+   xlink = (long) index_ptr->ptr;
ptr = zend_list_find(xlink, &type);  /* check if the xlink 
is still there */
if (ptr && (type == le_link || type == le_plink)) {
zend_list_addref(xlink);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-09-11 Thread Ard Biesheuvel
abies   Thu Sep 11 04:50:31 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Changed unsigned ISC_LONG to ISC_LONG
  # Build fix for FB 1.5
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.177 php-src/ext/interbase/interbase.c:1.178
--- php-src/ext/interbase/interbase.c:1.177 Sun Sep  7 15:59:55 2003
+++ php-src/ext/interbase/interbase.c   Thu Sep 11 04:50:30 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.177 2003/09/07 19:59:55 abies Exp $ */
+/* $Id: interbase.c,v 1.178 2003/09/11 08:50:30 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -26,7 +26,7 @@
 
 #include "php.h"
 
-#define FILE_REVISION "$Revision: 1.177 $"
+#define FILE_REVISION "$Revision: 1.178 $"
 
 #if HAVE_IBASE && !defined(VERSION_INFO_ONLY)
 
@@ -325,7 +325,7 @@
unsigned ISC_INT64 res;
if (sscanf(id, BLOB_ID_MASK, &res)) {
qd->gds_quad_high = (ISC_LONG) (res >> 0x20);
-   qd->gds_quad_low = (unsigned ISC_LONG) (res & 0x);
+   qd->gds_quad_low = (ISC_LONG) (res & 0x);
return 1;
}
return 0;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c interbase.dsp interbase.rc

2003-09-07 Thread Ard Biesheuvel
abies   Sun Sep  7 15:59:56 2003 EDT

  Added files: 
/php-src/ext/interbase  interbase.rc 

  Modified files:  
/php-src/ext/interbase  interbase.c interbase.dsp 
  Log:
  Add version info to Windows DLL
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.176 php-src/ext/interbase/interbase.c:1.177
--- php-src/ext/interbase/interbase.c:1.176 Fri Sep  5 10:21:25 2003
+++ php-src/ext/interbase/interbase.c   Sun Sep  7 15:59:55 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.176 2003/09/05 14:21:25 abies Exp $ */
+/* $Id: interbase.c,v 1.177 2003/09/07 19:59:55 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -26,7 +26,9 @@
 
 #include "php.h"
 
-#if HAVE_IBASE
+#define FILE_REVISION "$Revision: 1.177 $"
+
+#if HAVE_IBASE && !defined(VERSION_INFO_ONLY)
 
 #include "php_ini.h"
 #include "ext/standard/php_standard.h"
@@ -716,7 +718,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.176 $");
+   php_info_print_table_row(2, "Revision", FILE_REVISION);
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
Index: php-src/ext/interbase/interbase.dsp
diff -u php-src/ext/interbase/interbase.dsp:1.6 php-src/ext/interbase/interbase.dsp:1.7
--- php-src/ext/interbase/interbase.dsp:1.6 Tue Sep  4 17:50:27 2001
+++ php-src/ext/interbase/interbase.dsp Sun Sep  7 15:59:55 2003
@@ -108,6 +108,13 @@
 # Begin Group "Resource Files"
 
 # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# Begin Source File
+
+SOURCE=.\interbase.rc
+
+# ADD RSC /i "..\.." /i "..\..\main" /i "..\..\win32" /i "..\..\Zend" /i "..\..\TSRM" 
/d "ZEND_WIN32" /d "WIN32" /d "PHP_WIN32"
+
+# End Source File
 # End Group
 # End Target
 # End Project

Index: php-src/ext/interbase/interbase.rc
+++ php-src/ext/interbase/interbase.rc
/*
   +--+
   | PHP Version 4|
   +--+
   | Copyright (c) 1997-2003 The PHP Group|
   +--+
   | This source file is subject to version 3.0 of the PHP license,   |
   | that is bundled with this package in the file LICENSE, and is|
   | available through the world-wide-web at the following url:   |
   | http://www.php.net/license/3_0.txt.  |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to  |
   | [EMAIL PROTECTED] so we can mail you a copy immediately.   |
   +--+
   | Author:  Ard Biesheuvel <[EMAIL PROTECTED]>  |
   +--+
 */

/* $Id: interbase.rc,v 1.1 2003/09/07 19:59:55 abies Exp $ */

#ifdef APSTUDIO_INVOKED
#error This file cannot be opened from the Visual Studio IDE
#endif

#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
#include "winres.h"
#undef APSTUDIO_READONLY_SYMBOLS

#include "php_version.h"

#ifdef _DEBUG
# define BUILD_TYPE "Debug"
#else
# define BUILD_TYPE "Release"
#endif

#define VERSION_INFO_ONLY
#include "interbase.c"

#ifndef _MAC

VS_VERSION_INFO VERSIONINFO
 FILEVERSION PHP_MAJOR_VERSION,PHP_MINOR_VERSION,PHP_RELEASE_VERSION,0
 PRODUCTVERSION PHP_MAJOR_VERSION,PHP_MINOR_VERSION,PHP_RELEASE_VERSION,0
 FILEFLAGSMASK 0x3fL
 FILEOS 0x40004L
 FILETYPE 0x2L
 FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "04b0"
BEGIN
VALUE "FileDescription", "PHP Interbase module"
VALUE "FileVersion", PHP_VERSION
VALUE "File Revision", FILE_REVISION
VALUE "LegalCopyright", "1997-2003 The PHP Group"
VALUE "ProductName", "PHP"
VALUE "ProductVersion", PHP_VERSION
VALUE "Build Type", BUILD_TYPE
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0, 1200
END
END

#endif// !_MAC

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-09-05 Thread Ard Biesheuvel
abies   Fri Sep  5 10:21:26 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Be more relaxed about dimensions of array arguments
  
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.175 php-src/ext/interbase/interbase.c:1.176
--- php-src/ext/interbase/interbase.c:1.175 Thu Sep  4 18:37:14 2003
+++ php-src/ext/interbase/interbase.c   Fri Sep  5 10:21:25 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.175 2003/09/04 22:37:14 abies Exp $ */
+/* $Id: interbase.c,v 1.176 2003/09/05 14:21:25 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -716,7 +716,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.175 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.176 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -1105,7 +1105,7 @@

for (i = 0; i < sqlda->sqld; i++, var++) {
unsigned short dim;
-   unsigned long ar_size;
+   unsigned long ar_size = 1;

if ((var->sqltype & ~1) == SQL_ARRAY) {
ISC_ARRAY_DESC *ar_desc = &IB_ARRAY[i].ar_desc;
@@ -1121,7 +1121,7 @@
case blr_text:
case blr_text2:
IB_ARRAY[i].el_type = SQL_TEXT;
-   IB_ARRAY[i].el_size = 
ar_desc->array_desc_length + 1;
+   IB_ARRAY[i].el_size = 
ar_desc->array_desc_length;
break;
case blr_short:
IB_ARRAY[i].el_type = SQL_SHORT;
@@ -1165,8 +1165,12 @@
break;
 #endif 
case blr_varying:
-   case blr_varying2:  /* changed to SQL_TEXT ? */
-   /* sql_type = SQL_VARYING; Why? FIXME: ??? */
+   case blr_varying2:
+   /**
+* IB has a strange way of handling VARCHAR 
arrays. It doesn't store
+* the length in the first short, as with 
VARCHAR fields. It does, 
+* however, expect the extra short to be 
allocated for each element.
+*/
IB_ARRAY[i].el_type = SQL_TEXT;
IB_ARRAY[i].el_size = 
ar_desc->array_desc_length + sizeof(short);
break;
@@ -1174,7 +1178,12 @@
case blr_blob_id:
case blr_cstring:
case blr_cstring2:
-   /* FIXME */
+   /**
+* These types are mentioned as array types in 
the manual, but I 
+* wouldn't know how to create an array field 
with any of these
+* types. I assume these types are not 
applicable to arrays, and
+* were mentioned erroneously.
+*/
default:
_php_ibase_module_error("Unsupported array 
type %d in relation '%s' column '%s'" TSRMLS_CC, ar_desc->array_desc_dtype, 
var->relname, var->sqlname);
efree(IB_ARRAY);
@@ -1182,7 +1191,7 @@
return FAILURE;
} /* switch array_desc_type */

-   ar_size = 1; /* calculate elements count */
+   /* calculate elements count */
for (dim = 0; dim < ar_desc->array_desc_dimensions; dim++) {
ar_size *= 1 + 
ar_desc->array_desc_bounds[dim].array_bound_upper - 
ar_desc->array_desc_bounds[dim].array_bound_lower;
}
@@ -1323,48 +1332,64 @@
 /* {{{ _php_ibase_bind_array() */
 static int _php_ibase_bind_array(zval *val, char *buf, unsigned long buf_size, 
ibase_array *array, int dim TSRMLS_DC)
 {
-   int 
-   u_bound = array->ar_desc.array_desc_bounds[dim].array_bound_upper,
+   zval null_val, *pnull_val = &null_val;
+   int u_bound = array->ar_desc.array_desc_bounds[dim].array_bound_upper,
l_bound = array->ar_d

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-09-04 Thread Ard Biesheuvel
abies   Thu Sep  4 18:37:14 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Added support for binding arrays
  Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.174 php-src/ext/interbase/interbase.c:1.175
--- php-src/ext/interbase/interbase.c:1.174 Thu Sep  4 10:44:34 2003
+++ php-src/ext/interbase/interbase.c   Thu Sep  4 18:37:14 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.174 2003/09/04 14:44:34 abies Exp $ */
+/* $Id: interbase.c,v 1.175 2003/09/04 22:37:14 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -56,14 +56,14 @@
 #define ISC_LONG_MAX 2147483647
 
 #ifdef PHP_WIN32
-# ifndef ISC_UINT64
-#  define ISC_UINT64 unsigned __int64
+# ifndef ISC_INT64
+#  define ISC_INT64 __int64
 # endif
 # define LL_MASK "I64"
 # define LL_LIT(lit) lit ## I64
 #else
-# ifndef ISC_UINT64
-#  define ISC_UINT64 unsigned long long int
+# ifndef ISC_INT64
+#  define ISC_INT64 long long int
 # endif
 # define LL_MASK "ll"
 # define LL_LIT(lit) lit ## ll
@@ -317,10 +317,10 @@
 static inline int _php_ibase_string_to_quad(char const *id, ISC_QUAD *qd)
 {
/* shortcut for most common case */
-   if (sizeof(ISC_QUAD) == sizeof(ISC_UINT64)) {
-   return sscanf(id, BLOB_ID_MASK, (ISC_UINT64 *) qd);
+   if (sizeof(ISC_QUAD) == sizeof(unsigned ISC_INT64)) {
+   return sscanf(id, BLOB_ID_MASK, (unsigned ISC_INT64 *) qd);
} else {
-   ISC_UINT64 res;
+   unsigned ISC_INT64 res;
if (sscanf(id, BLOB_ID_MASK, &res)) {
qd->gds_quad_high = (ISC_LONG) (res >> 0x20);
qd->gds_quad_low = (unsigned ISC_LONG) (res & 0x);
@@ -335,10 +335,10 @@
char *result = (char *) emalloc(BLOB_ID_LEN+1);
 
/* shortcut for most common case */
-   if (sizeof(ISC_QUAD) == sizeof(ISC_UINT64)) {
-   sprintf(result, BLOB_ID_MASK, *(ISC_UINT64*)(void *) &qd); 
+   if (sizeof(ISC_QUAD) == sizeof(unsigned ISC_INT64)) {
+   sprintf(result, BLOB_ID_MASK, *(unsigned ISC_INT64*)(void *) &qd); 
} else {
-   ISC_UINT64 res = ((ISC_UINT64) qd.gds_quad_high << 0x20) | 
qd.gds_quad_low;
+   unsigned ISC_INT64 res = ((unsigned ISC_INT64) qd.gds_quad_high << 
0x20) | qd.gds_quad_low;
sprintf(result, BLOB_ID_MASK, res);
}
result[BLOB_ID_LEN] = '\0';
@@ -716,7 +716,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.174 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.175 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -1105,7 +1105,7 @@

for (i = 0; i < sqlda->sqld; i++, var++) {
unsigned short dim;
-   unsigned long ar_length;
+   unsigned long ar_size;

if ((var->sqltype & ~1) == SQL_ARRAY) {
ISC_ARRAY_DESC *ar_desc = &IB_ARRAY[i].ar_desc;
@@ -1182,11 +1182,11 @@
return FAILURE;
} /* switch array_desc_type */

-   ar_length = 0; /* calculate elements count */
+   ar_size = 1; /* calculate elements count */
for (dim = 0; dim < ar_desc->array_desc_dimensions; dim++) {
-   ar_length += 1 + 
ar_desc->array_desc_bounds[dim].array_bound_upper - 
ar_desc->array_desc_bounds[dim].array_bound_lower;
+   ar_size *= 1 + 
ar_desc->array_desc_bounds[dim].array_bound_upper - 
ar_desc->array_desc_bounds[dim].array_bound_lower;
}
-   IB_ARRAY[i].ar_size = IB_ARRAY[i].el_size * ar_length;
+   IB_ARRAY[i].ar_size = IB_ARRAY[i].el_size * ar_size;
} /* if SQL_ARRAY */
} /* for column */
return SUCCESS;
@@ -1320,11 +1320,206 @@
 }  
 /* }}} */
 
+/* {{{ _php_ibase_bind_array() */
+static int _php_ibase_bind_array(zval *val, char *buf, unsigned long buf_size, 
ibase_array *array, int dim TSRMLS_DC)
+{
+   int 
+   u_bound = array->ar_desc.array_desc_bounds[dim].array_bound_upper,
+   l_bound = array->ar_desc.array_desc_bounds[dim].array_bound_lower,
+   dim_len = 1 + u_bound - l_bound;
+
+   if (dim < array->ar_desc.array_desc_dimensions) {
+   unsigned long slice_size = buf_size / dim_len;
+   unsigned short i;
+   
+   if (Z_TYPE_P(val) != IS_ARRAY || 
zend_hash_num_elements(Z_ARRVAL_P(val)) != dim_len) {
+   _php_ibase

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-09-04 Thread Ard Biesheuvel
abies   Thu Sep  4 10:44:35 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Don't rely on sizeof(int) == 4
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.173 php-src/ext/interbase/interbase.c:1.174
--- php-src/ext/interbase/interbase.c:1.173 Thu Sep  4 10:18:39 2003
+++ php-src/ext/interbase/interbase.c   Thu Sep  4 10:44:34 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.173 2003/09/04 14:18:39 abies Exp $ */
+/* $Id: interbase.c,v 1.174 2003/09/04 14:44:34 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -52,6 +52,9 @@
 
 #define SAFE_STRING(s) ((s)?(s):"")
 
+#define ISC_LONG_MIN (-ISC_LONG_MAX - 1)
+#define ISC_LONG_MAX 2147483647
+
 #ifdef PHP_WIN32
 # ifndef ISC_UINT64
 #  define ISC_UINT64 unsigned __int64
@@ -713,7 +716,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.173 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.174 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -1363,7 +1366,7 @@
convert_to_long(b_var);
 #if (SIZEOF_LONG > 4)
/* ISC_LONG is always 32-bit */
-   if (Z_LVAL_P(b_var) > INT_MAX || 
Z_LVAL_P(b_var) < INT_MIN) {
+   if (Z_LVAL_P(b_var) > ISC_LONG_MAX || 
Z_LVAL_P(b_var) < ISC_LONG_MIN) {
_php_ibase_module_error("Parameter %d 
exceeds field width" TSRMLS_CC, i+1);
rv = FAILURE;
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c php_interbase.h

2003-09-04 Thread Ard Biesheuvel
abies   Thu Sep  4 10:18:40 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c php_interbase.h 
  Log:
  Fix inter-op with IB < 6
  Fixes for 64-bit archs
  Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.172 php-src/ext/interbase/interbase.c:1.173
--- php-src/ext/interbase/interbase.c:1.172 Thu Sep  4 07:09:46 2003
+++ php-src/ext/interbase/interbase.c   Thu Sep  4 10:18:39 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.172 2003/09/04 11:09:46 abies Exp $ */
+/* $Id: interbase.c,v 1.173 2003/09/04 14:18:39 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -39,7 +39,7 @@
 #endif
 
 #ifndef SQL_DIALECT_CURRENT
-#define SQL_DIALECT_CURRENT SQL_DIALECT_V5
+#define SQL_DIALECT_CURRENT 1 /* == SQL_DIALECT_V5 */
 #endif
 
 #ifdef ZEND_DEBUG_
@@ -53,11 +53,17 @@
 #define SAFE_STRING(s) ((s)?(s):"")
 
 #ifdef PHP_WIN32
-#define LL_MASK "I64"
-#define LL_LIT(lit) lit ## I64
+# ifndef ISC_UINT64
+#  define ISC_UINT64 unsigned __int64
+# endif
+# define LL_MASK "I64"
+# define LL_LIT(lit) lit ## I64
 #else
-#define LL_MASK "ll"
-#define LL_LIT(lit) lit ## ll
+# ifndef ISC_UINT64
+#  define ISC_UINT64 unsigned long long int
+# endif
+# define LL_MASK "ll"
+# define LL_LIT(lit) lit ## ll
 #endif
 
 #define QUERY_RESULT   1
@@ -111,7 +117,6 @@
PHP_FE(ibase_commit, NULL)
PHP_FE(ibase_rollback, NULL)
PHP_FE(ibase_commit_ret, NULL)
-   PHP_FE(ibase_rollback_ret, NULL)
 
PHP_FE(ibase_blob_info, NULL)
PHP_FE(ibase_blob_create, NULL)
@@ -129,6 +134,8 @@
PHP_FE(ibase_add_user, NULL)
PHP_FE(ibase_modify_user, NULL)
PHP_FE(ibase_delete_user, NULL)
+
+   PHP_FE(ibase_rollback_ret, NULL)
 #endif
PHP_FE(ibase_wait_event, NULL)
PHP_FE(ibase_set_event_handler, NULL)
@@ -253,7 +260,7 @@
 } ISC_TEB;
 
 typedef struct {
-   ISC_USHORT vary_length;
+   unsigned short vary_length;
char vary_string[1];
 } IBVARY;
 
@@ -293,6 +300,7 @@
union {
short sval;
float fval;
+   ISC_LONG lval;
ISC_QUAD qval;
 #ifdef ISC_TIMESTAMP
ISC_TIMESTAMP tsval;
@@ -312,7 +320,7 @@
ISC_UINT64 res;
if (sscanf(id, BLOB_ID_MASK, &res)) {
qd->gds_quad_high = (ISC_LONG) (res >> 0x20);
-   qd->gds_quad_low = (ISC_ULONG) (res & 0x);
+   qd->gds_quad_low = (unsigned ISC_LONG) (res & 0x);
return 1;
}
return 0;
@@ -466,9 +474,6 @@
IBDEBUG("Dropping statement handle (free_result dtor)...");
isc_dsql_free_statement(IB_STATUS, &ib_result->stmt, 
DSQL_drop);
}
-   if (ib_result->out_array) {
-   efree(ib_result->out_array);
-   }
efree(ib_result);
}
 }
@@ -708,7 +713,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.172 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.173 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -1356,8 +1361,22 @@
break;
case SQL_LONG:
convert_to_long(b_var);
+#if (SIZEOF_LONG > 4)
+   /* ISC_LONG is always 32-bit */
+   if (Z_LVAL_P(b_var) > INT_MAX || 
Z_LVAL_P(b_var) < INT_MIN) {
+   _php_ibase_module_error("Parameter %d 
exceeds field width" TSRMLS_CC, i+1);
+   rv = FAILURE;
+   }
+#endif
+   buf[i].val.lval = (ISC_LONG) Z_LVAL_P(b_var);
+   var->sqldata = (void *) &buf[i].val.lval;
+   break;
+#if defined(SQL_INT64) && (SIZEOF_LONG == 8)
+   case SQL_INT64:
+   convert_to_long(b_var);
var->sqldata = (void *) &Z_LVAL_P(b_var);
break;
+#endif
case SQL_FLOAT:
convert_to_double(b_var);
buf[i].val.fval = (float) Z_DVAL_P(b_var);
@@ -1602,7 +1621,7 @@
/* allocate sqlda and output buffers */
if (ib_query->out_sqlda) { /* output variables in select, select for update */
IBDEBUG("Query wants XSQLDA for out

[PHP-CVS] cvs: php-src /ext/interbase interbase.c php_interbase.h

2003-09-04 Thread Ard Biesheuvel
abies   Thu Sep  4 07:09:47 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c php_interbase.h 
  Log:
  Fixed fetching of arrays
  # Untested for multidimensional arrays
  Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.171 php-src/ext/interbase/interbase.c:1.172
--- php-src/ext/interbase/interbase.c:1.171 Wed Sep  3 21:26:36 2003
+++ php-src/ext/interbase/interbase.c   Thu Sep  4 07:09:46 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.171 2003/09/04 01:26:36 abies Exp $ */
+/* $Id: interbase.c,v 1.172 2003/09/04 11:09:46 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -708,7 +708,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.171 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.172 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -1086,117 +1086,101 @@
 /* }}} */
 
 /* {{{ _php_ibase_alloc_array() */
-static int _php_ibase_alloc_array(ibase_array **ib_arrayp, int *array_cntp, XSQLDA 
*sqlda, isc_db_handle link, isc_tr_handle trans TSRMLS_DC)
+static int _php_ibase_alloc_array(ibase_array **ib_arrayp, XSQLDA *sqlda, 
isc_db_handle link, isc_tr_handle trans TSRMLS_DC)
 {
 #define IB_ARRAY (*ib_arrayp)
 
-   int i, dim, ar_cnt, ar_length;
-   XSQLVAR *var;
+   unsigned short i;
+   XSQLVAR *var = sqlda->sqlvar;
 
-   IB_ARRAY = NULL;
+   IB_ARRAY = safe_emalloc(sizeof(ibase_array), sqlda->sqld, 0);

-   ar_cnt = 0; /* find arrays */
-   var = sqlda->sqlvar;
for (i = 0; i < sqlda->sqld; i++, var++) {
+   unsigned short dim;
+   unsigned long ar_length;
+   
if ((var->sqltype & ~1) == SQL_ARRAY) {
-   ar_cnt++;
-   }
-   }
-
-   if (ar_cnt) { /* have  arrays ? */
-   *array_cntp = ar_cnt;
-   IB_ARRAY = safe_emalloc(sizeof(ibase_array), ar_cnt, 0);
-   ar_cnt = 0;
-   var = sqlda->sqlvar;
-   for (i = 0; i < sqlda->sqld; i++, var++) {
-   if ((var->sqltype & ~1) == SQL_ARRAY) {
+   ISC_ARRAY_DESC *ar_desc = &IB_ARRAY[i].ar_desc;

-   ISC_ARRAY_DESC *ar_desc = &IB_ARRAY[ar_cnt].ar_desc;
-   
-   if (isc_array_lookup_bounds(IB_STATUS, &link, &trans, 
var->relname, var->sqlname, ar_desc)) {
-   _php_ibase_error(TSRMLS_C);
-   efree(IB_ARRAY);
-   IB_ARRAY = NULL;
-   return FAILURE;
-   }
+   if (isc_array_lookup_bounds(IB_STATUS, &link, &trans, 
var->relname, var->sqlname, ar_desc)) {
+   _php_ibase_error(TSRMLS_C);
+   efree(IB_ARRAY);
+   IB_ARRAY = NULL;
+   return FAILURE;
+   }
 
-   switch (ar_desc->array_desc_dtype) {
-   case blr_text:
-   case blr_text2:
-   IB_ARRAY[ar_cnt].el_type = SQL_TEXT;
-   IB_ARRAY[ar_cnt].el_size = 
ar_desc->array_desc_length + 1;
-   break;
-   case blr_short:
-   IB_ARRAY[ar_cnt].el_type = SQL_SHORT;
-   IB_ARRAY[ar_cnt].el_size = 
sizeof(short);
-   break;
-   case blr_long:
-   IB_ARRAY[ar_cnt].el_type = SQL_LONG;
-   IB_ARRAY[ar_cnt].el_size = 
sizeof(ISC_LONG);
-   break;
-   case blr_float:
-   IB_ARRAY[ar_cnt].el_type = SQL_FLOAT;
-   IB_ARRAY[ar_cnt].el_size = 
sizeof(float);
-   break;
-   case blr_double:
-   IB_ARRAY[ar_cnt].el_type = SQL_DOUBLE;
-   IB_ARRAY[ar_cnt].el_size = 
sizeof(double);
-   break;
+   switc

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-09-03 Thread Ard Biesheuvel
abies   Wed Sep  3 21:26:36 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  No scaling for double type
  Added missing array types
  Precompute scale factors
  Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.170 php-src/ext/interbase/interbase.c:1.171
--- php-src/ext/interbase/interbase.c:1.170 Wed Sep  3 11:15:30 2003
+++ php-src/ext/interbase/interbase.c   Wed Sep  3 21:26:36 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.170 2003/09/03 15:15:30 abies Exp $ */
+/* $Id: interbase.c,v 1.171 2003/09/04 01:26:36 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -54,8 +54,10 @@
 
 #ifdef PHP_WIN32
 #define LL_MASK "I64"
+#define LL_LIT(lit) lit ## I64
 #else
 #define LL_MASK "ll"
+#define LL_LIT(lit) lit ## ll
 #endif
 
 #define QUERY_RESULT   1
@@ -706,7 +708,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.170 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.171 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -1130,7 +1132,7 @@
break;
case blr_long:
IB_ARRAY[ar_cnt].el_type = SQL_LONG;
-   IB_ARRAY[ar_cnt].el_size = 
sizeof(long);
+   IB_ARRAY[ar_cnt].el_size = 
sizeof(ISC_LONG);
break;
case blr_float:
IB_ARRAY[ar_cnt].el_type = SQL_FLOAT;
@@ -1140,18 +1142,44 @@
IB_ARRAY[ar_cnt].el_type = SQL_DOUBLE;
IB_ARRAY[ar_cnt].el_size = 
sizeof(double);
break;
+#ifdef blr_int64
+   case blr_int64:
+   IB_ARRAY[ar_cnt].el_type = SQL_INT64;
+   IB_ARRAY[ar_cnt].el_size = 
sizeof(ISC_INT64);
+   break;
+#endif
+#ifndef blr_timestamp
case blr_date:
IB_ARRAY[ar_cnt].el_type = SQL_DATE;
IB_ARRAY[ar_cnt].el_size = 
sizeof(ISC_QUAD);
break;
+#else
+   case blr_timestamp:
+   IB_ARRAY[ar_cnt].el_type = 
SQL_TIMESTAMP;
+   IB_ARRAY[ar_cnt].el_size = 
sizeof(ISC_TIMESTAMP);
+   break;
+   case blr_sql_date:
+   IB_ARRAY[ar_cnt].el_type = 
SQL_TYPE_DATE;
+   IB_ARRAY[ar_cnt].el_size = 
sizeof(ISC_DATE);
+   break;
+   case blr_sql_time:
+   IB_ARRAY[ar_cnt].el_type = 
SQL_TYPE_TIME;
+   IB_ARRAY[ar_cnt].el_size = 
sizeof(ISC_TIME);
+   break;
+#endif 
case blr_varying:
case blr_varying2:  /* changed to SQL_TEXT 
? */
/* sql_type = SQL_VARYING; Why? FIXME: 
??? */
IB_ARRAY[ar_cnt].el_type = SQL_TEXT;
IB_ARRAY[ar_cnt].el_size = 
ar_desc->array_desc_length + sizeof(short);
break;
+   case blr_quad:
+   case blr_blob_id:
+   case blr_cstring:
+   case blr_cstring2:
+   /* FIXME */
default:
-   _php_ibase_module_error("Unexpected 
array type %d in relation '%s' column '%s'" TSRMLS_CC, ar_desc->array_desc_dtype, 
var->relname, var->sqlname);
+   _php_ibase_module_error("Unsupported 
array type %d in relation '%s' column '%s'" TSRMLS_CC, ar_desc->array_desc_dtype, 
var->relname, var->sqlnam

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-09-03 Thread Ard Biesheuvel
abies   Wed Sep  3 11:15:31 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Fix binding of 16-bit NUMERIC parameters
  Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.169 php-src/ext/interbase/interbase.c:1.170
--- php-src/ext/interbase/interbase.c:1.169 Tue Sep  2 18:37:26 2003
+++ php-src/ext/interbase/interbase.c   Wed Sep  3 11:15:30 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.169 2003/09/02 22:37:26 abies Exp $ */
+/* $Id: interbase.c,v 1.170 2003/09/03 15:15:30 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -706,7 +706,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.169 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.170 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -1311,190 +1311,152 @@
Bind parameter placeholders in a previously prepared query */
 static int _php_ibase_bind(XSQLDA *sqlda, zval **b_vars, BIND_BUF *buf, ibase_query 
*ib_query TSRMLS_DC)
 {
-   XSQLVAR *var;
-   zval *b_var;
-   int i;
+   int i , rv = SUCCESS;
+   XSQLVAR *var = sqlda->sqlvar;
 
-   var = sqlda->sqlvar;
-   for (i = 0; i < sqlda->sqld; var++, i++) { /* bound vars */
+   for (i = 0; i < sqlda->sqld; ++var, ++i) { /* bound vars */

-   buf[i].sqlind = 0;
+   zval *b_var = b_vars[i];
+
var->sqlind = &buf[i].sqlind;
-   b_var = b_vars[i];

if (Z_TYPE_P(b_var) == IS_NULL) {
-   static char nothing[64];
-   static short null_flag = -1;
-   var->sqldata = nothing;
-   var->sqltype |= 1;
-   var->sqlind = &null_flag;
-   if (var->sqllen > 64) {
-   var->sqllen = 64;
+
+   if ((var->sqltype & 1) != 1) {
+   _php_ibase_module_error("Parameter %d must have a 
value" TSRMLS_CC, i+1);
+   rv = FAILURE;
}
-   } else
-   
-   switch (var->sqltype & ~1) {
-   case SQL_TEXT: /* direct to variable */
-   case SQL_VARYING:
-   convert_to_string(b_var);
-   var->sqldata = (void *) Z_STRVAL_P(b_var);
-   var->sqllen  = Z_STRLEN_P(b_var);
-   var->sqltype = SQL_TEXT + (var->sqltype & 1);
-   break;
-   case SQL_SHORT:
-   convert_to_long(b_var);
-   if (Z_LVAL_P(b_var) > SHRT_MAX || Z_LVAL_P(b_var) < 
SHRT_MIN) {
-   _php_ibase_module_error("Field %*s overflow" 
TSRMLS_CC, var->aliasname_length, var->aliasname);
-   return FAILURE;
-   }
-   buf[i].val.sval = (short) Z_LVAL_P(b_var);
-   var->sqldata = (void *) (&buf[i].val.sval);
-   break;
-   case SQL_LONG:
-   if (var->sqlscale < 0) {
-   /*
- DECIMAL or NUMERIC field stored internally 
as scaled integer.
- Coerce it to string and let InterBase's 
internal routines
- handle it.
-   */
-   convert_to_string(b_var);
-   var->sqldata = (void *) Z_STRVAL_P(b_var);
-   var->sqllen  = Z_STRLEN_P(b_var);
-   var->sqltype = SQL_TEXT;
-   } else {
-   convert_to_long(b_var);
-   var->sqldata = (void *) (&Z_LVAL_P(b_var));
-   }
-   break;
-   case SQL_FLOAT:
-   convert_to_double(b_var);
-   buf[i].val.fval = (float) Z_DVAL_P(b_var);
-   var->sqldata = (void *) (&buf[i].val.fval);
-   break;
-   case SQL_DOUBLE:  /* direct to variable */
-   convert_to_double(b_var);
-   var->sqldata = (void *) 

[PHP-CVS] cvs: php-src /ext/interbase interbase.c php_interbase.h

2003-09-02 Thread Ard Biesheuvel
abies   Tue Sep  2 18:37:26 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c php_interbase.h 
  Log:
  Nuke far pointers
  # Unfortunately, this does break compatibility with Windows 3.x :-)
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.168 php-src/ext/interbase/interbase.c:1.169
--- php-src/ext/interbase/interbase.c:1.168 Tue Sep  2 18:19:18 2003
+++ php-src/ext/interbase/interbase.c   Tue Sep  2 18:37:26 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.168 2003/09/02 22:19:18 abies Exp $ */
+/* $Id: interbase.c,v 1.169 2003/09/02 22:37:26 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -706,7 +706,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.168 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.169 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -1337,7 +1337,7 @@
case SQL_TEXT: /* direct to variable */
case SQL_VARYING:
convert_to_string(b_var);
-   var->sqldata = (void ISC_FAR *) Z_STRVAL_P(b_var);
+   var->sqldata = (void *) Z_STRVAL_P(b_var);
var->sqllen  = Z_STRLEN_P(b_var);
var->sqltype = SQL_TEXT + (var->sqltype & 1);
break;
@@ -1348,7 +1348,7 @@
return FAILURE;
}
buf[i].val.sval = (short) Z_LVAL_P(b_var);
-   var->sqldata = (void ISC_FAR *) (&buf[i].val.sval);
+   var->sqldata = (void *) (&buf[i].val.sval);
break;
case SQL_LONG:
if (var->sqlscale < 0) {
@@ -1358,22 +1358,22 @@
  handle it.
*/
convert_to_string(b_var);
-   var->sqldata = (void ISC_FAR *) 
Z_STRVAL_P(b_var);
+   var->sqldata = (void *) Z_STRVAL_P(b_var);
var->sqllen  = Z_STRLEN_P(b_var);
var->sqltype = SQL_TEXT;
} else {
convert_to_long(b_var);
-   var->sqldata = (void ISC_FAR *) 
(&Z_LVAL_P(b_var));
+   var->sqldata = (void *) (&Z_LVAL_P(b_var));
}
break;
case SQL_FLOAT:
convert_to_double(b_var);
buf[i].val.fval = (float) Z_DVAL_P(b_var);
-   var->sqldata = (void ISC_FAR *) (&buf[i].val.fval);
+   var->sqldata = (void *) (&buf[i].val.fval);
break;
case SQL_DOUBLE:  /* direct to variable */
convert_to_double(b_var);
-   var->sqldata = (void ISC_FAR *) (&Z_DVAL_P(b_var));
+   var->sqldata = (void *) (&Z_DVAL_P(b_var));
break;
 #ifdef SQL_INT64
case SQL_INT64:
@@ -1383,7 +1383,7 @@
  to avoid rounding errors...
*/
convert_to_string(b_var);
-   var->sqldata = (void ISC_FAR *) Z_STRVAL_P(b_var);
+   var->sqldata = (void *) Z_STRVAL_P(b_var);
var->sqllen  = Z_STRLEN_P(b_var);
var->sqltype = SQL_TEXT;
break;
@@ -1415,7 +1415,7 @@
t.tm_year -= 1900;
t.tm_mon--;
isc_encode_date(&t, &buf[i].val.qval);
-   var->sqldata = (void ISC_FAR *) 
(&buf[i].val.qval);
+   var->sqldata = (void *) (&buf[i].val.qval);
}
 #else
/*
@@ -1426,7 +1426,7 @@
  ask Sascha?
*/
convert_to_string(b_var);
-   var->sqldata = (void ISC_FAR *) Z_STRVAL_P(

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-09-02 Thread Ard Biesheuvel
abies   Tue Sep  2 18:19:19 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  CS fixes
  # Boy, these guys are worse than -ansi -pedantic
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.167 php-src/ext/interbase/interbase.c:1.168
--- php-src/ext/interbase/interbase.c:1.167 Tue Sep  2 15:30:20 2003
+++ php-src/ext/interbase/interbase.c   Tue Sep  2 18:19:18 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.167 2003/09/02 19:30:20 abies Exp $ */
+/* $Id: interbase.c,v 1.168 2003/09/02 22:19:18 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -706,7 +706,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.167 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.168 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -2985,7 +2985,7 @@
 /* }}} */
 #endif
 
-/* {{{ proto int ibase_num_fields(resource query|result)
+/* {{{ proto int ibase_num_fields(resource query_result)
Get the number of fields in result */
 PHP_FUNCTION(ibase_num_fields)
 {
@@ -3024,68 +3024,85 @@
 /* {{{ static char * _php_ibase_field_type() */
 static char * _php_ibase_field_type(XSQLVAR *var)
 {
-   char buf[32], *s;
-   int precision;
+   char *s = "(unknown type)";

-   switch (var->sqltype & ~1) {
-   case SQL_TEXT:  s = "CHAR"; break;
-   case SQL_VARYING:   s = "VARCHAR"; break;
-   case SQL_SHORT:
-   if (var->sqlscale < 0) {
+   if (var->sqlscale < 0) {
+   char buf[16];
+   unsigned short precision;
+
+   switch (var->sqltype & ~1) {
+
+   case SQL_SHORT:
precision = 4;
-   } else {
-   s = "SMALLINT"; 
-   }
-   break;
-   case SQL_LONG:
-   if (var->sqlscale < 0) {
+   break;
+   case SQL_LONG:
precision = 9;
-   } else {
-   s = "INTEGER"; 
-   }
-   break;
-   case SQL_FLOAT: s = "FLOAT"; break;
-   case SQL_DOUBLE:
-   case SQL_D_FLOAT:   s = "DOUBLE PRECISION"; break;
+   break;
 #ifdef SQL_INT64
-   case SQL_INT64: 
-   if (var->sqlscale < 0) {
+   case SQL_INT64: 
precision = 18;
-   } else {
+   break;
+#endif
+   }
+   sprintf(buf, "NUMERIC(%d,%d)", precision, -var->sqlscale);
+   return estrdup(buf);
+   } else {
+   switch (var->sqltype & ~1) {
+   case SQL_TEXT:
+   s = "CHAR"; 
+   break;
+   case SQL_VARYING:
+   s = "VARCHAR"; 
+   break;
+   case SQL_SHORT:
+   s = "SMALLINT"; 
+   break;
+   case SQL_LONG:
+   s = "INTEGER"; 
+   break;
+   case SQL_FLOAT: 
+   s = "FLOAT"; break;
+   case SQL_DOUBLE:
+   case SQL_D_FLOAT:   
+   s = "DOUBLE PRECISION"; break;
+#ifdef SQL_INT64
+   case SQL_INT64: 
s = "BIGINT"; 
-   }
-   break;
+   break;
 #endif
 #ifdef SQL_TIMESTAMP
-   case SQL_TIMESTAMP: s = "TIMESTAMP"; break;
-   case SQL_TYPE_DATE: s = "DATE"; break;
-   case SQL_TYPE_TIME: s = "TIME"; break;
+   case SQL_TIMESTAMP: 
+   s = "TIMESTAMP"; 
+   break;
+   case SQL_TYPE_DATE:
+   s = "DATE";
+   break;
+   case SQL_TYPE_TIME:
+   s = "TIME"; 
+   break;
 #else
-   case SQL_DATE:  s = "DATE"; break;
+   case SQL_DATE:
+   s = "DATE"; 
+   break;
 #endif
-   case SQL_BLOB:  s = "BLOB"; break;
- 

Re: [PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-09-02 Thread Ard Biesheuvel
> Please don't use | in parameter names, you couldn't do that in php.
> Make it query_result or something like that.
OK

> And please have a look at CS we prefer case and their statments on
> different lines.
Actually, that's how it was in the original file.
Will fix it.
--
Ard
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-09-02 Thread Marcus Börger
Hello Ard,

Tuesday, September 2, 2003, 9:30:22 PM, you wrote:

> abies Tue Sep  2 15:30:22 2003 EDT

>   Modified files:  
> /php-src/ext/interbaseinterbase.c 
>   Log:
>   Make ibase_{param|field}_info() return typenames that actually mean something
  

> -/* {{{ proto int ibase_num_fields(resource {query|result})
> +/* {{{ proto int ibase_num_fields(resource query|result)

Please don't use | in parameter names, you couldn't do that in php. Make it
query_result or something like that.

And please have a look at CS we prefer case and their statments on different
lines.

-- 
Best regards,
 Marcusmailto:[EMAIL PROTECTED]

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-09-02 Thread Ard Biesheuvel
abies   Tue Sep  2 15:30:22 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Make ibase_{param|field}_info() return typenames that actually mean something
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.166 php-src/ext/interbase/interbase.c:1.167
--- php-src/ext/interbase/interbase.c:1.166 Tue Sep  2 09:17:56 2003
+++ php-src/ext/interbase/interbase.c   Tue Sep  2 15:30:20 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.166 2003/09/02 13:17:56 abies Exp $ */
+/* $Id: interbase.c,v 1.167 2003/09/02 19:30:20 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -706,7 +706,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.166 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.167 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -2985,7 +2985,7 @@
 /* }}} */
 #endif
 
-/* {{{ proto int ibase_num_fields(resource {query|result})
+/* {{{ proto int ibase_num_fields(resource query|result)
Get the number of fields in result */
 PHP_FUNCTION(ibase_num_fields)
 {
@@ -3021,14 +3021,78 @@
 }
 /* }}} */
 
-/* {{{ proto array ibase_field_info(resource result, int field_number)
+/* {{{ static char * _php_ibase_field_type() */
+static char * _php_ibase_field_type(XSQLVAR *var)
+{
+   char buf[32], *s;
+   int precision;
+   
+   switch (var->sqltype & ~1) {
+   case SQL_TEXT:  s = "CHAR"; break;
+   case SQL_VARYING:   s = "VARCHAR"; break;
+   case SQL_SHORT:
+   if (var->sqlscale < 0) {
+   precision = 4;
+   } else {
+   s = "SMALLINT"; 
+   }
+   break;
+   case SQL_LONG:
+   if (var->sqlscale < 0) {
+   precision = 9;
+   } else {
+   s = "INTEGER"; 
+   }
+   break;
+   case SQL_FLOAT: s = "FLOAT"; break;
+   case SQL_DOUBLE:
+   case SQL_D_FLOAT:   s = "DOUBLE PRECISION"; break;
+#ifdef SQL_INT64
+   case SQL_INT64: 
+   if (var->sqlscale < 0) {
+   precision = 18;
+   } else {
+   s = "BIGINT"; 
+   }
+   break;
+#endif
+#ifdef SQL_TIMESTAMP
+   case SQL_TIMESTAMP: s = "TIMESTAMP"; break;
+   case SQL_TYPE_DATE: s = "DATE"; break;
+   case SQL_TYPE_TIME: s = "TIME"; break;
+#else
+   case SQL_DATE:  s = "DATE"; break;
+#endif
+   case SQL_BLOB:  s = "BLOB"; break;
+   case SQL_ARRAY: s = "ARRAY"; break;
+
+   /* TODO provide more detailed information about the 
field type, field size
+  and array dimensions */
+   
+   case SQL_QUAD:  s = "QUAD"; break;
+
+   default:
+   sprintf(buf, "unknown (%d)", var->sqltype & ~1);
+   s = buf;
+   break;
+   }
+   if (var->sqlscale < 0) {
+   sprintf(buf, "NUMERIC(%d,%d)", precision, -var->sqlscale);
+   s = buf;
+   }
+   
+   return estrdup(s);
+}
+/* }}} */
+
+/* {{{ proto array ibase_field_info(resource query|result, int field_number)
Get information about a field */
 PHP_FUNCTION(ibase_field_info)
 {
zval **result_arg, **field_arg;
-   ibase_result *ib_result;
-   char buf[30], *s;
-   int len;
+   char buf[8], *s;
+   int len, type;
+   XSQLDA *sqlda;
XSQLVAR *var;
 
RESET_ERRMSG;
@@ -3037,22 +3101,34 @@
WRONG_PARAM_COUNT;
}
 
-   ZEND_FETCH_RESOURCE(ib_result, ibase_result *, result_arg, -1, "InterBase 
result", le_result);
+   zend_list_find(Z_LVAL_PP(result_arg), &type);
+   
+   if (type == le_query) {
+   ibase_query *ib_query;
 
-   if (ib_result->out_sqlda == NULL) {
+   ZEND_FETCH_RESOURCE(ib_query, ibase_query *, result_arg, -1, 
"InterBase query", le_query);
+   sqlda = ib_query->out_sqlda;
+   } else {
+   ibase_result *ib_result;
+   
+   ZEND_FETCH_RESOURCE(ib_result, ibase_result *, result_arg, -1, 
"InterBase result", le_result);
+   sqlda = ib_result->out_sqlda;
+   }   
+
+   if (sqlda == NULL) {
_

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-09-02 Thread Ard Biesheuvel
abies   Tue Sep  2 09:17:57 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Can't ignore variadic DEBUG macro for compilers
  that don't support them. Revert.
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.165 php-src/ext/interbase/interbase.c:1.166
--- php-src/ext/interbase/interbase.c:1.165 Tue Sep  2 08:46:42 2003
+++ php-src/ext/interbase/interbase.c   Tue Sep  2 09:17:56 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.165 2003/09/02 12:46:42 abies Exp $ */
+/* $Id: interbase.c,v 1.166 2003/09/02 13:17:56 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -43,7 +43,7 @@
 #endif
 
 #ifdef ZEND_DEBUG_
-#define IBDEBUG(fmt, ...) php_printf("::: (%4d) " fmt " \n",  __LINE__, ##__VA_ARGS__)
+#define IBDEBUG(a) php_printf("::: %s (%d)\n", a, __LINE__);
 #endif
 
 #ifndef IBDEBUG
@@ -261,7 +261,7 @@
 {
int type;
 
-   IBDEBUG("Resource #%ld transaction or database link?",Z_LVAL_PP(link_id));
+   IBDEBUG("Transaction or database link?");
if (zend_list_find(Z_LVAL_PP(link_id), &type)) {
if (type == le_trans) {
/* Transaction resource: make sure it refers to one link only, 
then 
@@ -706,7 +706,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.165 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.166 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -1634,7 +1634,7 @@
 
/* allocate sqlda and output buffers */
if (ib_query->out_sqlda) { /* output variables in select, select for update */
-   IBDEBUG("Query wants XSQLDA with %d field(s) for 
output",ib_query->out_sqlda->sqld);
+   IBDEBUG("Query wants XSQLDA for output");
IB_RESULT = emalloc(sizeof(ibase_result));
IB_RESULT->link = ib_query->link;
IB_RESULT->trans = ib_query->trans;
@@ -1656,7 +1656,7 @@
}
 
if (ib_query->in_sqlda) { /* has placeholders */
-   IBDEBUG("Query wants XSQLDA with %d field(s) for 
input",ib_query->in_sqlda->sqld);
+   IBDEBUG("Query wants XSQLDA for input");
if (ib_query->in_sqlda->sqld != argc) {
_php_ibase_module_error("Placeholders (%d) and variables (%d) 
mismatch" TSRMLS_CC, ib_query->in_sqlda->sqld, argc);
goto _php_ibase_exec_error;
@@ -2878,7 +2878,7 @@

/* Have we used this cursor before and it's still open (exec proc has no 
cursor) ? */
if (ib_query->result_res_id != 0 && ib_query->statement_type != 
isc_info_sql_stmt_exec_procedure) {
-   IBDEBUG("Implicitly closing a cursor for result resource 
#%d",ib_query->result_res_id);
+   IBDEBUG("Implicitly closing a cursor");
if (isc_dsql_free_statement(IB_STATUS, &ib_query->stmt, DSQL_close)) {
_php_ibase_error(TSRMLS_C);
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-09-02 Thread Ard Biesheuvel
abies   Tue Sep  2 08:46:43 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Changed some formatting/macro/debugging/variadic stuff
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.164 php-src/ext/interbase/interbase.c:1.165
--- php-src/ext/interbase/interbase.c:1.164 Thu Aug 28 18:12:06 2003
+++ php-src/ext/interbase/interbase.c   Tue Sep  2 08:46:42 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.164 2003/08/28 22:12:06 abies Exp $ */
+/* $Id: interbase.c,v 1.165 2003/09/02 12:46:42 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -43,7 +43,7 @@
 #endif
 
 #ifdef ZEND_DEBUG_
-#define IBDEBUG(a) php_printf("::: %s (%d)\n", a, __LINE__);
+#define IBDEBUG(fmt, ...) php_printf("::: (%4d) " fmt " \n",  __LINE__, ##__VA_ARGS__)
 #endif
 
 #ifndef IBDEBUG
@@ -220,6 +220,8 @@
 
 /* {{{ _php_ibase_module_error()
print php interbase module error and save it for ibase_errmsg() */
+static void _php_ibase_module_error(char * TSRMLS_DC, ...) 
PHP_ATTRIBUTE_FORMAT(printf,1,PHP_ATTR_FMT_OFFSET +2);
+
 static void _php_ibase_module_error(char *msg TSRMLS_DC, ...)
 {
va_list ap;
@@ -259,7 +261,7 @@
 {
int type;
 
-   IBDEBUG("Transaction or database link?");
+   IBDEBUG("Resource #%ld transaction or database link?",Z_LVAL_PP(link_id));
if (zend_list_find(Z_LVAL_PP(link_id), &type)) {
if (type == le_trans) {
/* Transaction resource: make sure it refers to one link only, 
then 
@@ -704,7 +706,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.164 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.165 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -1632,7 +1634,7 @@
 
/* allocate sqlda and output buffers */
if (ib_query->out_sqlda) { /* output variables in select, select for update */
-   IBDEBUG("Query wants XSQLDA for output");
+   IBDEBUG("Query wants XSQLDA with %d field(s) for 
output",ib_query->out_sqlda->sqld);
IB_RESULT = emalloc(sizeof(ibase_result));
IB_RESULT->link = ib_query->link;
IB_RESULT->trans = ib_query->trans;
@@ -1654,7 +1656,7 @@
}
 
if (ib_query->in_sqlda) { /* has placeholders */
-   IBDEBUG("Query wants XSQLDA for input");
+   IBDEBUG("Query wants XSQLDA with %d field(s) for 
input",ib_query->in_sqlda->sqld);
if (ib_query->in_sqlda->sqld != argc) {
_php_ibase_module_error("Placeholders (%d) and variables (%d) 
mismatch" TSRMLS_CC, ib_query->in_sqlda->sqld, argc);
goto _php_ibase_exec_error;
@@ -2418,7 +2420,7 @@
 #if HAVE_STRFTIME
j = strftime(string_data, sizeof(string_data), format, 
&t);
 #else
-   /* FIXME */
+   /* FIXME (will not work for time values) */
if (!t.tm_hour && !t.tm_min && !t.tm_sec) {
j = sprintf(string_data, "%02d/%02d/%4d", 
t.tm_mon + 1, t.tm_mday, t.tm_year + 1900);
} else {
@@ -2876,7 +2878,7 @@

/* Have we used this cursor before and it's still open (exec proc has no 
cursor) ? */
if (ib_query->result_res_id != 0 && ib_query->statement_type != 
isc_info_sql_stmt_exec_procedure) {
-   IBDEBUG("Implicitly closing a cursor");
+   IBDEBUG("Implicitly closing a cursor for result resource 
#%d",ib_query->result_res_id);
if (isc_dsql_free_statement(IB_STATUS, &ib_query->stmt, DSQL_close)) {
_php_ibase_error(TSRMLS_C);
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-28 Thread Ard Biesheuvel
abies   Thu Aug 28 18:12:07 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Prototype fixes
  Return number of affected rows by ibase_query() and ibase_execute() if > 0
  # Second change was actually introduced in 1.149, but never 
  # mentioned in the CVS log
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.163 php-src/ext/interbase/interbase.c:1.164
--- php-src/ext/interbase/interbase.c:1.163 Thu Aug 28 12:48:22 2003
+++ php-src/ext/interbase/interbase.c   Thu Aug 28 18:12:06 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.163 2003/08/28 16:48:22 abies Exp $ */
+/* $Id: interbase.c,v 1.164 2003/08/28 22:12:06 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -185,7 +185,7 @@
 }
 /* }}} */
 
-/* {{{ proto string ibase_errcode(void) 
+/* {{{ proto int ibase_errcode(void) 
Return error code */
 PHP_FUNCTION(ibase_errcode)
 {
@@ -704,7 +704,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.163 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.164 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -2033,7 +2033,7 @@
 }
 /* }}} */
 
-/* {{{ proto resource ibase_query([resource link_identifier [, resource 
link_identifier ] ,] string query [, int bind_args])
+/* {{{ proto mixed ibase_query([resource link_identifier, [ resource link_identifier, 
]] string query [, mixed bind_arg [, mixed bind_arg [, ...]]])
Execute a query */
 PHP_FUNCTION(ibase_query)
 {
@@ -2188,7 +2188,7 @@
 }
 /* }}} */
 
-/* {{{ proto ibase_affected_rows( [ resource link_identifier ] )
+/* {{{ proto int ibase_affected_rows( [ resource link_identifier ] )
Returns the number of rows affected by the previous INSERT, UPDATE or DELETE 
statement */
 PHP_FUNCTION(ibase_affected_rows)
 {
@@ -2847,7 +2847,7 @@
 }
 /* }}} */
 
-/* {{{ proto resource ibase_execute(resource query [, int bind_args [, int ...]])
+/* {{{ proto mixed ibase_execute(resource query [, mixed bind_arg [, mixed bind_arg 
[, ...]]])
Execute a previously prepared query */
 PHP_FUNCTION(ibase_execute)
 {
@@ -2927,7 +2927,7 @@
 /* }}} */
 
 #if HAVE_STRFTIME
-/* {{{ proto int ibase_timefmt(string format)
+/* {{{ proto bool ibase_timefmt(string format)
Sets the format of timestamp, date and time columns returned from queries */
 PHP_FUNCTION(ibase_timefmt)
 {
@@ -3254,7 +3254,7 @@
 }
 /* }}} */
 
-/* {{{ proto int ibase_blob_create([resource link_identifier])
+/* {{{ proto resource ibase_blob_create([resource link_identifier])
Create blob for adding data */
 PHP_FUNCTION(ibase_blob_create)
 {
@@ -3299,7 +3299,7 @@
 }
 /* }}} */
 
-/* {{{ proto int ibase_blob_open([ resource link_identifier, ] string blob_id)
+/* {{{ proto resource ibase_blob_open([ resource link_identifier, ] string blob_id)
Open blob for retrieving data parts */
 PHP_FUNCTION(ibase_blob_open)
 {
@@ -3356,7 +3356,7 @@
 }
 /* }}} */
 
-/* {{{ proto bool ibase_blob_add(int blob_id, string data)
+/* {{{ proto bool ibase_blob_add(resource blob_handle, string data)
Add data into created blob */
 PHP_FUNCTION(ibase_blob_add)
 {
@@ -3382,7 +3382,7 @@
 }
 /* }}} */
 
-/* {{{ proto string ibase_blob_get(int blob_id, int len)
+/* {{{ proto string ibase_blob_get(resource blob_handle, int len)
Get len bytes data from open blob */
 PHP_FUNCTION(ibase_blob_get)
 {
@@ -3448,7 +3448,7 @@
 }
 /* }}} */
 
-/* {{{ proto bool ibase_blob_close(int blob_id)
+/* {{{ proto string ibase_blob_close(resource blob_handle)
Close blob */
 PHP_FUNCTION(ibase_blob_close)
 {
@@ -3456,7 +3456,7 @@
 }
 /* }}} */
 
-/* {{{ proto bool ibase_blob_cancel(int blob_id)
+/* {{{ proto bool ibase_blob_cancel(resource blob_handle)
Cancel creating blob */
 PHP_FUNCTION(ibase_blob_cancel)
 {
@@ -3464,7 +3464,7 @@
 }
 /* }}} */
 
-/* {{{ proto object ibase_blob_info([ resource link_identifier, ] string blob_id_str)
+/* {{{ proto array ibase_blob_info([ resource link_identifier, ] string blob_id)
Return blob length and other useful info */
 PHP_FUNCTION(ibase_blob_info)
 {
@@ -3545,7 +3545,7 @@
 }
 /* }}} */
 
-/* {{{ proto bool ibase_blob_echo([ resource link_identifier, ] string blob_id_str)
+/* {{{ proto bool ibase_blob_echo([ resource link_identifier, ] string blob_id)
Output blob contents to browser */
 PHP_FUNCTION(ibase_blob_echo)
 {
@@ -3884,7 +3884,7 @@
 }
 /* }}} */
 
-/* {{{ proto string ibase_wait_event([resource link,] string event [, string event [, 
...]])
+/* {{{ proto string ibase_wait_event([resource link_identifier,] string event [, 
string event [, ...]])
Waits for any one of the passed Interbase events to be posted by the database, and 
returns its name */
 PHP_FUNCTION(ibase_wait_event)
 {
@@ -4015,7

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-28 Thread Ard Biesheuvel
abies   Thu Aug 28 12:48:23 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Fixed some format strings
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.162 php-src/ext/interbase/interbase.c:1.163
--- php-src/ext/interbase/interbase.c:1.162 Wed Aug 27 20:11:16 2003
+++ php-src/ext/interbase/interbase.c   Thu Aug 28 12:48:22 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.162 2003/08/28 00:11:16 abies Exp $ */
+/* $Id: interbase.c,v 1.163 2003/08/28 16:48:22 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -704,7 +704,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.162 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.163 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -887,12 +887,12 @@
list_entry new_le;

if ((IBG(max_links) != -1) && (IBG(num_links) >= 
IBG(max_links))) {
-   _php_ibase_module_error("Too many open links (%d)" 
TSRMLS_CC, IBG(num_links));
+   _php_ibase_module_error("Too many open links (%ld)" 
TSRMLS_CC, IBG(num_links));
efree(hashed_details);
RETURN_FALSE;
}
if ((IBG(max_persistent) != -1) && (IBG(num_persistent) >= 
IBG(max_persistent))) {
-   _php_ibase_module_error("Too many open persistent 
links (%d)" TSRMLS_CC, IBG(num_persistent));
+   _php_ibase_module_error("Too many open persistent 
links (%ld)" TSRMLS_CC, IBG(num_persistent));
efree(hashed_details);
RETURN_FALSE;
}
@@ -953,7 +953,7 @@
}
}
if ((IBG(max_links) != -1) && (IBG(num_links) >= IBG(max_links))) {
-   _php_ibase_module_error("Too many open links (%d)" TSRMLS_CC, 
IBG(num_links));
+   _php_ibase_module_error("Too many open links (%ld)" TSRMLS_CC, 
IBG(num_links));
efree(hashed_details);
RETURN_FALSE;
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-28 Thread Ard Biesheuvel
abies   Wed Aug 27 20:11:17 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Removed TSRMLS_FETCH from _php_ibase_module_error()
  
  Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.161 php-src/ext/interbase/interbase.c:1.162
--- php-src/ext/interbase/interbase.c:1.161 Wed Aug 27 18:55:05 2003
+++ php-src/ext/interbase/interbase.c   Wed Aug 27 20:11:16 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.161 2003/08/27 22:55:05 abies Exp $ */
+/* $Id: interbase.c,v 1.162 2003/08/28 00:11:16 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -220,12 +220,16 @@
 
 /* {{{ _php_ibase_module_error()
print php interbase module error and save it for ibase_errmsg() */
-static void _php_ibase_module_error(char *msg, ...)
+static void _php_ibase_module_error(char *msg TSRMLS_DC, ...)
 {
va_list ap;
-   TSRMLS_FETCH();
 
+#ifdef ZTS
+   va_start(ap, TSRMLS_C);
+#else
va_start(ap, msg);
+#endif
+
/* vsnprintf NUL terminates the buf and writes at most n-1 chars+NUL */
vsnprintf(IBG(errmsg), MAX_ERRMSG, msg, ap);
va_end(ap);
@@ -263,7 +267,7 @@
IBDEBUG("Type is le_trans");
ZEND_FETCH_RESOURCE(*trans, ibase_trans *, link_id, -1, 
"InterBase transaction", le_trans);
if ((*trans)->link_cnt > 1) {
-   _php_ibase_module_error("Link id is ambiguous: 
transaction spans multiple connections.");
+   _php_ibase_module_error("Link id is ambiguous: 
transaction spans multiple connections." TSRMLS_CC);
return;
}   
*ib_link = (*trans)->db_link[0];
@@ -520,7 +524,7 @@
if (ib_blob->bl_handle != NULL) { /* blob open*/
if (isc_cancel_blob(IB_STATUS, &ib_blob->bl_handle)) {
_php_ibase_module_error("You can lose data. Close any blob 
after " 
-   "reading from or writing to it. Use ibase_blob_close() 
before calling ibase_close()");
+   "reading from or writing to it. Use ibase_blob_close() 
before calling ibase_close()" TSRMLS_CC);
}
}
efree(ib_blob);
@@ -700,7 +704,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.161 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.162 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -864,7 +868,7 @@
list_entry *le;
int open_new_connection = 1;

-   if ( (zend_hash_find(&EG(persistent_list), hashed_details, 
hashed_details_length + 1, (void *) &le)) ) {
+   if ( (zend_hash_find(&EG(persistent_list), hashed_details, 
hashed_details_length + 1, (void *) &le) != FAILURE) ) {
static char info[] = {isc_info_base_level, isc_info_end};
char result[8]; /* Enough? Hope so... */ 
 
@@ -883,12 +887,12 @@
list_entry new_le;

if ((IBG(max_links) != -1) && (IBG(num_links) >= 
IBG(max_links))) {
-   _php_ibase_module_error("Too many open links (%d)", 
IBG(num_links));
+   _php_ibase_module_error("Too many open links (%d)" 
TSRMLS_CC, IBG(num_links));
efree(hashed_details);
RETURN_FALSE;
}
if ((IBG(max_persistent) != -1) && (IBG(num_persistent) >= 
IBG(max_persistent))) {
-   _php_ibase_module_error("Too many open persistent 
links (%d)", IBG(num_persistent));
+   _php_ibase_module_error("Too many open persistent 
links (%d)" TSRMLS_CC, IBG(num_persistent));
efree(hashed_details);
RETURN_FALSE;
}
@@ -929,7 +933,7 @@
 * if it doesn't, open a new ib_link, add it to the resource list,
 * and add a pointer to it with hashed_details as the key.
 */
-   if ( (zend_hash_find(&EG(regular_list), hashed_details, 
hashed_details_length + 1, (void *) &index_ptr)) ) {
+   if ( (zend_hash_find(&EG(regular_list), hashed_details, 
hashed_details_length + 1, (void *) &index_ptr) == SUCCESS) ) {
int type, xlink;
void *ptr;
if (Z_TYPE_P(index_ptr) != le_index_ptr) {
@@ -949,7 +953,7 @@
  

[PHP-CVS] cvs: php-src /ext/interbase interbase.c php_interbase.h

2003-08-28 Thread Ard Biesheuvel
abies   Wed Aug 27 18:55:06 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c php_interbase.h 
  Log:
  Do not reuse data structure for ibase_execute() results.
  Invalidate the results whose statement handle has been invalidated.
  # EXEC PROCEDURE results don't need a statement handle, so
  # the result doesn't have to be invalidated.
  Fixed some add_{index|assoc}_*() bogosity
  Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.160 php-src/ext/interbase/interbase.c:1.161
--- php-src/ext/interbase/interbase.c:1.160 Wed Aug 20 18:59:33 2003
+++ php-src/ext/interbase/interbase.c   Wed Aug 27 18:55:05 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.160 2003/08/20 22:59:33 abies Exp $ */
+/* $Id: interbase.c,v 1.161 2003/08/27 22:55:05 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -42,10 +42,11 @@
 #define SQL_DIALECT_CURRENT SQL_DIALECT_V5
 #endif
 
-#ifdef ZEND_DEBUG
-/* #define IBDEBUG(a) php_printf("::: %s (%d)\n", a, __LINE__); */
-#define IBDEBUG(a)
-#else
+#ifdef ZEND_DEBUG_
+#define IBDEBUG(a) php_printf("::: %s (%d)\n", a, __LINE__);
+#endif
+
+#ifndef IBDEBUG
 #define IBDEBUG(a)
 #endif
 
@@ -57,11 +58,24 @@
 #define LL_MASK "ll"
 #endif
 
-#define BLOB_ID_LEN 18
-#define BLOB_ID_MASK "0x%" LL_MASK "x"
+#define QUERY_RESULT   1
+#define EXECUTE_RESULT 2
+
+#define ROLLBACK   0
+#define COMMIT 1
+#define RETAIN 2
 
-#define BLOB_INPUT 1
-#define BLOB_OUTPUT 2
+#define FETCH_ROW  1
+#define FETCH_ARRAY2
+
+#define BLOB_ID_LEN18
+#define BLOB_ID_MASK   "0x%" LL_MASK "x"
+
+#define BLOB_INPUT 1
+#define BLOB_OUTPUT2
+
+#define BLOB_CLOSE 1
+#define BLOB_CANCEL2
 
 /* {{{ extension definition structures */
 function_entry ibase_functions[] = {
@@ -230,6 +244,11 @@
 char *tpb_ptr;
 } ISC_TEB;
 
+typedef struct {
+   ISC_USHORT vary_length;
+   char vary_string[1];
+} IBVARY;
+
 /* Fill ib_link and trans with the correct database link and transaction.
  */
 static void _php_ibase_get_link_trans(INTERNAL_FUNCTION_PARAMETERS, zval **link_id, 
ibase_db_link **ib_link, ibase_trans **trans)
@@ -298,7 +317,7 @@
 
/* shortcut for most common case */
if (sizeof(ISC_QUAD) == sizeof(ISC_UINT64)) {
-   sprintf(result, BLOB_ID_MASK, *(ISC_UINT64*) &qd);
+   sprintf(result, BLOB_ID_MASK, *(ISC_UINT64*)(void *) &qd); 
} else {
ISC_UINT64 res = ((ISC_UINT64) qd.gds_quad_high << 0x20) | 
qd.gds_quad_low;
sprintf(result, BLOB_ID_MASK, res);
@@ -346,7 +365,7 @@
  */
 static void _php_ibase_commit_link(ibase_db_link *link TSRMLS_DC)
 {
-   int i = 0, j;
+   unsigned short i = 0, j;
ibase_tr_list *l;
IBDEBUG("Checking transactions to close...");
 
@@ -433,9 +452,9 @@
ibase_result *ib_result = (ibase_result *) rsrc->ptr;
 
IBDEBUG("Freeing result by dtor...");
-   if (ib_result && ib_result->query == NULL) { /* doesn't belong to a query */
+   if (ib_result) {
_php_ibase_free_xsqlda(ib_result->out_sqlda);
-   if (ib_result->stmt) {
+   if (ib_result->stmt && ib_result->type != EXECUTE_RESULT) {
IBDEBUG("Dropping statement handle (free_result dtor)...");
isc_dsql_free_statement(IB_STATUS, &ib_result->stmt, 
DSQL_drop);
}
@@ -460,14 +479,6 @@
}
if (ib_query->stmt) {
IBDEBUG("Dropping statement handle (free_query)...");
-   if (ib_query->result) {
-   _php_ibase_free_xsqlda(ib_query->result->out_sqlda);
-   
-   if (ib_query->result->out_array) {
-   efree(ib_query->result->out_array);
-   }
-   efree(ib_query->result);
-   }
if (isc_dsql_free_statement(IB_STATUS, &ib_query->stmt, DSQL_drop)) {
_php_ibase_error(TSRMLS_C);
}
@@ -487,10 +498,16 @@
 /* {{{ php_ibase_free_query_rsrc() */
 static void php_ibase_free_query_rsrc(zend_rsrc_list_entry *rsrc TSRMLS_DC)
 {
-   if (rsrc->ptr != NULL) {
+   ibase_query *ib_query = (ibase_query *)rsrc->ptr;
+
+   if (ib_query != NULL) {
IBDEBUG("Preparing to free query by dtor...");
-   _php_ibase_free_query((ibase_query *)rsrc->ptr TSRMLS_CC);
-   efree(rsrc->ptr);
+
+   _php_ibase_free_query(ib_query TSRMLS_CC);
+   if (ib_query->statement_type != isc_info_sql_stmt_exec_procedure) {
+   zend_list_delete(ib_query->result_res_id);
+   }
+   efree(ib_query);
}
 }
 /* }}} */
@@ -514,7 +531,7 @@
 static v

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-20 Thread Ard Biesheuvel
abies   Wed Aug 20 18:59:34 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Fix false warning on zero-size BLOB fetch
  
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.159 php-src/ext/interbase/interbase.c:1.160
--- php-src/ext/interbase/interbase.c:1.159 Wed Aug 20 15:47:00 2003
+++ php-src/ext/interbase/interbase.c   Wed Aug 20 18:59:33 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.159 2003/08/20 19:47:00 abies Exp $ */
+/* $Id: interbase.c,v 1.160 2003/08/20 22:59:33 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -502,7 +502,8 @@
 
if (ib_blob->bl_handle != NULL) { /* blob open*/
if (isc_cancel_blob(IB_STATUS, &ib_blob->bl_handle)) {
-   php_error_docref(NULL TSRMLS_CC, E_ERROR, "You can lose data. 
Close any blob after reading of writing it. Use ibase_blob_close() before calling 
ibase_close()");
+   _php_ibase_module_error("You can lose data. Close any blob 
after " 
+   "reading from or writing to it. Use ibase_blob_close() 
before calling ibase_close()");
}
}
efree(ib_blob);
@@ -682,7 +683,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.159 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.160 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -2500,8 +2501,8 @@
 
 /* {{{ _php_ibase_fetch_hash() */
 
-#define FETCH_ROW  2
-#define FETCH_ARRAY 4
+#define FETCH_ROW  1
+#define FETCH_ARRAY 2
 
 static void _php_ibase_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int fetch_type)
 {
@@ -2570,7 +2571,8 @@
ibase_blob blob_handle;
unsigned long max_len = 0;
static char bl_items[] = 
{isc_info_blob_total_length};
-   char bl_info[20], *p;
+   char bl_info[20];
+   unsigned short i;

blob_handle.bl_handle = NULL;
blob_handle.bl_qd = *(ISC_QUAD ISC_FAR 
*) var->sqldata;
@@ -2586,25 +2588,29 @@
}

/* find total length of blob's data */
-   for (p = bl_info; *p != isc_info_end 
&& p < bl_info + sizeof(bl_info);) {
+   for (i = 0; i < sizeof(bl_info); ) {
unsigned short item_len;
-   char item = *p++;
+   char item = bl_info[i++];

-   item_len = (unsigned short) 
isc_vax_integer(p, 2);
-   p += 2;
+   if (item == isc_info_end || 
item == isc_info_truncated || 
+   item == isc_info_error 
|| i >= sizeof(bl_info)) {
+
+   
_php_ibase_module_error("Could not determine BLOB size (internal error)");
+   RETURN_FALSE;
+   }  
 
+
+   item_len = (unsigned short) 
isc_vax_integer(&bl_info[i], 2);
+
if (item == 
isc_info_blob_total_length) {
-   max_len = 
isc_vax_integer(p, item_len);
+   max_len = 
isc_vax_integer(&bl_info[i+2], item_len);
break;
}
-   p += item_len;
+   i += item_len+2;
}

if (max_len == 0) {
-   _php_ibase_module_error("Could 
not determine

[PHP-CVS] cvs: php-src /ext/interbase interbase.c php_interbase.h

2003-08-20 Thread Ard Biesheuvel
abies   Wed Aug 20 15:47:01 2003 EDT

  Modified files:  
/php-src/ext/interbase  php_interbase.h interbase.c 
  Log:
  Reuse result data structure and resource id for consecutive executions 
  of a prepared query
  # As previous resources are invalidated anyway because their statement
  # handle is reused, we don't have to allocate a new result for every
  # execution of a prepared query
  
  Index: php-src/ext/interbase/php_interbase.h
diff -u php-src/ext/interbase/php_interbase.h:1.55 
php-src/ext/interbase/php_interbase.h:1.56
--- php-src/ext/interbase/php_interbase.h:1.55  Wed Aug 20 12:13:51 2003
+++ php-src/ext/interbase/php_interbase.h   Wed Aug 20 15:47:00 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: php_interbase.h,v 1.55 2003/08/20 16:13:51 abies Exp $ */
+/* $Id: php_interbase.h,v 1.56 2003/08/20 19:47:00 abies Exp $ */
 
 #ifndef PHP_INTERBASE_H
 #define PHP_INTERBASE_H
@@ -144,13 +144,24 @@
 typedef struct {
ibase_db_link *link;
ibase_trans *trans;
+   struct _ibase_query *query;
+   isc_stmt_handle stmt;
+   XSQLDA *out_sqlda;
+   ibase_array *out_array;
+   unsigned char has_more_rows;
+   char statement_type;
+} ibase_result;
+
+typedef struct _ibase_query {
+   ibase_db_link *link;
+   ibase_trans *trans;
+   ibase_result *result;
+   int result_res_id;
isc_stmt_handle stmt;
-   int drop_stmt;
XSQLDA *in_sqlda, *out_sqlda;
ibase_array *in_array, *out_array;
int in_array_cnt, out_array_cnt;
unsigned short dialect;
-   int cursor_open;
char statement_type;
char *query;
int trans_res_id;
@@ -158,18 +169,7 @@
 
 typedef struct {
ibase_db_link *link;
-   ibase_trans *trans;
-   isc_stmt_handle stmt;
-   int drop_stmt;
-   XSQLDA *out_sqlda;
-   ibase_array *out_array;
-   unsigned char has_more_rows;
-   char statement_type;
-} ibase_result;
-
-typedef struct {
int link_res_id;
-   ibase_db_link *link;
ISC_LONG event_id;
unsigned short event_count;
char **events;
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.158 php-src/ext/interbase/interbase.c:1.159
--- php-src/ext/interbase/interbase.c:1.158 Wed Aug 20 12:13:51 2003
+++ php-src/ext/interbase/interbase.c   Wed Aug 20 15:47:00 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.158 2003/08/20 16:13:51 abies Exp $ */
+/* $Id: interbase.c,v 1.159 2003/08/20 19:47:00 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -433,22 +433,11 @@
ibase_result *ib_result = (ibase_result *) rsrc->ptr;
 
IBDEBUG("Freeing result by dtor...");
-   if (ib_result) {
+   if (ib_result && ib_result->query == NULL) { /* doesn't belong to a query */
_php_ibase_free_xsqlda(ib_result->out_sqlda);
-   if (ib_result->drop_stmt && ib_result->stmt) {
+   if (ib_result->stmt) {
IBDEBUG("Dropping statement handle (free_result dtor)...");
isc_dsql_free_statement(IB_STATUS, &ib_result->stmt, 
DSQL_drop);
-   } else {
-   /* Shouldn't be here unless query was select and had parameter
-  placeholders, in which case ibase_execute handles this???
-  (Testing seems to confirm the decision was a right one.)
-   */
-   IBDEBUG("Closing statement handle...");
-   /*
-   if (isc_dsql_free_statement(IB_STATUS, &ib_result->stmt, 
DSQL_close)) {
-   _php_ibase_error();
-   }
-   */
}
if (ib_result->out_array) {
efree(ib_result->out_array);
@@ -471,6 +460,14 @@
}
if (ib_query->stmt) {
IBDEBUG("Dropping statement handle (free_query)...");
+   if (ib_query->result) {
+   _php_ibase_free_xsqlda(ib_query->result->out_sqlda);
+   
+   if (ib_query->result->out_array) {
+   efree(ib_query->result->out_array);
+   }
+   efree(ib_query->result);
+   }
if (isc_dsql_free_statement(IB_STATUS, &ib_query->stmt, DSQL_drop)) {
_php_ibase_error(TSRMLS_C);
}
@@ -685,7 +682,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.158 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.159 $");
 #ifdef COMPILE_DL_INTERBASE
php_info

[PHP-CVS] cvs: php-src /ext/interbase interbase.c php_interbase.h

2003-08-20 Thread Ard Biesheuvel
abies   Wed Aug 20 12:13:51 2003 EDT

  Modified files:  
/php-src/ext/interbase  php_interbase.h interbase.c 
  Log:
  Moved transaction defaults to header file
  
  
Index: php-src/ext/interbase/php_interbase.h
diff -u php-src/ext/interbase/php_interbase.h:1.54 
php-src/ext/interbase/php_interbase.h:1.55
--- php-src/ext/interbase/php_interbase.h:1.54  Wed Aug 20 08:22:58 2003
+++ php-src/ext/interbase/php_interbase.h   Wed Aug 20 12:13:51 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: php_interbase.h,v 1.54 2003/08/20 12:22:58 abies Exp $ */
+/* $Id: php_interbase.h,v 1.55 2003/08/20 16:13:51 abies Exp $ */
 
 #ifndef PHP_INTERBASE_H
 #define PHP_INTERBASE_H
@@ -180,23 +180,26 @@
 
 enum php_interbase_option {
PHP_IBASE_DEFAULT   = 0,
-   PHP_IBASE_UNIXTIME  = 2,
-   PHP_IBASE_TIMESTAMP = 4,
-   PHP_IBASE_DATE  = 8,
-   PHP_IBASE_TIME  = 16,
-   /* fetch args */
+   /* fetch flags */
PHP_IBASE_FETCH_BLOBS   = 1,
PHP_IBASE_FETCH_ARRAYS  = 2,
-   /* transactions */  
-   PHP_IBASE_WRITE = 2,
-   PHP_IBASE_READ  = 4,
-   PHP_IBASE_COMMITTED = 8,
-   PHP_IBASE_CONSISTENCY   = 16,
-   PHP_IBASE_CONCURRENCY   = 32,
-   PHP_IBASE_REC_VERSION   = 64,
-   PHP_IBASE_REC_NO_VERSION= 128,
-   PHP_IBASE_NOWAIT= 256,
-   PHP_IBASE_WAIT  = 512
+   PHP_IBASE_UNIXTIME  = 4,
+   /* timefmt flags */
+   PHP_IBASE_TIMESTAMP = 1,
+   PHP_IBASE_DATE  = 2,
+   PHP_IBASE_TIME  = 4,
+   /* transaction access mode */   
+   PHP_IBASE_WRITE = 0, /* default */
+   PHP_IBASE_READ  = 1,
+   /* transaction isolation level */
+   PHP_IBASE_CONCURRENCY   = 0, /* default */
+   PHP_IBASE_COMMITTED = 2,
+ PHP_IBASE_REC_NO_VERSION  = 0, /* default */
+ PHP_IBASE_REC_VERSION = 4,
+   PHP_IBASE_CONSISTENCY   = 8,
+   /* transaction lock resolution */
+   PHP_IBASE_WAIT  = 0, /* default */
+   PHP_IBASE_NOWAIT= 16
 };
 
 #ifdef ZTS
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.157 php-src/ext/interbase/interbase.c:1.158
--- php-src/ext/interbase/interbase.c:1.157 Wed Aug 20 09:02:26 2003
+++ php-src/ext/interbase/interbase.c   Wed Aug 20 12:13:51 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.157 2003/08/20 13:02:26 abies Exp $ */
+/* $Id: interbase.c,v 1.158 2003/08/20 16:13:51 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -276,7 +276,6 @@
short sqlind;
 } BIND_BUF;
 
-
 static inline int _php_ibase_string_to_quad(char const *id, ISC_QUAD *qd)
 {
/* shortcut for most common case */
@@ -284,10 +283,12 @@
return sscanf(id, BLOB_ID_MASK, (ISC_UINT64 *) qd);
} else {
ISC_UINT64 res;
-   int n = sscanf(id, BLOB_ID_MASK, &res);
-   qd->gds_quad_high = (long) (res >> 0x20);
-   qd->gds_quad_low = (unsigned long) (res & 0x);
-   return n;
+   if (sscanf(id, BLOB_ID_MASK, &res)) {
+   qd->gds_quad_high = (ISC_LONG) (res >> 0x20);
+   qd->gds_quad_low = (ISC_ULONG) (res & 0x);
+   return 1;
+   }
+   return 0;
}
 }
 
@@ -684,7 +685,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.157 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.158 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -1785,31 +1786,31 @@
last_tpb[tpb_len++] = isc_tpb_version3;
 
/* access mode */
-   if (trans_argl & PHP_IBASE_READ) { /* READ 
ONLY TRANSACTION */
+   if (PHP_IBASE_READ == (trans_argl & 
PHP_IBASE_READ)) {
last_tpb[tpb_len++] = isc_tpb_read;
-   } else {
-   last_tpb[tpb_len++] = isc_tpb_write;  
/* default access mode */
+   } else if (PHP_IBASE_WRITE == (trans_argl & 
PHP_I

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-20 Thread Ard Biesheuvel
abies   Wed Aug 20 09:02:27 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Cleaned up _php_ibase_var_zval()
  
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.156 php-src/ext/interbase/interbase.c:1.157
--- php-src/ext/interbase/interbase.c:1.156 Wed Aug 20 08:40:59 2003
+++ php-src/ext/interbase/interbase.c   Wed Aug 20 09:02:26 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.156 2003/08/20 12:40:59 abies Exp $ */
+/* $Id: interbase.c,v 1.157 2003/08/20 13:02:26 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -684,7 +684,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.156 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.157 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -2285,6 +2285,8 @@
char string_data[255];

switch (type & ~1) {
+   unsigned short j;
+
case SQL_VARYING:
len = ((PARAMVARY *) data)->vary_length;
data = ((PARAMVARY *) data)->vary_string;
@@ -2299,75 +2301,59 @@
break;
case SQL_LONG:
case SQL_SHORT:
-   if (scale) {
-   short j;
+   if (scale < 0) {
long n, f = 1;
+
if ( (type & ~1) == SQL_SHORT) {
-   n = (long) *(short *) (data);
+   n = *(short *) (data);
} else {
-   n = (long) *(long *) (data);
+   n = *(long *) (data);
}
for (j = 0; j < -scale; j++) {
f *= 10;
}
-   if (n  >= 0) {
-   Z_STRLEN_P(val) = sprintf(string_data, 
"%ld.%0*ld", n / f, -scale,  n % f );
-   } else if ((n/f) != 0) {
-   Z_STRLEN_P(val) = sprintf(string_data, 
"%ld.%0*ld", n / f, -scale,  -(n % f) );
+   if (n  >= 0 || n < -f) {
+   j = sprintf(string_data, "%ld.%0*ld", n / f, 
-scale,  labs(n % f) );
} else {
-   Z_STRLEN_P(val) = sprintf(string_data, 
"%s.%0*ld","-0", -scale, -(n % f) );
+   j = sprintf(string_data, "%s.%0*ld","-0", 
-scale, -n % f);
}
-   Z_TYPE_P(val) = IS_STRING;
-   Z_STRVAL_P(val) = estrdup(string_data);
+   ZVAL_STRINGL(val,string_data,j,1);
+   } else if ( (type & ~1) == SQL_SHORT) {
+   ZVAL_LONG(val, *(short *) data);
} else {
-   Z_TYPE_P(val) = IS_LONG;
-   if ( (type & ~1) == SQL_SHORT) {
-   Z_LVAL_P(val) = *(short *) (data);
-   } else {
-   Z_LVAL_P(val) = *(long *) (data);
-   }
+   ZVAL_LONG(val, *(long *) data);
}
break;
case SQL_FLOAT:
-   Z_TYPE_P(val) = IS_DOUBLE;
-   Z_DVAL_P(val) = *(float *) (data);
+   ZVAL_DOUBLE(val, *(float *) data);
break;
case SQL_DOUBLE:
-   if (scale) {
-   Z_TYPE_P(val) = IS_STRING;
-   Z_STRLEN_P(val) = sprintf(string_data, "%.*f", -scale, 
*(double *) data);
-   Z_STRVAL_P(val) = estrdup(string_data);
+   if (scale < 0) {
+   j = sprintf(string_data, "%.*f", -scale, *(double *) 
data);
+   ZVAL_STRINGL(val, string_data, j, 1);
} else {
-   Z_TYPE_P(val) = IS_DOUBLE;
-   Z_DVAL_P(val) = *(double *) data;
+   ZVAL_DOUBLE(val, *(double *) data);
}
break;
 #ifdef SQL_INT64
case SQL_INT64:
-   Z_TYPE_P(val) = IS_STRING;
   

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-20 Thread Ard Biesheuvel
abies   Wed Aug 20 08:40:59 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Fix Win32 build
  
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.155 php-src/ext/interbase/interbase.c:1.156
--- php-src/ext/interbase/interbase.c:1.155 Wed Aug 20 08:40:05 2003
+++ php-src/ext/interbase/interbase.c   Wed Aug 20 08:40:59 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.155 2003/08/20 12:40:05 abies Exp $ */
+/* $Id: interbase.c,v 1.156 2003/08/20 12:40:59 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -491,7 +491,7 @@
 {
if (rsrc->ptr != NULL) {
IBDEBUG("Preparing to free query by dtor...");
-   _php_ibase_free_query((ibase_query *)rsrc->ptr);
+   _php_ibase_free_query((ibase_query *)rsrc->ptr TSRMLS_CC);
efree(rsrc->ptr);
}
 }
@@ -684,7 +684,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.155 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.156 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-20 Thread Ard Biesheuvel
abies   Wed Aug 20 08:40:05 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Moved some local vars to stack
  
  
  Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.154 php-src/ext/interbase/interbase.c:1.155
--- php-src/ext/interbase/interbase.c:1.154 Wed Aug 20 08:22:58 2003
+++ php-src/ext/interbase/interbase.c   Wed Aug 20 08:40:05 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.154 2003/08/20 12:22:58 abies Exp $ */
+/* $Id: interbase.c,v 1.155 2003/08/20 12:40:05 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -285,8 +285,8 @@
} else {
ISC_UINT64 res;
int n = sscanf(id, BLOB_ID_MASK, &res);
-   qd->gds_quad_high = (SLONG) (res >> 0x20);
-   qd->gds_quad_low = (ULONG) (res & 0x);
+   qd->gds_quad_high = (long) (res >> 0x20);
+   qd->gds_quad_low = (unsigned long) (res & 0x);
return n;
}
 }
@@ -461,29 +461,27 @@
 static void _php_ibase_free_query(ibase_query *ib_query TSRMLS_DC)
 {
IBDEBUG("Freeing query...");
-   if (ib_query) {
-   if (ib_query->in_sqlda) {
-   efree(ib_query->in_sqlda);
-   }
-   if (ib_query->out_sqlda) {
-   efree(ib_query->out_sqlda);
-   }
-   if (ib_query->stmt) {
-   IBDEBUG("Dropping statement handle (free_query)...");
-   if (isc_dsql_free_statement(IB_STATUS, &ib_query->stmt, 
DSQL_drop)) {
-   _php_ibase_error(TSRMLS_C);
-   }
-   }
-   if (ib_query->in_array) {
-   efree(ib_query->in_array);
-   }
-   if (ib_query->out_array) {
-   efree(ib_query->out_array);
-   }
-   if (ib_query->query) {
-   efree(ib_query->query);
+
+   if (ib_query->in_sqlda) {
+   efree(ib_query->in_sqlda);
+   }
+   if (ib_query->out_sqlda) {
+   efree(ib_query->out_sqlda);
+   }
+   if (ib_query->stmt) {
+   IBDEBUG("Dropping statement handle (free_query)...");
+   if (isc_dsql_free_statement(IB_STATUS, &ib_query->stmt, DSQL_drop)) {
+   _php_ibase_error(TSRMLS_C);
}
-   efree(ib_query);
+   }
+   if (ib_query->in_array) {
+   efree(ib_query->in_array);
+   }
+   if (ib_query->out_array) {
+   efree(ib_query->out_array);
+   }
+   if (ib_query->query) {
+   efree(ib_query->query);
}
 }
 /* }}} */
@@ -491,30 +489,10 @@
 /* {{{ php_ibase_free_query_rsrc() */
 static void php_ibase_free_query_rsrc(zend_rsrc_list_entry *rsrc TSRMLS_DC)
 {
-   ibase_query *ib_query = (ibase_query *)rsrc->ptr;
-
-   IBDEBUG("Freeing query by dtor...");
-   if (ib_query) {
-   if (ib_query->in_sqlda) {
-   efree(ib_query->in_sqlda);
-   }
-   if (ib_query->out_sqlda) {
-   efree(ib_query->out_sqlda);
-   }
-   if (ib_query->stmt) {
-   IBDEBUG("Dropping statement handle (free_query dtor)...");
-   isc_dsql_free_statement(IB_STATUS, &ib_query->stmt, DSQL_drop);
-   }
-   if (ib_query->in_array) {
-   efree(ib_query->in_array);
-   }
-   if (ib_query->out_array) {
-   efree(ib_query->out_array);
-   }
-   if (ib_query->query) {
-   efree(ib_query->query);
-   }
-   efree(ib_query);
+   if (rsrc->ptr != NULL) {
+   IBDEBUG("Preparing to free query by dtor...");
+   _php_ibase_free_query((ibase_query *)rsrc->ptr);
+   efree(rsrc->ptr);
}
 }
 /* }}} */
@@ -706,7 +684,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.154 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.155 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -1176,120 +1154,114 @@
 
 /* {{{ _php_ibase_alloc_query() */
 /* allocate and prepare query */
-static int _php_ibase_alloc_query(ibase_query **ib_queryp, ibase_db_link *link, 
ibase_trans *trans, char *query, unsigned short dialect, int trans_res_id TSRMLS_DC)
+static int _php_ibase_alloc_query(ibase_query *ib_query, ibase_db_link *link, 
ibase_trans *trans, char *query, unsigned short dialect, int trans_res_id TSRMLS_DC)
 {
-#define IB_QU

[PHP-CVS] cvs: php-src /ext/interbase interbase.c php_interbase.h

2003-08-20 Thread Ard Biesheuvel
abies   Wed Aug 20 08:22:59 2003 EDT

  Modified files:  
/php-src/ext/interbase  php_interbase.h interbase.c 
  Log:
  Nuke link handle from BLOB id
  # Now BLOB ids can survive disconnect/reconnect
  Added link argument to ibase_blob_{open|info|echo}()
  
  Index: php-src/ext/interbase/php_interbase.h
diff -u php-src/ext/interbase/php_interbase.h:1.53 
php-src/ext/interbase/php_interbase.h:1.54
--- php-src/ext/interbase/php_interbase.h:1.53  Sun Aug 17 20:14:53 2003
+++ php-src/ext/interbase/php_interbase.h   Wed Aug 20 08:22:58 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: php_interbase.h,v 1.53 2003/08/18 00:14:53 abies Exp $ */
+/* $Id: php_interbase.h,v 1.54 2003/08/20 12:22:58 abies Exp $ */
 
 #ifndef PHP_INTERBASE_H
 #define PHP_INTERBASE_H
@@ -28,14 +28,6 @@
 extern zend_module_entry ibase_module_entry;
 #define phpext_interbase_ptr &ibase_module_entry
 
-#ifndef ISC_INT64_FORMAT
-#ifdef PHP_WIN32
-#define ISC_INT64_FORMAT "I64"
-#else
-#define ISC_INT64_FORMAT "ll"
-#endif
-#endif
-
 PHP_MINIT_FUNCTION(ibase);
 PHP_RINIT_FUNCTION(ibase);
 PHP_MSHUTDOWN_FUNCTION(ibase);
@@ -97,6 +89,8 @@
 
 #define IBASE_MSGSIZE 256
 #define MAX_ERRMSG (IBASE_MSGSIZE*2)
+
+/* this value should never be > USHRT_MAX */
 #define IBASE_BLOB_SEG 4096
 
 ZEND_BEGIN_MODULE_GLOBALS(ibase)
@@ -114,7 +108,6 @@
char *cfg_timeformat;
char errmsg[MAX_ERRMSG];
long sql_code;
-   HashTable blob_table;
 ZEND_END_MODULE_GLOBALS(ibase)
 
 typedef struct {
@@ -143,11 +136,10 @@
 } ibase_array;
 
 typedef struct {
-   ibase_db_link *link;
isc_blob_handle bl_handle;
ISC_QUAD bl_qd;
unsigned short type;
-} ibase_blob_handle;
+} ibase_blob;
 
 typedef struct {
ibase_db_link *link;
@@ -185,11 +177,6 @@
zval *callback;
void **thread_ctx;
 } ibase_event;
-
-typedef struct _php_ibase_varchar {
-   short var_len;
-   char var_str[1];
-} IBASE_VCHAR;
 
 enum php_interbase_option {
PHP_IBASE_DEFAULT   = 0,
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.153 php-src/ext/interbase/interbase.c:1.154
--- php-src/ext/interbase/interbase.c:1.153 Sun Aug 17 20:14:53 2003
+++ php-src/ext/interbase/interbase.c   Wed Aug 20 08:22:58 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.153 2003/08/18 00:14:53 abies Exp $ */
+/* $Id: interbase.c,v 1.154 2003/08/20 12:22:58 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -51,8 +51,17 @@
 
 #define SAFE_STRING(s) ((s)?(s):"")
 
+#ifdef PHP_WIN32
+#define LL_MASK "I64"
+#else
+#define LL_MASK "ll"
+#endif
+
 #define BLOB_ID_LEN 18
-#define BLOB_ID_MASK "0x%08lx%08lx"
+#define BLOB_ID_MASK "0x%" LL_MASK "x"
+
+#define BLOB_INPUT 1
+#define BLOB_OUTPUT 2
 
 /* {{{ extension definition structures */
 function_entry ibase_functions[] = {
@@ -268,19 +277,33 @@
 } BIND_BUF;
 
 
-/* get blob handle from argument
- * note: blob already open when handle active
- */
-static int _php_ibase_get_blob_handle(zval **blob_arg, ibase_blob_handle **blob_ptr 
TSRMLS_DC)
+static inline int _php_ibase_string_to_quad(char const *id, ISC_QUAD *qd)
 {
-   int type;
-   convert_to_long_ex(blob_arg);
-   *blob_ptr = (ibase_blob_handle *) zend_list_find(Z_LVAL_PP(blob_arg), &type);
-   if (type != le_blob) {
-   _php_ibase_module_error("%d is not blob handle", Z_LVAL_PP(blob_arg));
-   return FAILURE;
+   /* shortcut for most common case */
+   if (sizeof(ISC_QUAD) == sizeof(ISC_UINT64)) {
+   return sscanf(id, BLOB_ID_MASK, (ISC_UINT64 *) qd);
+   } else {
+   ISC_UINT64 res;
+   int n = sscanf(id, BLOB_ID_MASK, &res);
+   qd->gds_quad_high = (SLONG) (res >> 0x20);
+   qd->gds_quad_low = (ULONG) (res & 0x);
+   return n;
}
-   return SUCCESS;
+}
+
+static inline char *_php_ibase_quad_to_string(ISC_QUAD const qd)
+{
+   char *result = (char *) emalloc(BLOB_ID_LEN+1);
+
+   /* shortcut for most common case */
+   if (sizeof(ISC_QUAD) == sizeof(ISC_UINT64)) {
+   sprintf(result, BLOB_ID_MASK, *(ISC_UINT64*) &qd);
+   } else {
+   ISC_UINT64 res = ((ISC_UINT64) qd.gds_quad_high << 0x20) | 
qd.gds_quad_low;
+   sprintf(result, BLOB_ID_MASK, res);
+   }
+   result[BLOB_ID_LEN] = '\0';
+   return result;
 }
 
 /* blob information struct */
@@ -499,7 +522,7 @@
 /* {{{ _php_ibase_free_blob()  */
 static void _php_ibase_free_blob(zend_rsrc_list_entry *rsrc TSRMLS_DC)
 {
-   ibase_blob_handle *ib_blob = (ibase_blob_handle *)rsrc->ptr;
+   ibase_blob *ib_blob = (ibase_blob *)rsrc->ptr;
 
if (ib_blob->bl_handle != NULL) { /* blob open*/
if (isc_cancel_blob(IB_STAT

[PHP-CVS] cvs: php-src /ext/interbase interbase.c php_interbase.h

2003-08-17 Thread Ard Biesheuvel
abies   Sun Aug 17 20:14:53 2003 EDT

  Modified files:  
/php-src/ext/interbase  php_interbase.h interbase.c 
  Log:
  Nuke bogus BLOB ids
  # User-space BLOB id no longer contains transaction handle, so BLOB ids
  # now remain valid throughout multiple transactions.
  # Oh, and they look better too :-)
  
  Index: php-src/ext/interbase/php_interbase.h
diff -u php-src/ext/interbase/php_interbase.h:1.52 
php-src/ext/interbase/php_interbase.h:1.53
--- php-src/ext/interbase/php_interbase.h:1.52  Sat Aug 16 11:31:06 2003
+++ php-src/ext/interbase/php_interbase.h   Sun Aug 17 20:14:53 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: php_interbase.h,v 1.52 2003/08/16 15:31:06 abies Exp $ */
+/* $Id: php_interbase.h,v 1.53 2003/08/18 00:14:53 abies Exp $ */
 
 #ifndef PHP_INTERBASE_H
 #define PHP_INTERBASE_H
@@ -114,6 +114,7 @@
char *cfg_timeformat;
char errmsg[MAX_ERRMSG];
long sql_code;
+   HashTable blob_table;
 ZEND_END_MODULE_GLOBALS(ibase)
 
 typedef struct {
@@ -142,10 +143,10 @@
 } ibase_array;
 
 typedef struct {
-   isc_tr_handle trans_handle; 
-   isc_db_handle link;
-   ISC_QUAD bl_qd;
+   ibase_db_link *link;
isc_blob_handle bl_handle;
+   ISC_QUAD bl_qd;
+   unsigned short type;
 } ibase_blob_handle;
 
 typedef struct {
@@ -164,8 +165,8 @@
 } ibase_query;
 
 typedef struct {
-   isc_db_handle link; /* db link for this result */
-   isc_tr_handle trans;
+   ibase_db_link *link;
+   ibase_trans *trans;
isc_stmt_handle stmt;
int drop_stmt;
XSQLDA *out_sqlda;
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.152 php-src/ext/interbase/interbase.c:1.153
--- php-src/ext/interbase/interbase.c:1.152 Sun Aug 17 12:30:15 2003
+++ php-src/ext/interbase/interbase.c   Sun Aug 17 20:14:53 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.152 2003/08/17 16:30:15 abies Exp $ */
+/* $Id: interbase.c,v 1.153 2003/08/18 00:14:53 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -51,6 +51,9 @@
 
 #define SAFE_STRING(s) ((s)?(s):"")
 
+#define BLOB_ID_LEN 18
+#define BLOB_ID_MASK "0x%08lx%08lx"
+
 /* {{{ extension definition structures */
 function_entry ibase_functions[] = {
PHP_FE(ibase_connect, NULL)
@@ -264,24 +267,6 @@
short sqlind;
 } BIND_BUF;
 
-/* get blob identifier from argument
- * on empty unset argument ib_blob set to NULL
- */
-static int _php_ibase_get_blob_id(zval **blob_arg, ibase_blob_handle **ib_blob)
-{
-   if (Z_TYPE_PP(blob_arg) == IS_STRING && Z_STRLEN_PP(blob_arg) == 0) {
-   *ib_blob = NULL;
-   } else if (Z_TYPE_PP(blob_arg) != IS_STRING
-|| Z_STRLEN_PP(blob_arg) != sizeof(ibase_blob_handle)
-|| ((ibase_blob_handle *)(Z_STRVAL_PP(blob_arg)))->bl_handle 
!= 0) {
-
-   _php_ibase_module_error("Invalid blob id");
-   return FAILURE;
-   } else {
-   *ib_blob = (ibase_blob_handle *)Z_STRVAL_PP(blob_arg);
-   }
-   return SUCCESS;
-}
 
 /* get blob handle from argument
  * note: blob already open when handle active
@@ -582,7 +567,6 @@
}
_php_ibase_event_free(event->event_buffer,event->result_buffer);
 }
-   
 /* }}} */
 
 /* {{{ startup, shutdown and info functions */
@@ -664,6 +648,8 @@
 
RESET_ERRMSG;
 
+   zend_hash_init(&IBG(blob_table), 0, NULL, NULL, 0);
+
return SUCCESS;
 }
 
@@ -690,6 +676,8 @@
}
IBG(timeformat) = NULL;
 
+   zend_hash_destroy(&IBG(blob_table));
+   
return SUCCESS;
 } 
  
@@ -699,7 +687,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.152 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.153 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -864,15 +852,15 @@
int open_new_connection = 1;

if (zend_hash_find(&EG(persistent_list), hashed_details, 
hashed_details_length + 1, (void **) &le) != FAILURE) {
-   char tmp_1[] = {isc_info_base_level, isc_info_end};
-   char tmp_2[8]; /* Enough? Hope so... */ 
+   static char info[] = {isc_info_base_level, isc_info_end};
+   char result[8]; /* Enough? Hope so... */ 
 
if (Z_TYPE_P(le) != le_plink) {
RETURN_FALSE;
}
/* Check if connection has timed out */
ib_link = (ibase_db_link *) le->ptr;
-   if (!isc_database_info(IB_STATUS, &ib

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-17 Thread Ard Biesheuvel
abies   Sun Aug 17 12:30:15 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Simplify previous fix
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.151 php-src/ext/interbase/interbase.c:1.152
--- php-src/ext/interbase/interbase.c:1.151 Sun Aug 17 12:13:52 2003
+++ php-src/ext/interbase/interbase.c   Sun Aug 17 12:30:15 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.151 2003/08/17 16:13:52 abies Exp $ */
+/* $Id: interbase.c,v 1.152 2003/08/17 16:30:15 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -262,7 +262,6 @@
 #endif
} val;
short sqlind;
-   void *allocated;
 } BIND_BUF;
 
 /* get blob identifier from argument
@@ -700,7 +699,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.151 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.152 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -1320,7 +1319,6 @@
for (i = 0; i < sqlda->sqld; var++, i++) { /* bound vars */

buf[i].sqlind = 0;
-   buf[i].allocated = NULL;
var->sqlind = &buf[i].sqlind;
b_var = b_vars[i];

@@ -1486,8 +1484,8 @@
_php_ibase_error(TSRMLS_C);
return FAILURE;
}
-   buf[i].allocated = var->sqldata = (void 
ISC_FAR *) emalloc(sizeof(ISC_QUAD));
-   *(ISC_QUAD ISC_FAR *) var->sqldata = 
ib_blob.bl_qd;
+   buf[i].val.qval = ib_blob.bl_qd;
+   var->sqldata = (void ISC_FAR *) 
&buf[i].val.qval;

} else {
var->sqldata = (void ISC_FAR *) 
&((ibase_blob_handle *) Z_STRVAL_P(b_var))->bl_qd;
@@ -1727,17 +1725,8 @@
if (in_sqlda) {
efree(in_sqlda);
}
-   if (bind_buf) {
-   int i;
-
-   /* free memory allocated in binding stage */
-   for (i = 0; i < ib_query->in_sqlda->sqld; ++i) {
-   if (bind_buf[i].allocated != NULL) {
-   efree(bind_buf[i].allocated);
-   }
-   }
+   if (bind_buf)
efree(bind_buf);
-   }
 
if (rv == FAILURE) {
if (IB_RESULT) {



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-17 Thread Ard Biesheuvel
abies   Sun Aug 17 12:13:52 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Fixed leak in _php_ibase_bind()
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.150 php-src/ext/interbase/interbase.c:1.151
--- php-src/ext/interbase/interbase.c:1.150 Sun Aug 17 09:16:54 2003
+++ php-src/ext/interbase/interbase.c   Sun Aug 17 12:13:52 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.150 2003/08/17 13:16:54 abies Exp $ */
+/* $Id: interbase.c,v 1.151 2003/08/17 16:13:52 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -262,6 +262,7 @@
 #endif
} val;
short sqlind;
+   void *allocated;
 } BIND_BUF;
 
 /* get blob identifier from argument
@@ -699,7 +700,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.150 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.151 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -1319,6 +1320,7 @@
for (i = 0; i < sqlda->sqld; var++, i++) { /* bound vars */

buf[i].sqlind = 0;
+   buf[i].allocated = NULL;
var->sqlind = &buf[i].sqlind;
b_var = b_vars[i];

@@ -1462,40 +1464,35 @@
 #endif
break;
case SQL_BLOB:
-   {
-   ibase_blob_handle *ib_blob_id;
+   if (Z_TYPE_P(b_var) != IS_STRING || Z_STRLEN_P(b_var) 
!= sizeof(ibase_blob_handle) || 
+  ((ibase_blob_handle 
*)(Z_STRVAL_P(b_var)))->bl_handle != 0) {
 
-   if (Z_TYPE_P(b_var) != IS_STRING || 
Z_STRLEN_P(b_var) != sizeof(ibase_blob_handle) || 
-  ((ibase_blob_handle 
*)(Z_STRVAL_P(b_var)))->bl_handle != 0) {
-   ibase_blob_handle *ib_blob;
-
-   ib_blob = (ibase_blob_handle *) 
emalloc(sizeof(ibase_blob_handle));
-   ib_blob->trans_handle = 
ib_query->trans;
-   ib_blob->link = ib_query->link;
-   ib_blob->bl_handle = NULL;
-   if (isc_create_blob(IB_STATUS, 
&ib_blob->link, &ib_blob->trans_handle, &ib_blob->bl_handle, &ib_blob->bl_qd)) {
-   efree(ib_blob);
-   _php_ibase_error(TSRMLS_C);
-   return FAILURE;
-   }
+   ibase_blob_handle ib_blob;
 
-   if (_php_ibase_blob_add(&b_var, 
ib_blob TSRMLS_CC) != SUCCESS) {
-   efree(ib_blob);
-   return FAILURE;
-   }
-   
-   if (isc_close_blob(IB_STATUS, 
&ib_blob->bl_handle)) {
-   _php_ibase_error(TSRMLS_C);
-   efree(ib_blob);
-   return FAILURE;
-   }
-   ib_blob_id = ib_blob;
-   } else {
-   ib_blob_id = (ibase_blob_handle *) 
Z_STRVAL_P(b_var);
+   ib_blob.trans_handle = ib_query->trans->handle;
+   ib_blob.link = ib_query->link->handle;
+   ib_blob.bl_handle = NULL;
+
+   if (isc_create_blob(IB_STATUS, &ib_blob.link, 
&ib_blob.trans_handle, &ib_blob.bl_handle, &ib_blob.bl_qd)) {
+   _php_ibase_error(TSRMLS_C);
+   return FAILURE;
+   }
+
+   if (_php_ibase_blob_add(&b_var, &ib_blob 
TSRMLS_CC) != SUCCESS) {
+   return FAILURE;
}
-   var->sqldata = (void ISC_FAR *) 
&ib_blob_id->bl_qd;
+

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-17 Thread Ard Biesheuvel
abies   Sun Aug 17 09:16:55 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Fix possible leak in _php_ibase_fetch_hash()
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.149 php-src/ext/interbase/interbase.c:1.150
--- php-src/ext/interbase/interbase.c:1.149 Sun Aug 17 08:31:55 2003
+++ php-src/ext/interbase/interbase.c   Sun Aug 17 09:16:54 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.149 2003/08/17 12:31:55 abies Exp $ */
+/* $Id: interbase.c,v 1.150 2003/08/17 13:16:54 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -699,7 +699,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.149 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.150 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -2606,8 +2606,8 @@
var = ib_result->out_sqlda->sqlvar;
for (i = 0; i < ib_result->out_sqlda->sqld; i++, var++) {
if (((var->sqltype & 1) == 0) || *var->sqlind != -1) {
-   zval *tmp;
-   tmp = emalloc(sizeof(zval));
+   zval tmp;
+
switch (var->sqltype & ~1) {
case SQL_VARYING:
case SQL_TEXT:
@@ -2625,7 +2625,7 @@
case SQL_TYPE_DATE:
case SQL_TYPE_TIME:
 #endif
-   _php_ibase_var_zval(tmp, var->sqldata, 
var->sqltype, var->sqllen, var->sqlscale, flag TSRMLS_CC);
+   _php_ibase_var_zval(&tmp, var->sqldata, 
var->sqltype, var->sqllen, var->sqlscale, flag TSRMLS_CC);
break;
case SQL_BLOB:
if (flag & PHP_IBASE_FETCH_BLOBS) { /* fetch 
blob contents into hash */
@@ -2665,25 +2665,25 @@
RETURN_FALSE;
}

-   if (_php_ibase_blob_get(tmp, 
&blob_handle, max_len TSRMLS_CC) != SUCCESS) {
+   if (_php_ibase_blob_get(&tmp, 
&blob_handle, max_len TSRMLS_CC) != SUCCESS) {
RETURN_FALSE;
}

if (isc_close_blob(IB_STATUS, 
&blob_handle.bl_handle)) {
+   zval_dtor(&tmp);
_php_ibase_error(TSRMLS_C);
+   RETURN_FALSE;
}
 
} else { /* blob id only */
-   ISC_QUAD *bl_qd = (ISC_QUAD ISC_FAR *) 
var->sqldata;
-   ibase_blob_handle *ib_blob_id;
-   
-   ib_blob_id = (ibase_blob_handle *) 
ecalloc(1, sizeof(ibase_blob_handle) + 1);
+
+   ibase_blob_handle *ib_blob_id = 
(ibase_blob_handle *) ecalloc(1, sizeof(ibase_blob_handle) + 1);

ib_blob_id->link = ib_result->link;
ib_blob_id->trans_handle = 
ib_result->trans;
-   ib_blob_id->bl_qd = *bl_qd;
+   ib_blob_id->bl_qd = *(ISC_QUAD ISC_FAR 
*) var->sqldata;

-   ZVAL_STRINGL(tmp, (char *) ib_blob_id, 
sizeof(ibase_blob_handle),0);
+   ZVAL_STRINGL(&tmp, (char *) 
ib_blob_id, sizeof(ibase_blob_handle),0);
}
break;
case SQL_ARRAY: {
@@ -2703,7 +2703,7 @@
}

tmp_ptr = ar_data; /* avoid changes in 
_arr_zval */
-   if (_php_ibase_arr_zval(tmp, &tmp_ptr, 
ib_array, 0, flag TSRMLS_CC) == FAILURE) {
+   if (_

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-17 Thread Ard Biesheuvel
abies   Sun Aug 17 08:31:55 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Apply fix for ibase_blob_get() to ibase_fetch_*()
  Apply fix for ibase_blob_add() to ibase_query()/ibase_execute()
  
  
  Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.148 php-src/ext/interbase/interbase.c:1.149
--- php-src/ext/interbase/interbase.c:1.148 Sat Aug 16 15:48:32 2003
+++ php-src/ext/interbase/interbase.c   Sun Aug 17 08:31:55 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.148 2003/08/16 19:48:32 abies Exp $ */
+/* $Id: interbase.c,v 1.149 2003/08/17 12:31:55 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -699,7 +699,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.148 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.149 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -1285,6 +1285,28 @@
 }
 /* }}} */
 
+/* ((( _php_ibase_blob_add */
+static int _php_ibase_blob_add(zval **string_arg, ibase_blob_handle *ib_blob 
TSRMLS_DC)
+{
+   unsigned long put_cnt = 0, rem_cnt;
+   unsigned short chunk_size;
+
+   convert_to_string_ex(string_arg);
+
+   for (rem_cnt = Z_STRLEN_PP(string_arg); rem_cnt > 0; rem_cnt -= chunk_size)  {
+   
+   chunk_size = rem_cnt > USHRT_MAX ? USHRT_MAX : (unsigned short)rem_cnt;
+
+   if (isc_put_segment(IB_STATUS, &ib_blob->bl_handle, chunk_size, 
&Z_STRVAL_PP(string_arg)[put_cnt] )) {
+   _php_ibase_error(TSRMLS_C);
+   return FAILURE;
+   }
+   put_cnt += chunk_size;
+   }
+   return SUCCESS;
+}  
+/* }}} */
+
 /* {{{ _php_ibase_bind()
Bind parameter placeholders in a previously prepared query */
 static int _php_ibase_bind(XSQLDA *sqlda, zval **b_vars, BIND_BUF *buf, ibase_query 
*ib_query TSRMLS_DC)
@@ -1442,6 +1464,7 @@
case SQL_BLOB:
{
ibase_blob_handle *ib_blob_id;
+
if (Z_TYPE_P(b_var) != IS_STRING || 
Z_STRLEN_P(b_var) != sizeof(ibase_blob_handle) || 
   ((ibase_blob_handle 
*)(Z_STRVAL_P(b_var)))->bl_handle != 0) {
ibase_blob_handle *ib_blob;
@@ -1455,13 +1478,15 @@
_php_ibase_error(TSRMLS_C);
return FAILURE;
}
-   convert_to_string(b_var);
-   if (isc_put_segment(IB_STATUS, 
&ib_blob->bl_handle, (unsigned short) Z_STRLEN_P(b_var), Z_STRVAL_P(b_var))) {
-   _php_ibase_error(TSRMLS_C);
+
+   if (_php_ibase_blob_add(&b_var, 
ib_blob TSRMLS_CC) != SUCCESS) {
+   efree(ib_blob);
return FAILURE;
}
+   
if (isc_close_blob(IB_STATUS, 
&ib_blob->bl_handle)) {
_php_ibase_error(TSRMLS_C);
+   efree(ib_blob);
return FAILURE;
}
ib_blob_id = ib_blob;
@@ -1612,8 +1637,7 @@

default:

-   Z_BVAL_P(return_value) = 1;
-   Z_TYPE_P(return_value) = IS_BOOL;
+   RETVAL_BOOL(1);
}
 
/* allocate sqlda and output buffers */
@@ -1668,6 +1692,8 @@

switch (ib_query->statement_type) {
 
+   unsigned long affected_rows;
+
case isc_info_sql_stmt_insert:
case isc_info_sql_stmt_update:
case isc_info_sql_stmt_delete:
@@ -1677,6 +1703,8 @@
_php_ibase_error(TSRMLS_C);
goto _php_ibase_exec_error;
}
+
+   affected_rows = 0;

if (result[0] == isc_info_sql_records) {
unsigned i = 3, result_size = 
isc_vax_integer(&result[1],2);
@@ -1684,11 +1712,15 

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-16 Thread Ard Biesheuvel
abies   Sat Aug 16 15:48:32 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Always fill entire buffer in ibase_blob_get()
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.147 php-src/ext/interbase/interbase.c:1.148
--- php-src/ext/interbase/interbase.c:1.147 Sat Aug 16 12:09:24 2003
+++ php-src/ext/interbase/interbase.c   Sat Aug 16 15:48:32 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.147 2003/08/16 16:09:24 abies Exp $ */
+/* $Id: interbase.c,v 1.148 2003/08/16 19:48:32 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -699,7 +699,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.147 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.148 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -3364,7 +3364,7 @@
 
for (rem_cnt = Z_STRLEN_PP(string_arg); rem_cnt > 0; rem_cnt -= chunk_size)  {

-   chunk_size = rem_cnt > USHRT_MAX ? USHRT_MAX : rem_cnt;
+   chunk_size = rem_cnt > USHRT_MAX ? USHRT_MAX : (unsigned short)rem_cnt;
 
if (isc_put_segment(IB_STATUS, &ib_blob->bl_handle, chunk_size, 
&Z_STRVAL_PP(string_arg)[put_cnt] )) {
_php_ibase_error(TSRMLS_C);
@@ -3381,9 +3381,8 @@
 PHP_FUNCTION(ibase_blob_get)
 {
zval **blob_arg, **len_arg;
-   int stat;
+   ISC_STATUS stat;
char *bl_data;
-   unsigned short seg_len;
unsigned long max_len, cur_len;
ibase_blob_handle *ib_blob;
 
@@ -3404,20 +3403,20 @@

bl_data = emalloc(max_len + 1);
 
-   for (cur_len = stat = 0; stat == 0;) {
-   unsigned short next_chunk_size = (max_len-cur_len) > USHRT_MAX 
? USHRT_MAX : (max_len-cur_len);
+   for (cur_len = stat = 0; stat == 0 || stat == isc_segment;  ) {
+   unsigned short seg_len, chunk_size = (max_len-cur_len) > 
USHRT_MAX ? USHRT_MAX : (unsigned short)(max_len-cur_len);
+
+   stat = isc_get_segment(IB_STATUS, &ib_blob->bl_handle, 
&seg_len, chunk_size, &bl_data[cur_len]); 
 
-   stat = isc_get_segment(IB_STATUS, &ib_blob->bl_handle, 
&seg_len, next_chunk_size, &bl_data[cur_len]);
cur_len += seg_len;
-   if (cur_len > max_len) { /* never!*/
-   efree(bl_data);
-   _php_ibase_module_error("PHP module internal error");
-   RETURN_FALSE;
+   
+   if (cur_len == max_len) {
+   break;
}
}
 
bl_data[cur_len] = '\0';
-   if (IB_STATUS[0] && (IB_STATUS[1] != isc_segstr_eof && IB_STATUS[1] != 
isc_segment)) {
+   if (IB_STATUS[0] == 1 && (stat != 0 && stat != isc_segstr_eof && stat 
!= isc_segment)) {
efree(bl_data);
_php_ibase_error(TSRMLS_C);
RETURN_FALSE;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-16 Thread Jani Taskinen

Do NOT mix fixes with code cleanup. Do separate commits.
And second, merge any fixes to PHP_4_3 branch. If you don't 
merge for some reason, do NOT close bugs reported for PHP 4
without saying the fix is only going to be in PHP 5..

--Jani



On Sat, 16 Aug 2003, Ard Biesheuvel wrote:

>abies  Sat Aug 16 11:30:25 2003 EDT
>
>  Modified files:  
>/php-src/ext/interbase interbase.c 
>  Log:
>  Fixed bug #24224
>  Some general cleaning up
>  Some preliminary changes for extensions to array functions
>  
>  


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-16 Thread Ard Biesheuvel
abies   Sat Aug 16 12:09:24 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Fixed bug #18744
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.146 php-src/ext/interbase/interbase.c:1.147
--- php-src/ext/interbase/interbase.c:1.146 Sat Aug 16 11:30:22 2003
+++ php-src/ext/interbase/interbase.c   Sat Aug 16 12:09:24 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.146 2003/08/16 15:30:22 abies Exp $ */
+/* $Id: interbase.c,v 1.147 2003/08/16 16:09:24 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -699,7 +699,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.146 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.147 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -3347,6 +3347,8 @@
 {
zval **blob_arg, **string_arg;
ibase_blob_handle *ib_blob;
+   unsigned long put_cnt = 0, rem_cnt;
+   unsigned short chunk_size;
 
RESET_ERRMSG;
 
@@ -3360,9 +3362,15 @@

convert_to_string_ex(string_arg);
 
-   if (isc_put_segment(IB_STATUS, &ib_blob->bl_handle, (unsigned short) 
Z_STRLEN_PP(string_arg), Z_STRVAL_PP(string_arg))) {
-   _php_ibase_error(TSRMLS_C);
-   RETURN_FALSE;
+   for (rem_cnt = Z_STRLEN_PP(string_arg); rem_cnt > 0; rem_cnt -= chunk_size)  {
+   
+   chunk_size = rem_cnt > USHRT_MAX ? USHRT_MAX : rem_cnt;
+
+   if (isc_put_segment(IB_STATUS, &ib_blob->bl_handle, chunk_size, 
&Z_STRVAL_PP(string_arg)[put_cnt] )) {
+   _php_ibase_error(TSRMLS_C);
+   RETURN_FALSE;
+   }
+   put_cnt += chunk_size;
}
RETURN_TRUE;
 }



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-16 Thread Ard Biesheuvel
abies   Sat Aug 16 11:30:25 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Fixed bug #24224
  Some general cleaning up
  Some preliminary changes for extensions to array functions
  
  Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.145 php-src/ext/interbase/interbase.c:1.146
--- php-src/ext/interbase/interbase.c:1.145 Fri Aug 15 21:58:29 2003
+++ php-src/ext/interbase/interbase.c   Sat Aug 16 11:30:22 2003
@@ -18,64 +18,28 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.145 2003/08/16 01:58:29 abies Exp $ */
-
-/*
-   Changes:
-   2003-08-05: Ard Biesheuvel <[EMAIL PROTECTED]>
-   - Significant changes to layout of internal data structures
- in order to accomodate and carry out the following changes:
- * Removal of arbitrary 'transactions-per-link' limit,
- * Transactions over multiple databases.
-   - Leak fixes in ibase_query() and ibase_execute() by replacing
- emalloc() with do_alloca()
-   - Changes to ibase_query() to enable the use of CREATE 
DATABASE ...
-   - Added ibase_drop_db()
-   - Added ibase_commit_ret() and ibase_rollback_ret()
-   - Added ibase_name_result()
-   2001-05-31: Jeremy Bettis <[EMAIL PROTECTED]>
-   - If a blob handle was expected and something else was
- received create a blob and add the value to it.
-   - If the incoming argument to a bind parameter is NULL
- then store a NULL in the database.
-   - More verbose date errors.
-   1999-09-21: Ivo Panacek <[EMAIL PROTECTED]>
-   - added COMPILE_DL section
-   - more verbose php_info_ibase function
- mostly stolen from pgsql.c for now
-   1999-10-05: Ivo Panacek <[EMAIL PROTECTED]>
-   - safe rinit/rfinish: check for NULL so
- rfinish could be called repeatedly
- emalloc & co. replaced with malloc & co.
-*/
+/* $Id: interbase.c,v 1.146 2003/08/16 15:30:22 abies Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include "php.h"
+
+#if HAVE_IBASE
+
 #include "php_ini.h"
 #include "ext/standard/php_standard.h"
-#include "php_globals.h"
 #include "php_interbase.h"
 
-#if HAVE_IBASE
-#include 
+#include 
 
 #ifndef SQLDA_CURRENT_VERSION
 #define SQLDA_CURRENT_VERSION SQLDA_VERSION1
 #endif
 
-#include 
-#include "ext/standard/fsock.h"
-#include "ext/standard/info.h"
-
-#ifdef SQL_INT64
-#include 
-#endif
-
 #ifndef SQL_DIALECT_CURRENT
-#define SQL_DIALECT_CURRENT 1
+#define SQL_DIALECT_CURRENT SQL_DIALECT_V5
 #endif
 
 #ifdef ZEND_DEBUG
@@ -239,7 +203,9 @@
/* vsnprintf NUL terminates the buf and writes at most n-1 chars+NUL */
vsnprintf(IBG(errmsg), MAX_ERRMSG, msg, ap);
va_end(ap);
-   
+
+   IBG(sql_code) = -999; /* no SQL error */
+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", IBG(errmsg));
 }
 /* }}} */
@@ -655,7 +621,9 @@
le_event = zend_register_list_destructors_ex(_php_ibase_free_event, NULL, 
"interbase event", module_number);
 
REGISTER_LONG_CONSTANT("IBASE_DEFAULT", PHP_IBASE_DEFAULT, CONST_PERSISTENT);
-   REGISTER_LONG_CONSTANT("IBASE_TEXT", PHP_IBASE_TEXT, CONST_PERSISTENT);
+   REGISTER_LONG_CONSTANT("IBASE_TEXT", PHP_IBASE_FETCH_BLOBS, CONST_PERSISTENT); 
/* deprecated, for BC only */
+   REGISTER_LONG_CONSTANT("IBASE_FETCH_BLOBS", PHP_IBASE_FETCH_BLOBS, 
CONST_PERSISTENT);
+   REGISTER_LONG_CONSTANT("IBASE_FETCH_ARRAYS", PHP_IBASE_FETCH_ARRAYS, 
CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IBASE_UNIXTIME", PHP_IBASE_UNIXTIME, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IBASE_TIMESTAMP", PHP_IBASE_TIMESTAMP, 
CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IBASE_DATE", PHP_IBASE_DATE, CONST_PERSISTENT);
@@ -731,7 +699,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.145 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.146 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -1274,11 +1242,11 @@
}

/* allocate arrays... */
-   if (_php_ibase_alloc_array(&IB_QUERY->in_array, &IB_QUERY->in_array_cnt, 
IB_QUERY->in_sqlda, link, trans TSRMLS_CC) == FAILURE) {
+   if (_php_ibase_alloc_array(&IB_QUERY->in_array, &IB_QUERY->in_array_cnt, 
IB_QUERY->in_sqlda, link->handle, trans->handle TSRMLS_CC) == FAILURE) {
g

[PHP-CVS] cvs: php-src /ext/interbase interbase.c php_interbase.h

2003-08-15 Thread Ard Biesheuvel
abies   Fri Aug 15 21:58:29 2003 EDT

  Modified files:  
/php-src/ext/interbase  php_interbase.h interbase.c 
  Log:
  Removed ibase_num_rows()
  Converted some MACRO-isms
  
  
Index: php-src/ext/interbase/php_interbase.h
diff -u php-src/ext/interbase/php_interbase.h:1.50 
php-src/ext/interbase/php_interbase.h:1.51
--- php-src/ext/interbase/php_interbase.h:1.50  Fri Aug 15 12:13:51 2003
+++ php-src/ext/interbase/php_interbase.h   Fri Aug 15 21:58:29 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: php_interbase.h,v 1.50 2003/08/15 16:13:51 abies Exp $ */
+/* $Id: php_interbase.h,v 1.51 2003/08/16 01:58:29 abies Exp $ */
 
 #ifndef PHP_INTERBASE_H
 #define PHP_INTERBASE_H
@@ -63,7 +63,9 @@
 
 PHP_FUNCTION(ibase_num_fields);
 PHP_FUNCTION(ibase_num_params);
+#if abies_0
 PHP_FUNCTION(ibase_num_rows);
+#endif
 PHP_FUNCTION(ibase_affected_rows);
 PHP_FUNCTION(ibase_field_info);
 PHP_FUNCTION(ibase_param_info);
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.144 php-src/ext/interbase/interbase.c:1.145
--- php-src/ext/interbase/interbase.c:1.144 Fri Aug 15 20:58:24 2003
+++ php-src/ext/interbase/interbase.c   Fri Aug 15 21:58:29 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.144 2003/08/16 00:58:24 abies Exp $ */
+/* $Id: interbase.c,v 1.145 2003/08/16 01:58:29 abies Exp $ */
 
 /*
Changes:
@@ -108,7 +108,9 @@
 
PHP_FE(ibase_num_fields, NULL)
PHP_FE(ibase_num_params, NULL)
+#if abies_0
PHP_FE(ibase_num_rows, NULL)
+#endif
PHP_FE(ibase_affected_rows, NULL)
PHP_FE(ibase_field_info, NULL)
PHP_FE(ibase_param_info, NULL)
@@ -299,36 +301,38 @@
 /* get blob identifier from argument
  * on empty unset argument ib_blob set to NULL
  */
-#define GET_BLOB_ID_ARG(blob_arg, ib_blob)\
-{\
-   if (Z_TYPE_P(blob_arg) == IS_STRING && Z_STRLEN_P(blob_arg) == 0) {\
-   ib_blob = NULL;\
-   } else if (Z_TYPE_P(blob_arg) != IS_STRING\
-|| Z_STRLEN_P(blob_arg) != sizeof(ibase_blob_handle)\
-|| ((ibase_blob_handle *)(Z_STRVAL_P(blob_arg)))->bl_handle 
!= 0) {\
-   _php_ibase_module_error("Invalid blob id");\
-   RETURN_FALSE;\
-   } else {\
-   ib_blob = (ibase_blob_handle *)Z_STRVAL_P(blob_arg);\
-   }\
+static int _php_ibase_get_blob_id(zval **blob_arg, ibase_blob_handle **ib_blob)
+{
+   if (Z_TYPE_PP(blob_arg) == IS_STRING && Z_STRLEN_PP(blob_arg) == 0) {
+   *ib_blob = NULL;
+   } else if (Z_TYPE_PP(blob_arg) != IS_STRING
+|| Z_STRLEN_PP(blob_arg) != sizeof(ibase_blob_handle)
+|| ((ibase_blob_handle *)(Z_STRVAL_PP(blob_arg)))->bl_handle 
!= 0) {
+
+   _php_ibase_module_error("Invalid blob id");
+   return FAILURE;
+   } else {
+   *ib_blob = (ibase_blob_handle *)Z_STRVAL_PP(blob_arg);
+   }
+   return SUCCESS;
 }
 
 /* get blob handle from argument
  * note: blob already open when handle active
  */
-#define GET_BLOB_HANDLE_ARG(blob_arg, blob_ptr) \
-{ \
-   int type; \
-   convert_to_long_ex(blob_arg); \
-   blob_ptr = (ibase_blob_handle *) zend_list_find(Z_LVAL_PP(blob_arg), &type); \
-   if (type!=le_blob) { \
-   _php_ibase_module_error("%d is not blob handle", Z_LVAL_PP(blob_arg)); 
\
-   RETURN_FALSE; \
-   } \
+static int _php_ibase_get_blob_handle(zval **blob_arg, ibase_blob_handle **blob_ptr 
TSRMLS_DC)
+{
+   int type;
+   convert_to_long_ex(blob_arg);
+   *blob_ptr = (ibase_blob_handle *) zend_list_find(Z_LVAL_PP(blob_arg), &type);
+   if (type != le_blob) {
+   _php_ibase_module_error("%d is not blob handle", Z_LVAL_PP(blob_arg));
+   return FAILURE;
+   }
+   return SUCCESS;
 }
 
-/* blob information struct
- */
+/* blob information struct */
 typedef struct {
ISC_LONG  max_segment;  /* Length of longest segment */
ISC_LONG  num_segments; /* Total number of segments */
@@ -727,7 +731,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.144 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.145 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -2249,6 +2253,7 @@
 /* }}} */
 
 /* {{{ ibase_num_rows( resource result_identifier ) */
+#if abies_0
 PHP_FUNCTION(ibase_num_rows) 
 {
/**
@@ -2305,6 +2310,7 @@
}
}   
 }
+#endif
 /* }}} */
 
 /* {{{ _php_ibase_var_zval() */
@@ -3330,9 +3336,13 @@
 
ib_blob = (ibase_blob_handle *) emalloc(

Re: [PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-15 Thread Jani Taskinen

Why not leave it out then? It's new, it's not (yet) in any release, etc.
If you leave it in, people WILL try to use it and as they DO NOT read
sources in most cases, they will submit bug reports about the function
not working as they expect. (yes, even if it's not documented..)

--Jani


On Sat, 16 Aug 2003, Ard Biesheuvel wrote:

>abies  Fri Aug 15 20:58:24 2003 EDT
>
>  Modified files:  
>/php-src/ext/interbase interbase.c 
>  Log:
>  Added comment about ibase_num_rows()
>  
>Index: php-src/ext/interbase/interbase.c
>diff -u php-src/ext/interbase/interbase.c:1.143 
>php-src/ext/interbase/interbase.c:1.144
>--- php-src/ext/interbase/interbase.c:1.143Fri Aug 15 12:13:51 2003
>+++ php-src/ext/interbase/interbase.c  Fri Aug 15 20:58:24 2003
>@@ -18,7 +18,7 @@
>+--+
>  */
> 
>-/* $Id: interbase.c,v 1.143 2003/08/15 16:13:51 abies Exp $ */
>+/* $Id: interbase.c,v 1.144 2003/08/16 00:58:24 abies Exp $ */
> 
> /*
>   Changes:
>@@ -727,7 +727,7 @@
> 
>   php_info_print_table_start();
>   php_info_print_table_row(2, "Interbase Support", "enabled");
>-  php_info_print_table_row(2, "Revision", "$Revision: 1.143 $");
>+  php_info_print_table_row(2, "Revision", "$Revision: 1.144 $");
> #ifdef COMPILE_DL_INTERBASE
>   php_info_print_table_row(2, "Dynamic Module", "Yes");
> #endif
>@@ -2248,20 +2248,30 @@
> }
> /* }}} */
> 
>-/* {{{ proto ibase_num_rows( resource result_identifier )
>-   Returns the number of rows in a result */
>+/* {{{ ibase_num_rows( resource result_identifier ) */
> PHP_FUNCTION(ibase_num_rows) 
> {
>   /**
>-   * This function relies on the InterBase API function isc_dsql_sql_info()
>-   * which has a couple of limitations (which I hope will be fixed in
>-   * future releases of Firebird):
>-   * - row count is always zero before the first fetch;
>-   * - row count for SELECT ... FOR UPDATE is broken -> never returns a
>-   *   higher number than the number of records fetched so far;
>-   * - row count for other statements is merely a lower bound on the number
>-   *   of records => calling ibase_num_rows() again after a couple of fetches
>-   *   will most likely return a new (higher) figure for large result sets.
>+   * PLEASE READ THIS FIRST before adding this function to the main PHP
>+   * documentation:
>+   * 
>+   * As this function relies on the InterBase API function isc_dsql_sql_info()
>+   * which has a couple of limitations (which I hope will be fixed in future 
>+   * releases of Firebird), this function is fairly useless. I'm leaving it
>+   * in place for people who can live with the limitations, which I only 
>+   * found out about after I had implemented it anyway.
>+   *
>+   * Currently, there's no way to determine how many rows can be fetched from
>+   * a cursor. The only number that _can_ be determined is the number of rows
>+   * that have already been pre-fetched by the client library. 
>+   * This implies the following:
>+   * - num_rows() always returns zero before the first fetch;
>+   * - num_rows() for SELECT ... FOR UPDATE is broken -> never returns a
>+   *   higher number than the number of records fetched so far (no pre-fetch);
>+   * - the result of num_rows() for other statements is merely a lower bound 
>+   * on the number of records => calling ibase_num_rows() again after a couple
>+   * of fetches will most likely return a new (higher) figure for large result 
>+   * sets.
>*
>* 12-aug-2003 Ard Biesheuvel
>*/
>@@ -4088,7 +4098,7 @@
>   zend_list_addref(Z_LVAL_P(return_value));
> }
> 
>-/* {{{ proto bool ibase_free_vevent_handler(resource event)
>+/* {{{ proto bool ibase_free_event_handler(resource event)
>Frees the event handler set by ibase_set_event_handler() */
> PHP_FUNCTION(ibase_free_event_handler)
> {
>
>
>
>

-- 
https://www.paypal.com/xclick/[EMAIL PROTECTED]&no_note=1&tax=0¤cy_code=EUR
 


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-15 Thread Ard Biesheuvel
abies   Fri Aug 15 20:58:24 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Added comment about ibase_num_rows()
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.143 php-src/ext/interbase/interbase.c:1.144
--- php-src/ext/interbase/interbase.c:1.143 Fri Aug 15 12:13:51 2003
+++ php-src/ext/interbase/interbase.c   Fri Aug 15 20:58:24 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.143 2003/08/15 16:13:51 abies Exp $ */
+/* $Id: interbase.c,v 1.144 2003/08/16 00:58:24 abies Exp $ */
 
 /*
Changes:
@@ -727,7 +727,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.143 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.144 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -2248,20 +2248,30 @@
 }
 /* }}} */
 
-/* {{{ proto ibase_num_rows( resource result_identifier )
-   Returns the number of rows in a result */
+/* {{{ ibase_num_rows( resource result_identifier ) */
 PHP_FUNCTION(ibase_num_rows) 
 {
/**
-* This function relies on the InterBase API function isc_dsql_sql_info()
-* which has a couple of limitations (which I hope will be fixed in
-* future releases of Firebird):
-* - row count is always zero before the first fetch;
-* - row count for SELECT ... FOR UPDATE is broken -> never returns a
-*   higher number than the number of records fetched so far;
-* - row count for other statements is merely a lower bound on the number
-*   of records => calling ibase_num_rows() again after a couple of fetches
-*   will most likely return a new (higher) figure for large result sets.
+* PLEASE READ THIS FIRST before adding this function to the main PHP
+* documentation:
+* 
+* As this function relies on the InterBase API function isc_dsql_sql_info()
+* which has a couple of limitations (which I hope will be fixed in future 
+* releases of Firebird), this function is fairly useless. I'm leaving it
+* in place for people who can live with the limitations, which I only 
+* found out about after I had implemented it anyway.
+*
+* Currently, there's no way to determine how many rows can be fetched from
+* a cursor. The only number that _can_ be determined is the number of rows
+* that have already been pre-fetched by the client library. 
+* This implies the following:
+* - num_rows() always returns zero before the first fetch;
+* - num_rows() for SELECT ... FOR UPDATE is broken -> never returns a
+*   higher number than the number of records fetched so far (no pre-fetch);
+* - the result of num_rows() for other statements is merely a lower bound 
+* on the number of records => calling ibase_num_rows() again after a couple
+* of fetches will most likely return a new (higher) figure for large result 
+* sets.
 *
 * 12-aug-2003 Ard Biesheuvel
 */
@@ -4088,7 +4098,7 @@
zend_list_addref(Z_LVAL_P(return_value));
 }
 
-/* {{{ proto bool ibase_free_vevent_handler(resource event)
+/* {{{ proto bool ibase_free_event_handler(resource event)
Frees the event handler set by ibase_set_event_handler() */
 PHP_FUNCTION(ibase_free_event_handler)
 {



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c php_interbase.h

2003-08-15 Thread Ard Biesheuvel
abies   Fri Aug 15 12:13:52 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c php_interbase.h 
  Log:
  Added ibase_free_event_handler()
  
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.142 php-src/ext/interbase/interbase.c:1.143
--- php-src/ext/interbase/interbase.c:1.142 Thu Aug 14 20:16:58 2003
+++ php-src/ext/interbase/interbase.c   Fri Aug 15 12:13:51 2003
@@ -14,10 +14,11 @@
+--+
| Authors: Jouni Ahto <[EMAIL PROTECTED]>|
|  Andrew Avdeev <[EMAIL PROTECTED]>  |
+   |  Ard Biesheuvel <[EMAIL PROTECTED]>  |
+--+
  */
 
-/* $Id: interbase.c,v 1.142 2003/08/15 00:16:58 abies Exp $ */
+/* $Id: interbase.c,v 1.143 2003/08/15 16:13:51 abies Exp $ */
 
 /*
Changes:
@@ -137,6 +138,7 @@
 #endif
PHP_FE(ibase_wait_event, NULL)
PHP_FE(ibase_set_event_handler, NULL)
+   PHP_FE(ibase_free_event_handler, NULL)
{NULL, NULL, NULL}
 };
 
@@ -725,7 +727,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.142 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.143 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -3965,16 +3967,13 @@
}
}   
 
-   Z_TYPE(return_value) = IS_BOOL;
-   Z_BVAL(return_value) = 1;
-
/* call the callback provided by the user */
if (SUCCESS != call_user_function(EG(function_table), NULL, 
event->callback, &return_value, 2, args TSRMLS_CC)) {
_php_ibase_module_error("Error calling callback %s", 
Z_STRVAL_P(event->callback));
return 0;
}
 
-   if (! Z_BVAL(return_value)) {
+   if (Z_TYPE(return_value) == IS_BOOL && !Z_BVAL(return_value)) {
return 0;
}   
}
@@ -4042,7 +4041,7 @@
}   

/* get the callback */
-   if (!zend_is_callable(*args[i-1], 0, &callback_name)) {
+   if (!zend_is_callable(*cb_arg, 0, &callback_name)) {
_php_ibase_module_error("Callback argument %s is not a callable 
function", callback_name);
efree(callback_name);
efree(args);
@@ -4088,7 +4087,24 @@
ZEND_REGISTER_RESOURCE(return_value, event, le_event);
zend_list_addref(Z_LVAL_P(return_value));
 }
-   
+
+/* {{{ proto bool ibase_free_vevent_handler(resource event)
+   Frees the event handler set by ibase_set_event_handler() */
+PHP_FUNCTION(ibase_free_event_handler)
+{
+   zval **event_arg;
+   ibase_event *event;
+   
+   RESET_ERRMSG;
+   
+   if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &event_arg) == FAILURE) {
+   WRONG_PARAM_COUNT;
+   }
+
+   ZEND_FETCH_RESOURCE(event, ibase_event *, event_arg, -1, "Interbase event", 
le_event);
+   zend_list_delete(Z_LVAL_PP(event_arg));
+   RETURN_TRUE;
+}  
 /* }}} */
   
 #endif /* HAVE_IBASE */
Index: php-src/ext/interbase/php_interbase.h
diff -u php-src/ext/interbase/php_interbase.h:1.49 
php-src/ext/interbase/php_interbase.h:1.50
--- php-src/ext/interbase/php_interbase.h:1.49  Thu Aug 14 20:06:07 2003
+++ php-src/ext/interbase/php_interbase.h   Fri Aug 15 12:13:51 2003
@@ -14,10 +14,11 @@
+--+
| Authors: Jouni Ahto <[EMAIL PROTECTED]>|
|  Andrew Avdeev <[EMAIL PROTECTED]>   |
+   |  Ard Biesheuvel <[EMAIL PROTECTED]>  |
+--+
  */
 
-/* $Id: php_interbase.h,v 1.49 2003/08/15 00:06:07 abies Exp $ */
+/* $Id: php_interbase.h,v 1.50 2003/08/15 16:13:51 abies Exp $ */
 
 #ifndef PHP_INTERBASE_H
 #define PHP_INTERBASE_H
@@ -92,6 +93,7 @@
 
 PHP_FUNCTION(ibase_wait_event);
 PHP_FUNCTION(ibase_set_event_handler);
+PHP_FUNCTION(ibase_free_event_handler);
 
 #define IBASE_MSGSIZE 256
 #define MAX_ERRMSG (IBASE_MSGSIZE*2)



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c php_interbase.h

2003-08-14 Thread Ard Biesheuvel
abies   Wed Aug  6 21:00:25 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c php_interbase.h 
  Log:
  Fixed crash in _php_ibase_error() after request shutdown
  
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.119 php-src/ext/interbase/interbase.c:1.120
--- php-src/ext/interbase/interbase.c:1.119 Wed Aug  6 20:00:19 2003
+++ php-src/ext/interbase/interbase.c   Wed Aug  6 21:00:22 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.119 2003/08/07 00:00:19 abies Exp $ */
+/* $Id: interbase.c,v 1.120 2003/08/07 01:00:22 abies Exp $ */
 
 
 /* TODO: Arrays, roles?
@@ -34,6 +34,8 @@
  emalloc() with do_alloca()
- Changes to ibase_query() to enable the use of CREATE 
DATABASE ...
- Added ibase_drop_db()
+   - Added ibase_commit_ret() and ibase_rollback_ret()
+   - Added ibase_name_result()
2001-05-31: Jeremy Bettis <[EMAIL PROTECTED]>
- If a blob handle was expected and something else was
  received create a blob and add the value to it.
@@ -575,7 +577,6 @@
ibase_globals->timestampformat = NULL;
ibase_globals->dateformat = NULL;
ibase_globals->timeformat = NULL;
-   ibase_globals->errmsg = NULL;
ibase_globals->num_persistent = 0;
 }
 
@@ -632,10 +633,7 @@
}
IBG(timeformat) = DL_STRDUP(IBG(cfg_timeformat));
 
-   if (IBG(errmsg)) {
-   DL_FREE(IBG(errmsg));
-   }
-   IBG(errmsg) = DL_MALLOC(sizeof(char)*MAX_ERRMSG+1);
+   RESET_ERRMSG;
 
return SUCCESS;
 }
@@ -663,11 +661,6 @@
}
IBG(timeformat) = NULL;
 
-   if (IBG(errmsg)) {
-   DL_FREE(IBG(errmsg));
-   }
-   IBG(errmsg) = NULL;
-
return SUCCESS;
 } 
  
@@ -677,7 +670,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.119 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.120 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
Index: php-src/ext/interbase/php_interbase.h
diff -u php-src/ext/interbase/php_interbase.h:1.38 
php-src/ext/interbase/php_interbase.h:1.39
--- php-src/ext/interbase/php_interbase.h:1.38  Wed Aug  6 13:51:46 2003
+++ php-src/ext/interbase/php_interbase.h   Wed Aug  6 21:00:22 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: php_interbase.h,v 1.38 2003/08/06 17:51:46 abies Exp $ */
+/* $Id: php_interbase.h,v 1.39 2003/08/07 01:00:22 abies Exp $ */
 
 #ifndef PHP_INTERBASE_H
 #define PHP_INTERBASE_H
@@ -102,7 +102,7 @@
char *cfg_dateformat;
char *timeformat;
char *cfg_timeformat;
-   char *errmsg;
+   char errmsg[MAX_ERRMSG];
 ZEND_END_MODULE_GLOBALS(ibase)
 
 typedef struct {



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-14 Thread Jani Taskinen
sniper  Mon Aug 11 22:11:42 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  fix build
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.128 php-src/ext/interbase/interbase.c:1.129
--- php-src/ext/interbase/interbase.c:1.128 Mon Aug 11 20:55:57 2003
+++ php-src/ext/interbase/interbase.c   Mon Aug 11 22:11:41 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.128 2003/08/12 00:55:57 iliaa Exp $ */
+/* $Id: interbase.c,v 1.129 2003/08/12 02:11:41 sniper Exp $ */
 
 
 /* TODO: Arrays, roles?
@@ -687,7 +687,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.128 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.129 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -799,7 +799,7 @@
WRONG_PARAM_COUNT;
}

-   args = (zval ***) safe_emalloc(sizeof(zval **), ZEND_NUM_ARGS());
+   args = (zval ***) safe_emalloc(sizeof(zval **), ZEND_NUM_ARGS(), 0);
if (zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {
efree(args);
RETURN_FALSE;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-14 Thread Ard Biesheuvel
abies   Tue Aug 12 07:35:26 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Added comment in code :-)
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.132 php-src/ext/interbase/interbase.c:1.133
--- php-src/ext/interbase/interbase.c:1.132 Tue Aug 12 07:27:03 2003
+++ php-src/ext/interbase/interbase.c   Tue Aug 12 07:35:26 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.132 2003/08/12 11:27:03 abies Exp $ */
+/* $Id: interbase.c,v 1.133 2003/08/12 11:35:26 abies Exp $ */
 
 
 /* TODO: Arrays, roles?
@@ -687,7 +687,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.132 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.133 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -2201,6 +2201,20 @@
Returns the number of rows in a result */
 PHP_FUNCTION(ibase_num_rows) 
 {
+   /**
+* This function relies on the InterBase API function isc_dsql_sql_info()
+* which has a couple of limitations (which I hope will be fixed in
+* future releases of Firebird):
+* - row count is always zero before the first fetch;
+* - row count for SELECT ... FOR UPDATE is broken -> never returns a
+*   higher number than the number of records fetched so far;
+* - row count for other statements is merely a lower bound on the number
+*   of records => calling ibase_num_rows() again after a couple of fetches
+*   will most likely return a new (higher) figure for large result sets.
+*
+* 12-aug-2003 Ard Biesheuvel
+*/
+   
zval **result_arg;
ibase_result *ib_result;
char info_count[] = {isc_info_sql_records}, result[64];



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-14 Thread Ard Biesheuvel
abies   Tue Aug 12 07:27:04 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Revert ugly workaround for erroneous results of ibase_num_rows() (see comment in 
code)
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.131 php-src/ext/interbase/interbase.c:1.132
--- php-src/ext/interbase/interbase.c:1.131 Tue Aug 12 06:02:25 2003
+++ php-src/ext/interbase/interbase.c   Tue Aug 12 07:27:03 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.131 2003/08/12 10:02:25 abies Exp $ */
+/* $Id: interbase.c,v 1.132 2003/08/12 11:27:03 abies Exp $ */
 
 
 /* TODO: Arrays, roles?
@@ -687,7 +687,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.131 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.132 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -1901,23 +1901,6 @@
 }
 /* }}} */
 
-/* {{{ _php_ibase_do_fetch() */
-
-static void _php_ibase_do_fetch(ibase_result *ib_result TSRMLS_DC)
-{
-   if (ib_result->has_more_rows) {
-   if (isc_dsql_fetch(IB_STATUS, &ib_result->stmt, 1, 
ib_result->out_sqlda)) {
-
-   ib_result->has_more_rows = 0;
-   if (IB_STATUS[0] && IB_STATUS[1]) { /* error in fetch */
-   _php_ibase_error(TSRMLS_C);
-   }
-   }
-   }
-}  
-   
-/* }}} */
-
 /* {{{ proto resource ibase_query([resource link_identifier [, resource 
link_identifier ] ,] string query [, int bind_args])
Execute a query */
 PHP_FUNCTION(ibase_query)
@@ -2161,7 +2144,6 @@
ib_query->stmt = NULL; /* keep stmt when free query */
_php_ibase_free_query(ib_query TSRMLS_CC);
ib_result->has_more_rows = 1;
-   _php_ibase_do_fetch(ib_result TSRMLS_CC);
ZEND_REGISTER_RESOURCE(return_value, ib_result, le_result);
} else {
_php_ibase_free_query(ib_query TSRMLS_CC);
@@ -2468,6 +2450,8 @@
ibase_result *ib_result;
XSQLVAR *var;

+   RESET_ERRMSG;
+   
switch (ZEND_NUM_ARGS()) {
case 1:
if (ZEND_NUM_ARGS() == 1 && zend_get_parameters_ex(1, 
&result_arg) == FAILURE) {
@@ -2490,10 +2474,17 @@
 
if (ib_result->out_sqlda == NULL || !ib_result->has_more_rows) {
RETURN_FALSE;
-   } /* might have been because of an error */
+   }
+
+   if (isc_dsql_fetch(IB_STATUS, &ib_result->stmt, 1, ib_result->out_sqlda)) {
+
+   ib_result->has_more_rows = 0;
+   if (IB_STATUS[0] && IB_STATUS[1]) { /* error in fetch */
+   _php_ibase_error(TSRMLS_C);
+   }
+   RETURN_FALSE;
+   }
 
-   RESET_ERRMSG;
-   
array_init(return_value);

arr_cnt = 0;
@@ -2530,13 +2521,13 @@

if (isc_open_blob(IB_STATUS, 
&ib_result->link, &ib_result->trans, &bl_handle, (ISC_QUAD ISC_FAR *) var->sqldata)) {
_php_ibase_error(TSRMLS_C);
-   goto 
_php_ibase_fetch_hash_error;
+   RETURN_FALSE;
}

bl_items[0] = 
isc_info_blob_total_length;
if (isc_blob_info(IB_STATUS, 
&bl_handle, sizeof(bl_items), bl_items, sizeof(bl_info), bl_info)) {
_php_ibase_error(TSRMLS_C);
-   goto 
_php_ibase_fetch_hash_error;
+   RETURN_FALSE;
}

/* find total length of blob's data */
@@ -2562,14 +2553,14 @@
if (cur_len > max_len) { /* 
never! */
efree(bl_data);

_php_ibase_module_error("PHP module internal error");
-   goto 
_php_ibase_fetch_hash_error;
+   RETURN_FALSE;
}

[PHP-CVS] cvs: php-src /ext/interbase interbase.c php_interbase.h

2003-08-14 Thread Ard Biesheuvel
abies   Tue Aug 12 14:02:00 2003 EDT

  Modified files:  
/php-src/ext/interbase  php_interbase.h interbase.c 
  Log:
  Re-commit of failed patch 
  
  Index: php-src/ext/interbase/php_interbase.h
diff -u php-src/ext/interbase/php_interbase.h:1.44 
php-src/ext/interbase/php_interbase.h:1.45
--- php-src/ext/interbase/php_interbase.h:1.44  Tue Aug 12 13:41:37 2003
+++ php-src/ext/interbase/php_interbase.h   Tue Aug 12 14:01:59 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: php_interbase.h,v 1.44 2003/08/12 17:41:37 sniper Exp $ */
+/* $Id: php_interbase.h,v 1.45 2003/08/12 18:01:59 abies Exp $ */
 
 #ifndef PHP_INTERBASE_H
 #define PHP_INTERBASE_H
@@ -153,6 +153,9 @@
int in_array_cnt, out_array_cnt;
unsigned short dialect;
int cursor_open;
+   char statement_type;
+   char *query;
+   int trans_res_id;
 } ibase_query;
 
 typedef struct {
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.136 php-src/ext/interbase/interbase.c:1.137
--- php-src/ext/interbase/interbase.c:1.136 Tue Aug 12 13:41:37 2003
+++ php-src/ext/interbase/interbase.c   Tue Aug 12 14:01:59 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.136 2003/08/12 17:41:37 sniper Exp $ */
+/* $Id: interbase.c,v 1.137 2003/08/12 18:01:59 abies Exp $ */
 
 
 /* TODO: Arrays, roles?
@@ -421,9 +421,9 @@
ibase_db_link *link = (ibase_db_link *) rsrc->ptr;
 
_php_ibase_commit_link(link TSRMLS_CC);
-   if (link->link != NULL) {
+   if (link->handle != NULL) {
IBDEBUG("Closing normal link...");
-   isc_detach_database(IB_STATUS, &link->link);
+   isc_detach_database(IB_STATUS, &link->handle);
}
IBG(num_links)--;
efree(link);
@@ -438,8 +438,8 @@
 
_php_ibase_commit_link(link TSRMLS_CC);
IBDEBUG("Closing permanent link...");
-   if (link->link != NULL) {
-   isc_detach_database(IB_STATUS, &link->link);
+   if (link->handle != NULL) {
+   isc_detach_database(IB_STATUS, &link->handle);
}
IBG(num_persistent)--;
IBG(num_links)--;
@@ -502,6 +502,9 @@
if (ib_query->out_array) {
efree(ib_query->out_array);
}
+   if (ib_query->query) {
+   efree(ib_query->query);
+   }
efree(ib_query);
}
 }
@@ -530,6 +533,9 @@
if (ib_query->out_array) {
efree(ib_query->out_array);
}
+   if (ib_query->query) {
+   efree(ib_query->query);
+   }
efree(ib_query);
}
 }
@@ -692,7 +698,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.136 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.137 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -865,7 +871,7 @@
}
/* Check if connection has timed out */
ib_link = (ibase_db_link *) le->ptr;
-   if (!isc_database_info(IB_STATUS, &ib_link->link, 
sizeof(tmp_1), tmp_1, sizeof(tmp_2), tmp_2)) {
+   if (!isc_database_info(IB_STATUS, &ib_link->handle, 
sizeof(tmp_1), tmp_1, sizeof(tmp_2), tmp_2)) {
open_new_connection = 0;
}
}
@@ -895,7 +901,7 @@
}
 
ib_link = (ibase_db_link *) malloc(sizeof(ibase_db_link));
-   ib_link->link = db_handle;
+   ib_link->handle = db_handle;
ib_link->dialect = (ib_dialect ? (unsigned short) 
strtoul(ib_dialect, NULL, 10) : SQL_DIALECT_CURRENT);
ib_link->tr_list = NULL;
 
@@ -955,7 +961,7 @@
}
 
ib_link = (ibase_db_link *) emalloc(sizeof(ibase_db_link));
-   ib_link->link = db_handle;
+   ib_link->handle = db_handle;
ib_link->dialect = (ib_dialect ? (unsigned short) strtoul(ib_dialect, 
NULL, 10) : SQL_DIALECT_CURRENT);
ib_link->tr_list = NULL;

@@ -1054,7 +1060,7 @@
}

ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, link_arg, link_id, "InterBase 
link", le_link, le_plink);
-   if (isc_drop_database(IB_STATUS, &ib_link->link)) {
+   if (isc_drop_database(IB_STATUS, &ib_link->handle)) {
_php_ibase_error(TSRMLS_C);
RETURN_FALSE;
}
@@ -1162,9 +1168,10 @@
 
 /* {{{ _php_ibase_alloc_query() */
 /* 

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-14 Thread Ard Biesheuvel
abies   Thu Aug 14 20:16:59 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Moved TRMLS_FETCH to correct scope
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.141 php-src/ext/interbase/interbase.c:1.142
--- php-src/ext/interbase/interbase.c:1.141 Thu Aug 14 20:06:07 2003
+++ php-src/ext/interbase/interbase.c   Thu Aug 14 20:16:58 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.141 2003/08/15 00:06:07 abies Exp $ */
+/* $Id: interbase.c,v 1.142 2003/08/15 00:16:58 abies Exp $ */
 
 /*
Changes:
@@ -725,7 +725,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.141 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.142 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -3935,6 +3935,9 @@
 /* {{{ _php_ibase_callback() */
 static isc_callback _php_ibase_callback(ibase_event *event, unsigned short 
buffer_size, char *result_buf)
 {
+   /* this function is called asynchronously by the Interbase client library. */
+   TSRMLS_FETCH_FROM_CTX(event->thread_ctx);
+   
/**
 * The callback function is called when the event is first registered and when 
the event
 * is cancelled. I consider this is a bug. By clearing event->callback, we 
make sure 
@@ -3946,9 +3949,6 @@
ISC_STATUS occurred_event[15];
zval event_name, link_id, return_value, *args[2] = { &event_name, 
&link_id };
 
-   /* this function is called asynchronously by the Interbase client 
library. */
-   TSRMLS_FETCH_FROM_CTX(event->thread_ctx);
-   
/* copy the updated results into the result buffer */
memcpy(event->result_buffer, result_buf, buffer_size);

@@ -4086,6 +4086,7 @@
efree(args);
 
ZEND_REGISTER_RESOURCE(return_value, event, le_event);
+   zend_list_addref(Z_LVAL_P(return_value));
 }

 /* }}} */



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c php_interbase.h

2003-08-14 Thread Ard Biesheuvel
abies   Thu Aug 14 20:06:07 2003 EDT

  Modified files:  
/php-src/ext/interbase  php_interbase.h interbase.c 
  Log:
  Added ibase_set_event_handler()
  
  Index: php-src/ext/interbase/php_interbase.h
diff -u php-src/ext/interbase/php_interbase.h:1.48 
php-src/ext/interbase/php_interbase.h:1.49
--- php-src/ext/interbase/php_interbase.h:1.48  Thu Aug 14 06:55:02 2003
+++ php-src/ext/interbase/php_interbase.h   Thu Aug 14 20:06:07 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: php_interbase.h,v 1.48 2003/08/14 10:55:02 abies Exp $ */
+/* $Id: php_interbase.h,v 1.49 2003/08/15 00:06:07 abies Exp $ */
 
 #ifndef PHP_INTERBASE_H
 #define PHP_INTERBASE_H
@@ -91,6 +91,7 @@
 PHP_FUNCTION(ibase_errcode);
 
 PHP_FUNCTION(ibase_wait_event);
+PHP_FUNCTION(ibase_set_event_handler);
 
 #define IBASE_MSGSIZE 256
 #define MAX_ERRMSG (IBASE_MSGSIZE*2)
@@ -170,6 +171,17 @@
unsigned char has_more_rows;
char statement_type;
 } ibase_result;
+
+typedef struct {
+   int link_res_id;
+   ibase_db_link *link;
+   ISC_LONG event_id;
+   unsigned short event_count;
+   char **events;
+   char *event_buffer, *result_buffer;
+   zval *callback;
+   void **thread_ctx;
+} ibase_event;
 
 typedef struct _php_ibase_varchar {
short var_len;
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.140 php-src/ext/interbase/interbase.c:1.141
--- php-src/ext/interbase/interbase.c:1.140 Thu Aug 14 06:55:02 2003
+++ php-src/ext/interbase/interbase.c   Thu Aug 14 20:06:07 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.140 2003/08/14 10:55:02 abies Exp $ */
+/* $Id: interbase.c,v 1.141 2003/08/15 00:06:07 abies Exp $ */
 
 /*
Changes:
@@ -136,6 +136,7 @@
PHP_FE(ibase_delete_user, NULL)
 #endif
PHP_FE(ibase_wait_event, NULL)
+   PHP_FE(ibase_set_event_handler, NULL)
{NULL, NULL, NULL}
 };
 
@@ -164,7 +165,7 @@
 #endif
 
 /* True globals, no need for thread safety */
-static int le_blob, le_link, le_plink, le_result, le_query, le_trans;
+static int le_blob, le_link, le_plink, le_result, le_query, le_trans, le_event;
 
 ZEND_DECLARE_MODULE_GLOBALS(ibase)
 
@@ -584,6 +585,34 @@
 }
 /* }}} */
 
+/* {{{ _php_ibase_event_free() */
+static void _php_ibase_event_free(char *event_buf, char *result_buf)
+{
+   isc_free(event_buf);
+   isc_free(result_buf);
+}
+/* }}} */
+
+/* {{{ _php_ibase_free_event */
+static void _php_ibase_free_event(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+{
+   ibase_event *event = (ibase_event *) rsrc->ptr;
+   
+   IBDEBUG("Cleaning up event resource");
+
+   zval_dtor(event->callback);
+   event->callback = NULL;
+   
+   if (event->link->handle != NULL) {
+   if (isc_cancel_events(IB_STATUS, &event->link->handle, 
&event->event_id)) {
+   _php_ibase_error(TSRMLS_C);
+   }
+   }
+   _php_ibase_event_free(event->event_buffer,event->result_buffer);
+}
+   
+/* }}} */
+
 /* {{{ startup, shutdown and info functions */
 PHP_INI_BEGIN()
STD_PHP_INI_BOOLEAN("ibase.allow_persistent", "1", PHP_INI_SYSTEM, 
OnUpdateLong, allow_persistent, zend_ibase_globals, ibase_globals)
@@ -617,6 +646,7 @@
le_link = zend_register_list_destructors_ex(_php_ibase_close_link, NULL, 
"interbase link", module_number);
le_plink = zend_register_list_destructors_ex(php_ibase_commit_link_rsrc, 
_php_ibase_close_plink, "interbase link persistent", module_number);
le_trans = zend_register_list_destructors_ex(_php_ibase_free_trans, NULL, 
"interbase transaction", module_number);
+   le_event = zend_register_list_destructors_ex(_php_ibase_free_event, NULL, 
"interbase event", module_number);
 
REGISTER_LONG_CONSTANT("IBASE_DEFAULT", PHP_IBASE_DEFAULT, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IBASE_TEXT", PHP_IBASE_TEXT, CONST_PERSISTENT);
@@ -695,7 +725,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.140 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.141 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -1910,7 +1940,7 @@
 {
ibase_trans *trans = NULL;
int res_id = 0;
-   ISC_STATUS result;
+   ISC_STATUS result = 0;
 
RESET_ERRMSG;
 
@@ -3829,14 +3859,6 @@
 }
 /* }}} */
 
-/* {{{ _php_ibase_event_free() */
-static void _php_ibase_event_free(char *event_buf, char *result_buf)
-{
-   isc_free(event_buf);
-   isc_free(result_buf);
-}
-/* }}} */
-
 /* {{{ proto string ibase_wait_event([resource link,] string event [, string event [, 
...]])
Waits for any one of the passed 

Re: [PHP-CVS] cvs: php-src /ext/interbase interbase.c php_interbase.h

2003-08-14 Thread Jani Taskinen

I have reverted to previous version, you fucked up the commit
with some dos line endings or something.

Reapply the patch. 

--Jani


On Tue, 12 Aug 2003, Ard Biesheuvel wrote:

>abies  Tue Aug 12 13:33:54 2003 EDT
>
>  Modified files:  
>/php-src/ext/interbase interbase.c php_interbase.h 
>  Log:
>  Allow prepared execution of any non-query statement except CREATE DB
>  (fixes bug #7014)
>  
>  

 


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-14 Thread Ard Biesheuvel
abies   Tue Aug 12 09:19:36 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Fixed bug #23936 (fail to select and fetch)
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.133 php-src/ext/interbase/interbase.c:1.134
--- php-src/ext/interbase/interbase.c:1.133 Tue Aug 12 07:35:26 2003
+++ php-src/ext/interbase/interbase.c   Tue Aug 12 09:19:36 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.133 2003/08/12 11:35:26 abies Exp $ */
+/* $Id: interbase.c,v 1.134 2003/08/12 13:19:36 abies Exp $ */
 
 
 /* TODO: Arrays, roles?
@@ -64,6 +64,11 @@
 
 #if HAVE_IBASE
 #include 
+
+#ifndef SQLDA_CURRENT_VERSION
+#define SQLDA_CURRENT_VERSION SQLDA_VERSION1
+#endif
+
 #include 
 #include "ext/standard/fsock.h"
 #include "ext/standard/info.h"
@@ -687,7 +692,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.133 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.134 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -1180,7 +1185,7 @@
 
IB_QUERY->out_sqlda = (XSQLDA *) emalloc(XSQLDA_LENGTH(1));
IB_QUERY->out_sqlda->sqln = 1;
-   IB_QUERY->out_sqlda->version = SQLDA_VERSION1;
+   IB_QUERY->out_sqlda->version = SQLDA_CURRENT_VERSION;
 
if (isc_dsql_prepare(IB_STATUS, &IB_QUERY->trans, &IB_QUERY->stmt, 0, query, 
dialect, IB_QUERY->out_sqlda)) {
_php_ibase_error(TSRMLS_C);
@@ -1191,8 +1196,8 @@
if (IB_QUERY->out_sqlda->sqld > IB_QUERY->out_sqlda->sqln) {
IB_QUERY->out_sqlda = erealloc(IB_QUERY->out_sqlda, 
XSQLDA_LENGTH(IB_QUERY->out_sqlda->sqld));
IB_QUERY->out_sqlda->sqln = IB_QUERY->out_sqlda->sqld;
-   IB_QUERY->out_sqlda->version = SQLDA_VERSION1;
-   if (isc_dsql_describe(IB_STATUS, &IB_QUERY->stmt, SQLDA_VERSION1, 
IB_QUERY->out_sqlda)) {
+   IB_QUERY->out_sqlda->version = SQLDA_CURRENT_VERSION;
+   if (isc_dsql_describe(IB_STATUS, &IB_QUERY->stmt, 
SQLDA_CURRENT_VERSION, IB_QUERY->out_sqlda)) {
_php_ibase_error(TSRMLS_C);
goto _php_ibase_alloc_query_error;
}
@@ -1201,8 +1206,8 @@
/* maybe have input placeholders? */
IB_QUERY->in_sqlda = emalloc(XSQLDA_LENGTH(1));
IB_QUERY->in_sqlda->sqln = 1;
-   IB_QUERY->in_sqlda->version = SQLDA_VERSION1;
-   if (isc_dsql_describe_bind(IB_STATUS, &IB_QUERY->stmt, SQLDA_VERSION1, 
IB_QUERY->in_sqlda)) {
+   IB_QUERY->in_sqlda->version = SQLDA_CURRENT_VERSION;
+   if (isc_dsql_describe_bind(IB_STATUS, &IB_QUERY->stmt, SQLDA_CURRENT_VERSION, 
IB_QUERY->in_sqlda)) {
_php_ibase_error(TSRMLS_C);
goto _php_ibase_alloc_query_error;
}
@@ -1211,8 +1216,8 @@
if (IB_QUERY->in_sqlda->sqln < IB_QUERY->in_sqlda->sqld) {
IB_QUERY->in_sqlda = erealloc(IB_QUERY->in_sqlda, 
XSQLDA_LENGTH(IB_QUERY->in_sqlda->sqld));
IB_QUERY->in_sqlda->sqln = IB_QUERY->in_sqlda->sqld;
-   IB_QUERY->in_sqlda->version = SQLDA_VERSION1;
-   if (isc_dsql_describe_bind(IB_STATUS, &IB_QUERY->stmt, SQLDA_VERSION1, 
IB_QUERY->in_sqlda)) {
+   IB_QUERY->in_sqlda->version = SQLDA_CURRENT_VERSION;
+   if (isc_dsql_describe_bind(IB_STATUS, &IB_QUERY->stmt, 
SQLDA_CURRENT_VERSION, IB_QUERY->in_sqlda)) {
_php_ibase_error(TSRMLS_C);
goto _php_ibase_alloc_query_error;
}



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c php_interbase.h

2003-08-14 Thread Ard Biesheuvel
abies   Thu Aug 14 06:55:02 2003 EDT

  Modified files:  
/php-src/ext/interbase  php_interbase.h interbase.c 
  Log:
  Added ibase_wait_event()
  
  
Index: php-src/ext/interbase/php_interbase.h
diff -u php-src/ext/interbase/php_interbase.h:1.47 
php-src/ext/interbase/php_interbase.h:1.48
--- php-src/ext/interbase/php_interbase.h:1.47  Tue Aug 12 22:19:14 2003
+++ php-src/ext/interbase/php_interbase.h   Thu Aug 14 06:55:02 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: php_interbase.h,v 1.47 2003/08/13 02:19:14 abies Exp $ */
+/* $Id: php_interbase.h,v 1.48 2003/08/14 10:55:02 abies Exp $ */
 
 #ifndef PHP_INTERBASE_H
 #define PHP_INTERBASE_H
@@ -89,6 +89,8 @@
 #endif
 PHP_FUNCTION(ibase_errmsg);
 PHP_FUNCTION(ibase_errcode);
+
+PHP_FUNCTION(ibase_wait_event);
 
 #define IBASE_MSGSIZE 256
 #define MAX_ERRMSG (IBASE_MSGSIZE*2)
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.139 php-src/ext/interbase/interbase.c:1.140
--- php-src/ext/interbase/interbase.c:1.139 Wed Aug 13 06:35:14 2003
+++ php-src/ext/interbase/interbase.c   Thu Aug 14 06:55:02 2003
@@ -17,11 +17,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.139 2003/08/13 10:35:14 sniper Exp $ */
-
-
-/* TODO: Arrays, roles?
-A lot... */
+/* $Id: interbase.c,v 1.140 2003/08/14 10:55:02 abies Exp $ */
 
 /*
Changes:
@@ -139,6 +135,7 @@
PHP_FE(ibase_modify_user, NULL)
PHP_FE(ibase_delete_user, NULL)
 #endif
+   PHP_FE(ibase_wait_event, NULL)
{NULL, NULL, NULL}
 };
 
@@ -698,7 +695,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.139 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.140 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -3798,6 +3795,117 @@
 }
 /* }}} */
 #endif /* SQL_DIALECT_V6 */
+
+/* {{{ _php_ibase_event_block() */
+static void _php_ibase_event_block(ibase_db_link *ib_link, unsigned short count, char 
**events, 
+   unsigned short *l, char **event_buf, char **result_buf)
+{
+   ISC_STATUS dummy_result[20];
+
+   /**
+* Unfortunately, there's no clean and portable way in C to pass arguments to 
+* a variadic function if you don't know the number of arguments at compile 
time.
+* (And even if there were a way, the Interbase API doesn't provide a version 
of
+* this function that takes a va_list as an argument)
+*
+* In this case, the number of arguments is limited to 18 by the underlying 
API,
+* so we can work around it.
+*/
+
+   *l = (unsigned short) isc_event_block(event_buf, result_buf, count, events[0], 
+   events[1], events[2], events[3], events[4], events[5], events[6], 
events[7], 
+   events[8], events[9], events[10], events[11], events[12], events[13], 
events[14]);
+
+   /**
+* Currently, this is the only way to correctly initialize an event buffer.
+* This is clearly something that should be fixed, cause the semantics of
+* isc_wait_for_event() indicate that it blocks until an event occurs.
+* If the Firebird people ever fix this, these lines should be removed,
+* otherwise, events will have to fire twice before ibase_wait_event() returns.
+*/
+
+   isc_wait_for_event(dummy_result, &ib_link->handle, *l, *event_buf, 
*result_buf);
+   isc_event_counts(dummy_result, *l, *event_buf, *result_buf);
+}
+/* }}} */
+
+/* {{{ _php_ibase_event_free() */
+static void _php_ibase_event_free(char *event_buf, char *result_buf)
+{
+   isc_free(event_buf);
+   isc_free(result_buf);
+}
+/* }}} */
+
+/* {{{ proto string ibase_wait_event([resource link,] string event [, string event [, 
...]])
+   Waits for any one of the passed Interbase events to be posted by the database, and 
returns its name */
+PHP_FUNCTION(ibase_wait_event)
+{
+   zval ***args;
+   ibase_db_link *ib_link;
+   char *event_buffer, *result_buffer, *events[15];
+   unsigned short i = 0, event_count = 0, buffer_size;
+   ISC_STATUS occurred_event[15];
+   
+   RESET_ERRMSG;
+
+   /* no more than 15 events */
+   if (ZEND_NUM_ARGS() < 1 || ZEND_NUM_ARGS() > 16) {
+   WRONG_PARAM_COUNT;
+   }
+
+   args = (zval ***) safe_emalloc(sizeof(zval **), ZEND_NUM_ARGS(), 0);
+   if (zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {
+   efree(args);
+   RETURN_FALSE;
+   }
+
+   if (Z_TYPE_PP(args[0]) == IS_RESOURCE) {
+
+   ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, args[0], -1, "InterBase 
link", le_link, le_plink);
+   i = 1;
+
+   } else if 

Re: [PHP-CVS] cvs: php-src /ext/interbase interbase.c php_interbase.h

2003-08-14 Thread Ilia Alshanetsky
Please apply this fix to the PHP_4_3 branch as well.

Ilia


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-14 Thread Ard Biesheuvel
abies   Sun Aug 10 13:24:52 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Win32 fixes
  
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.125 php-src/ext/interbase/interbase.c:1.126
--- php-src/ext/interbase/interbase.c:1.125 Sun Aug 10 12:21:26 2003
+++ php-src/ext/interbase/interbase.c   Sun Aug 10 13:24:51 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.125 2003/08/10 16:21:26 abies Exp $ */
+/* $Id: interbase.c,v 1.126 2003/08/10 17:24:51 abies Exp $ */
 
 
 /* TODO: Arrays, roles?
@@ -683,7 +683,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.125 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.126 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -1899,7 +1899,7 @@
 
 /* {{{ _php_ibase_do_fetch() */
 
-static void _php_ibase_do_fetch(ibase_result *ib_result)
+static void _php_ibase_do_fetch(ibase_result *ib_result TSRMLS_DC)
 {
if (ib_result->has_more_rows) {
if (isc_dsql_fetch(IB_STATUS, &ib_result->stmt, 1, 
ib_result->out_sqlda) == 100L) {
@@ -2048,7 +2048,7 @@
RETURN_FALSE;
}

-   /* find out if what kind of statement was prepared */
+   /* find out what kind of statement was prepared */
if (isc_dsql_sql_info(IB_STATUS, &ib_query->stmt, sizeof(info_type), 
info_type, sizeof(result), result)) {
_php_ibase_error(TSRMLS_C);
free_alloca(args);
@@ -2057,12 +2057,12 @@
 
switch (result[3]) {
isc_tr_handle tr;
+   ibase_tr_list **l;

case isc_info_sql_stmt_start_trans:

/* a SET TRANSACTION statement should be executed with a NULL 
trans handle */
tr = NULL;
-   ibase_tr_list **l;

if (isc_dsql_execute_immediate(IB_STATUS, &ib_link->link, &tr, 
0, query, ib_link->dialect, NULL)) {
_php_ibase_error(TSRMLS_C);
@@ -2140,7 +2140,7 @@
unsigned i = 3, result_size = 
isc_vax_integer(&result[1],2);
 
while (result[i] != isc_info_end && i < 
result_size) {
-   short len = 
isc_vax_integer(&result[i+1],2);
+   short len = 
(short)isc_vax_integer(&result[i+1],2);
if (result[i] != 
isc_info_req_select_count) {
trans->affected_rows += 
isc_vax_integer(&result[i+3],len);
}
@@ -2157,7 +2157,7 @@
ib_query->stmt = NULL; /* keep stmt when free query */
_php_ibase_free_query(ib_query TSRMLS_CC);
ib_result->has_more_rows = 1;
-   _php_ibase_do_fetch(ib_result);
+   _php_ibase_do_fetch(ib_result TSRMLS_CC);
ZEND_REGISTER_RESOURCE(return_value, ib_result, le_result);
} else {
_php_ibase_free_query(ib_query TSRMLS_CC);
@@ -2212,7 +2212,7 @@
 /* }}} */
 
 /* {{{ proto ibase_num_rows( resource result_identifier )
-   Returns the number of records in the result */
+   Returns the number of rows in a result */
 PHP_FUNCTION(ibase_num_rows) 
 {
zval **result_arg;
@@ -2236,7 +2236,7 @@
unsigned i = 3, result_size = isc_vax_integer(&result[1],2);
 
while (result[i] != isc_info_end && i < result_size) {
-   short len = isc_vax_integer(&result[i+1],2);
+   short len = (short)isc_vax_integer(&result[i+1],2);
if (result[i] == isc_info_req_select_count) {
RETURN_LONG(isc_vax_integer(&result[i+3],len));
}
@@ -2244,6 +2244,7 @@
}
}   
 }
+/* }}} */
 
 /* {{{ _php_ibase_var_zval() */
 static int _php_ibase_var_zval(zval *val, void *data, int type, int len, int scale, 
int flag TSRMLS_DC)
@@ -2530,13 +2531,13 @@

if (isc_open_blob(IB_STATUS, 
&ib_result->link, &ib_result->trans, &bl_handle, (ISC_QUAD ISC_FAR *) var->sqldata)) {
_php_ibase_error(TSRMLS_C);
-   RETURN_FALSE;
+   goto 
_php_ibase_fetch_hash_error;
  

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-14 Thread Jani Taskinen
sniper  Wed Aug 13 06:35:15 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Disable the debugging to prevent the tests from failing.
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.138 php-src/ext/interbase/interbase.c:1.139
--- php-src/ext/interbase/interbase.c:1.138 Tue Aug 12 22:19:14 2003
+++ php-src/ext/interbase/interbase.c   Wed Aug 13 06:35:14 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.138 2003/08/13 02:19:14 abies Exp $ */
+/* $Id: interbase.c,v 1.139 2003/08/13 10:35:14 sniper Exp $ */
 
 
 /* TODO: Arrays, roles?
@@ -82,8 +82,8 @@
 #endif
 
 #ifdef ZEND_DEBUG
-#define IBDEBUG(a) php_printf("::: %s (%d)\n", a, __LINE__);
-/* #define IBDEBUG(a) */
+/* #define IBDEBUG(a) php_printf("::: %s (%d)\n", a, __LINE__); */
+#define IBDEBUG(a)
 #else
 #define IBDEBUG(a)
 #endif
@@ -698,7 +698,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.138 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.139 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c php_interbase.h

2003-08-14 Thread Ard Biesheuvel
abies   Tue Aug 12 22:19:15 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c php_interbase.h 
  Log:
  Allow the use of EXECUTE PROCEDURE statements
  
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.137 php-src/ext/interbase/interbase.c:1.138
--- php-src/ext/interbase/interbase.c:1.137 Tue Aug 12 14:01:59 2003
+++ php-src/ext/interbase/interbase.c   Tue Aug 12 22:19:14 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.137 2003/08/12 18:01:59 abies Exp $ */
+/* $Id: interbase.c,v 1.138 2003/08/13 02:19:14 abies Exp $ */
 
 
 /* TODO: Arrays, roles?
@@ -82,8 +82,8 @@
 #endif
 
 #ifdef ZEND_DEBUG
-/* #define IBDEBUG(a) php_printf("::: %s (%d)\n", a, __LINE__); */
-#define IBDEBUG(a)
+#define IBDEBUG(a) php_printf("::: %s (%d)\n", a, __LINE__);
+/* #define IBDEBUG(a) */
 #else
 #define IBDEBUG(a)
 #endif
@@ -698,7 +698,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.137 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.138 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -1554,7 +1554,8 @@
BIND_BUF *bind_buf = NULL;
int rv = FAILURE;
char info_count[] = {isc_info_sql_records}, result[64];
-
+   ISC_STATUS isc_result;
+   
RESET_ERRMSG;
 
if (argc > 0 && args != NULL) {
@@ -1627,6 +1628,7 @@
IB_RESULT->link = ib_query->link->handle;
IB_RESULT->trans = ib_query->trans->handle;
IB_RESULT->stmt = ib_query->stmt; 
+   IB_RESULT->statement_type = ib_query->statement_type;
IB_RESULT->drop_stmt = 0; /* when free result close but not drop!*/
 
out_sqlda = IB_RESULT->out_sqlda = 
emalloc(XSQLDA_LENGTH(ib_query->out_sqlda->sqld));
@@ -1656,7 +1658,12 @@
}
}
 
-   if (isc_dsql_execute(IB_STATUS, &ib_query->trans->handle, &ib_query->stmt, 
ib_query->dialect, in_sqlda)) {
+   if (ib_query->statement_type == isc_info_sql_stmt_exec_procedure) {
+   isc_result = isc_dsql_execute2(IB_STATUS, &ib_query->trans->handle, 
&ib_query->stmt, SQLDA_CURRENT_VERSION, in_sqlda, out_sqlda);
+   } else {
+   isc_result = isc_dsql_execute(IB_STATUS, &ib_query->trans->handle, 
&ib_query->stmt, SQLDA_CURRENT_VERSION, in_sqlda);
+   }
+   if (isc_result) {
IBDEBUG("Could not execute query");
_php_ibase_error(TSRMLS_C);
goto _php_ibase_exec_error;
@@ -2505,15 +2512,20 @@
RETURN_FALSE;
}
 
-   if (isc_dsql_fetch(IB_STATUS, &ib_result->stmt, 1, ib_result->out_sqlda)) {
+   if (ib_result->statement_type != isc_info_sql_stmt_exec_procedure) {
 
-   ib_result->has_more_rows = 0;
-   if (IB_STATUS[0] && IB_STATUS[1]) { /* error in fetch */
-   _php_ibase_error(TSRMLS_C);
+   if (isc_dsql_fetch(IB_STATUS, &ib_result->stmt, 1, 
ib_result->out_sqlda)) {
+   
+   ib_result->has_more_rows = 0;
+   if (IB_STATUS[0] && IB_STATUS[1]) { /* error in fetch */
+   _php_ibase_error(TSRMLS_C);
+   }
+   RETURN_FALSE;
}
-   RETURN_FALSE;
-   }
-
+   } else {
+   ib_result->has_more_rows = 0;
+   }   
+   
array_init(return_value);

arr_cnt = 0;
Index: php-src/ext/interbase/php_interbase.h
diff -u php-src/ext/interbase/php_interbase.h:1.46 
php-src/ext/interbase/php_interbase.h:1.47
--- php-src/ext/interbase/php_interbase.h:1.46  Tue Aug 12 14:08:13 2003
+++ php-src/ext/interbase/php_interbase.h   Tue Aug 12 22:19:14 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: php_interbase.h,v 1.46 2003/08/12 18:08:13 abies Exp $ */
+/* $Id: php_interbase.h,v 1.47 2003/08/13 02:19:14 abies Exp $ */
 
 #ifndef PHP_INTERBASE_H
 #define PHP_INTERBASE_H
@@ -166,6 +166,7 @@
XSQLDA *out_sqlda;
ibase_array *out_array;
unsigned char has_more_rows;
+   char statement_type;
 } ibase_result;
 
 typedef struct _php_ibase_varchar {



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src /ext/interbase interbase.c php_interbase.h

2003-08-14 Thread Allowee
On Tuesday 12 August 2003 20:21, Jani Taskinen wrote:
> And please MFH this fix (to PHP_4_3 branch).

Maybe it's a good idea to tell Ard how to commit to branches...

.: Allowee

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src /ext/interbase interbase.c php_interbase.h

2003-08-14 Thread Jani Taskinen

And please MFH this fix (to PHP_4_3 branch).

--Jani


On Tue, 12 Aug 2003, Ard Biesheuvel wrote:

>abies  Tue Aug 12 14:02:00 2003 EDT
>
>  Modified files:  
>/php-src/ext/interbase php_interbase.h interbase.c 
>  Log:
>  Re-commit of failed patch 
>  
>  


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c php_interbase.h

2003-08-14 Thread Ard Biesheuvel
abies   Sun Aug 10 12:21:27 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c php_interbase.h 
  Log:
  Added ibase_affected_rows() and ibase_num_rows()
  Fix for ibase_fetch_*() error after exhaustion of result 
  @- Added ibase_affected_row() (Ard)
  @- Added ibase_num_rows() (Ard) 
  
  Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.124 php-src/ext/interbase/interbase.c:1.125
--- php-src/ext/interbase/interbase.c:1.124 Sun Aug 10 09:20:38 2003
+++ php-src/ext/interbase/interbase.c   Sun Aug 10 12:21:26 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.124 2003/08/10 13:20:38 abies Exp $ */
+/* $Id: interbase.c,v 1.125 2003/08/10 16:21:26 abies Exp $ */
 
 
 /* TODO: Arrays, roles?
@@ -105,6 +105,8 @@
 #endif
 
PHP_FE(ibase_num_fields, NULL)
+   PHP_FE(ibase_num_rows, NULL)
+   PHP_FE(ibase_affected_rows, NULL)
PHP_FE(ibase_field_info, NULL)
 
PHP_FE(ibase_trans, NULL)
@@ -681,7 +683,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.124 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.125 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -1717,6 +1719,7 @@
ib_trans = (ibase_trans *) emalloc(sizeof(ibase_trans) + 
(link_cnt-1)*sizeof(ibase_db_link *));
ib_trans->handle = tr_handle;
ib_trans->link_cnt = link_cnt;
+   ib_trans->affected_rows = 0;
for (i = 0; i < link_cnt; ++i) {
ibase_tr_list **l;
ib_trans->db_link[i] = ib_link[i];
@@ -1762,6 +1765,7 @@
tr = (ibase_trans *) emalloc(sizeof(ibase_trans));
tr->handle = NULL;
tr->link_cnt = 1;
+   tr->affected_rows = 0;
tr->db_link[0] = ib_link;
ib_link->tr_list->trans = tr;
}
@@ -1893,13 +1897,30 @@
 }
 /* }}} */
 
+/* {{{ _php_ibase_do_fetch() */
+
+static void _php_ibase_do_fetch(ibase_result *ib_result)
+{
+   if (ib_result->has_more_rows) {
+   if (isc_dsql_fetch(IB_STATUS, &ib_result->stmt, 1, 
ib_result->out_sqlda) == 100L) {
+   ib_result->has_more_rows = 0;
+   }
+   
+   if (IB_STATUS[0] && IB_STATUS[1]) { /* error in fetch */
+   _php_ibase_error(TSRMLS_C);
+   }
+   }
+}  
+   
+/* }}} */
+
 /* {{{ proto resource ibase_query([resource link_identifier [, resource 
link_identifier ] ,] string query [, int bind_args])
Execute a query */
 PHP_FUNCTION(ibase_query)
 {
zval ***args, **bind_args = NULL;
int i, bind_n = 0, trans_id = 0;
-   char *query, item_type[] = {isc_info_sql_stmt_type}, result[8];
+   char *query, info_type[] = {isc_info_sql_stmt_type}, info_count[] = {'\0'}, 
result[64];
ibase_db_link *ib_link = NULL;
ibase_trans *trans = NULL;
ibase_query *ib_query;
@@ -2028,8 +2049,9 @@
}

/* find out if what kind of statement was prepared */
-   if (isc_dsql_sql_info(IB_STATUS, &ib_query->stmt, sizeof(item_type), 
item_type, sizeof(result), result)) {
+   if (isc_dsql_sql_info(IB_STATUS, &ib_query->stmt, sizeof(info_type), 
info_type, sizeof(result), result)) {
_php_ibase_error(TSRMLS_C);
+   free_alloca(args);
RETURN_FALSE;
}
 
@@ -2052,6 +2074,7 @@
trans = (ibase_trans *) emalloc(sizeof(ibase_trans));
trans->handle = tr;
trans->link_cnt = 1;
+   trans->affected_rows = 0;
trans->db_link[0] = ib_link;

if (ib_link->tr_list == NULL) {
@@ -2088,6 +2111,12 @@
}
break;
 
+   case isc_info_sql_stmt_insert:
+   case isc_info_sql_stmt_update:
+   case isc_info_sql_stmt_delete:
+   /* in these cases, we will want to know the number of affected 
rows */
+   info_count[0] = isc_info_sql_records;
+
default:
 
if (_php_ibase_exec(&ib_result, ib_query, bind_n, bind_args 
TSRMLS_CC) == FAILURE) {
@@ -2095,14 +2124,40 @@
free_alloca(args);
RETURN_FALSE;
}
+   
+   trans->affected_rows = 0;
+   
+   if (info_count[0]) {
+   
+   if (isc_dsql_sql_info(IB_STATUS, &ib_query->stmt, 
sizeof

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-14 Thread Ard Biesheuvel
abies   Tue Aug  5 19:40:30 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Changed ibase_trans() to allow multi-DB transactions with distinct 
  trans_args for each connection.
  
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.114 php-src/ext/interbase/interbase.c:1.115
--- php-src/ext/interbase/interbase.c:1.114 Tue Aug  5 12:30:47 2003
+++ php-src/ext/interbase/interbase.c   Tue Aug  5 19:40:30 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.114 2003/08/05 16:30:47 sniper Exp $ */
+/* $Id: interbase.c,v 1.115 2003/08/05 23:40:30 abies Exp $ */
 
 
 /* TODO: Arrays, roles?
@@ -670,7 +670,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.114 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.115 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "yes");
 #endif
@@ -974,7 +974,7 @@
Close an InterBase connection */
 PHP_FUNCTION(ibase_close)
 {
-   zval **link_arg;
+   zval **link_arg = NULL;
ibase_db_link *ib_link;
int link_id;

@@ -1006,7 +1006,7 @@
Drop an InterBase database */
 PHP_FUNCTION(ibase_drop_db)
 {
-   zval **link_arg;
+   zval **link_arg = NULL;
ibase_db_link *ib_link;
int link_id;

@@ -1576,98 +1576,120 @@
 }
 /* }}} */
 
-/* {{{ proto resource ibase_trans([int trans_args [, resource link_identifier]])
-   Start transaction */
+/* {{{ proto resource ibase_trans([int trans_args [, resource link_identifier [, ... 
], int trans_args [, resource link_identifier [, ... ]] [, ...]]])
+   Start a transaction over one or several databases */
+
+#define TPB_MAX_SIZE (8*sizeof(char))
+
 PHP_FUNCTION(ibase_trans)
 {
-   zval ***args;
-   char tpb[20];
-   long trans_argl = 0;
-   int tpb_len = 0, argn, link_cnt, link_id[19], i;
-   ibase_db_link *ib_link[19];
+   unsigned i, argn, link_cnt = 0, tpb_len = 0;
+   char last_tpb[TPB_MAX_SIZE];
+   ibase_db_link **ib_link = NULL;
ibase_trans *ib_trans;
-
-   ISC_TEB *teb;
isc_tr_handle tr_handle = NULL;
+   ISC_STATUS result;

RESET_ERRMSG;
 
argn = ZEND_NUM_ARGS();
-   if (argn < 0) {
-   WRONG_PARAM_COUNT;
-   }
 
-   if (argn) {
-   /* the number of databases this transaction connects to */
-   link_cnt = argn-1;
+   /* (1+argn) is an upper bound for the number of links this trans connects to */
+   ib_link = (ibase_db_link**)do_alloca(sizeof(ibase_db_link*) * (1+argn));
+   
+   if (argn > 0) {
+   long trans_argl = 0;
+   char *tpb;
+   ISC_TEB *teb;
+   zval ***args = (zval ***)do_alloca(sizeof(zval **) * argn);
 
-   args = (zval ***) emalloc(sizeof(zval **) * argn);
if (zend_get_parameters_array_ex(argn, args) == FAILURE) {
-   efree(args);
+   free_alloca(args);
+   free_alloca(ib_link);
RETURN_FALSE;
}
 
-   /* Handle all database links. */
-   for (i = argn-1; i > 0 && Z_TYPE_PP(args[i]) == IS_RESOURCE; --i) {
-   ZEND_FETCH_RESOURCE2(ib_link[i-1], ibase_db_link *, args[i], 
-1, "InterBase link", le_link, le_plink);
-   link_id[i-1] = Z_LVAL_PP(args[i]);
-   }
+   teb = (ISC_TEB*)do_alloca(sizeof(ISC_TEB) * argn);
+   tpb = (char*)do_alloca(TPB_MAX_SIZE * argn);
 
-   /* First argument is transaction parameters */
-   convert_to_long_ex(args[0]);
-   trans_argl = Z_LVAL_PP(args[0]);
+   /* enumerate all the arguments: assume every non-resource argument 
+  specifies modifiers for the link ids that follow it */
+   for (i = 0; i < argn; ++i) {
+   
+   if (Z_TYPE_PP(args[i]) == IS_RESOURCE) {
+   
+   ZEND_FETCH_RESOURCE2(ib_link[link_cnt], ibase_db_link 
*, args[i], -1, "InterBase link", le_link, le_plink);
+   
+   /* copy the most recent modifier string into tbp[] */
+   memcpy(&tpb[TPB_MAX_SIZE * link_cnt], last_tpb, 
TPB_MAX_SIZE);
 
-   efree(args);
-   }
+   /* add a database handle to the TEB with the most 
recently specified set of modifiers */
+   teb[link_cnt].db_ptr = &ib_link[link_cnt]->link;
+   teb[link_cnt].tpb_len = tpb_len;
+   teb[link_

Re: [PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-14 Thread Jani Taskinen

Any fixes for bugs should be merged to the PHP_4_3 branch..

--Jani


On Tue, 12 Aug 2003, Ard Biesheuvel wrote:

>abies  Tue Aug 12 09:19:36 2003 EDT
>
>  Modified files:  
>/php-src/ext/interbase interbase.c 
>  Log:
>  Fixed bug #23936 (fail to select and fetch)
>  
>Index: php-src/ext/interbase/interbase.c
>diff -u php-src/ext/interbase/interbase.c:1.133 
>php-src/ext/interbase/interbase.c:1.134
>--- php-src/ext/interbase/interbase.c:1.133Tue Aug 12 07:35:26 2003
>+++ php-src/ext/interbase/interbase.c  Tue Aug 12 09:19:36 2003
>@@ -17,7 +17,7 @@
>+--+
>  */
> 
>-/* $Id: interbase.c,v 1.133 2003/08/12 11:35:26 abies Exp $ */
>+/* $Id: interbase.c,v 1.134 2003/08/12 13:19:36 abies Exp $ */
> 
> 
> /* TODO: Arrays, roles?
>@@ -64,6 +64,11 @@
> 
> #if HAVE_IBASE
> #include 
>+
>+#ifndef SQLDA_CURRENT_VERSION
>+#define SQLDA_CURRENT_VERSION SQLDA_VERSION1
>+#endif
>+
> #include 
> #include "ext/standard/fsock.h"
> #include "ext/standard/info.h"
>@@ -687,7 +692,7 @@
> 
>   php_info_print_table_start();
>   php_info_print_table_row(2, "Interbase Support", "enabled");
>-  php_info_print_table_row(2, "Revision", "$Revision: 1.133 $");
>+  php_info_print_table_row(2, "Revision", "$Revision: 1.134 $");
> #ifdef COMPILE_DL_INTERBASE
>   php_info_print_table_row(2, "Dynamic Module", "Yes");
> #endif
>@@ -1180,7 +1185,7 @@
> 
>   IB_QUERY->out_sqlda = (XSQLDA *) emalloc(XSQLDA_LENGTH(1));
>   IB_QUERY->out_sqlda->sqln = 1;
>-  IB_QUERY->out_sqlda->version = SQLDA_VERSION1;
>+  IB_QUERY->out_sqlda->version = SQLDA_CURRENT_VERSION;
> 
>   if (isc_dsql_prepare(IB_STATUS, &IB_QUERY->trans, &IB_QUERY->stmt, 0, query, 
> dialect, IB_QUERY->out_sqlda)) {
>   _php_ibase_error(TSRMLS_C);
>@@ -1191,8 +1196,8 @@
>   if (IB_QUERY->out_sqlda->sqld > IB_QUERY->out_sqlda->sqln) {
>   IB_QUERY->out_sqlda = erealloc(IB_QUERY->out_sqlda, 
> XSQLDA_LENGTH(IB_QUERY->out_sqlda->sqld));
>   IB_QUERY->out_sqlda->sqln = IB_QUERY->out_sqlda->sqld;
>-  IB_QUERY->out_sqlda->version = SQLDA_VERSION1;
>-  if (isc_dsql_describe(IB_STATUS, &IB_QUERY->stmt, SQLDA_VERSION1, 
>IB_QUERY->out_sqlda)) {
>+  IB_QUERY->out_sqlda->version = SQLDA_CURRENT_VERSION;
>+  if (isc_dsql_describe(IB_STATUS, &IB_QUERY->stmt, 
>SQLDA_CURRENT_VERSION, IB_QUERY->out_sqlda)) {
>   _php_ibase_error(TSRMLS_C);
>   goto _php_ibase_alloc_query_error;
>   }
>@@ -1201,8 +1206,8 @@
>   /* maybe have input placeholders? */
>   IB_QUERY->in_sqlda = emalloc(XSQLDA_LENGTH(1));
>   IB_QUERY->in_sqlda->sqln = 1;
>-  IB_QUERY->in_sqlda->version = SQLDA_VERSION1;
>-  if (isc_dsql_describe_bind(IB_STATUS, &IB_QUERY->stmt, SQLDA_VERSION1, 
>IB_QUERY->in_sqlda)) {
>+  IB_QUERY->in_sqlda->version = SQLDA_CURRENT_VERSION;
>+  if (isc_dsql_describe_bind(IB_STATUS, &IB_QUERY->stmt, SQLDA_CURRENT_VERSION, 
>IB_QUERY->in_sqlda)) {
>   _php_ibase_error(TSRMLS_C);
>   goto _php_ibase_alloc_query_error;
>   }
>@@ -1211,8 +1216,8 @@
>   if (IB_QUERY->in_sqlda->sqln < IB_QUERY->in_sqlda->sqld) {
>   IB_QUERY->in_sqlda = erealloc(IB_QUERY->in_sqlda, 
> XSQLDA_LENGTH(IB_QUERY->in_sqlda->sqld));
>   IB_QUERY->in_sqlda->sqln = IB_QUERY->in_sqlda->sqld;
>-  IB_QUERY->in_sqlda->version = SQLDA_VERSION1;
>-  if (isc_dsql_describe_bind(IB_STATUS, &IB_QUERY->stmt, SQLDA_VERSION1, 
>IB_QUERY->in_sqlda)) {
>+  IB_QUERY->in_sqlda->version = SQLDA_CURRENT_VERSION;
>+  if (isc_dsql_describe_bind(IB_STATUS, &IB_QUERY->stmt, 
>SQLDA_CURRENT_VERSION, IB_QUERY->in_sqlda)) {
>   _php_ibase_error(TSRMLS_C);
>   goto _php_ibase_alloc_query_error;
>   }
>
>
>
>

-- 
https://www.paypal.com/xclick/[EMAIL PROTECTED]&no_note=1&tax=0¤cy_code=EUR
 


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/interbase interbase.c php_interbase.h

2003-08-14 Thread Ard Biesheuvel
abies   Sun Aug 10 16:53:20 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c php_interbase.h 
  Log:
  Added ibase_num_params() and ibase_param_info()
  @- Added function ibase_num_params() (Ard)
  @- Added function ibase_param_info() (Ard)
  
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.126 php-src/ext/interbase/interbase.c:1.127
--- php-src/ext/interbase/interbase.c:1.126 Sun Aug 10 13:24:51 2003
+++ php-src/ext/interbase/interbase.c   Sun Aug 10 16:53:19 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.126 2003/08/10 17:24:51 abies Exp $ */
+/* $Id: interbase.c,v 1.127 2003/08/10 20:53:19 abies Exp $ */
 
 
 /* TODO: Arrays, roles?
@@ -105,9 +105,11 @@
 #endif
 
PHP_FE(ibase_num_fields, NULL)
+   PHP_FE(ibase_num_params, NULL)
PHP_FE(ibase_num_rows, NULL)
PHP_FE(ibase_affected_rows, NULL)
PHP_FE(ibase_field_info, NULL)
+   PHP_FE(ibase_param_info, NULL)
 
PHP_FE(ibase_trans, NULL)
PHP_FE(ibase_commit, NULL)
@@ -250,22 +252,24 @@
int type;
 
IBDEBUG("Transaction or database link?");
-   if (zend_list_find(Z_LVAL_PP(link_id), &type) && type == le_trans) {
-   /* Transaction resource: make sure it refers to one link only, then 
-  fetch it; database link is stored in ib_trans->db_link[]. */
-   IBDEBUG("Type is le_trans");
-   ZEND_FETCH_RESOURCE(*trans, ibase_trans *, link_id, -1, "InterBase 
transaction", le_trans);
-   if ((*trans)->link_cnt > 1) {
-   _php_ibase_module_error("Link id is ambiguous: transaction 
spans multiple connections.");
+   if (zend_list_find(Z_LVAL_PP(link_id), &type)) {
+   if (type == le_trans) {
+   /* Transaction resource: make sure it refers to one link only, 
then 
+  fetch it; database link is stored in ib_trans->db_link[]. */
+   IBDEBUG("Type is le_trans");
+   ZEND_FETCH_RESOURCE(*trans, ibase_trans *, link_id, -1, 
"InterBase transaction", le_trans);
+   if ((*trans)->link_cnt > 1) {
+   _php_ibase_module_error("Link id is ambiguous: 
transaction spans multiple connections.");
+   return;
+   }   
+   *ib_link = (*trans)->db_link[0];
return;
-   }   
-   *ib_link = (*trans)->db_link[0];
-   } else {
-   IBDEBUG("Type is le_[p]link or id not found");
-   /* Database link resource, use default transaction. */
-   *trans = NULL;
-   ZEND_FETCH_RESOURCE2(*ib_link, ibase_db_link *, link_id, -1, 
"InterBase link", le_link, le_plink);
-   }
+   }
+   } 
+   IBDEBUG("Type is le_[p]link or id not found");
+   /* Database link resource, use default transaction. */
+   *trans = NULL;
+   ZEND_FETCH_RESOURCE2(*ib_link, ibase_db_link *, link_id, -1, "InterBase link", 
le_link, le_plink);
 }

 #define RESET_ERRMSG { IBG(errmsg)[0] = '\0'; IBG(sql_code) = 0; }
@@ -683,7 +687,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.126 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.127 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -2932,12 +2936,13 @@
 /* }}} */
 #endif
 
-/* {{{ proto int ibase_num_fields(resource result)
+/* {{{ proto int ibase_num_fields(resource {query|result})
Get the number of fields in result */
 PHP_FUNCTION(ibase_num_fields)
 {
zval **result;
-   ibase_result *ib_result;
+   int type;
+   XSQLDA *sqlda;
 
RESET_ERRMSG;
 
@@ -2945,14 +2950,25 @@
WRONG_PARAM_COUNT;
}

-   ZEND_FETCH_RESOURCE(ib_result, ibase_result *, result, -1, "InterBase result", 
le_result);
+   zend_list_find(Z_LVAL_PP(result), &type);
+   
+   if (type == le_query) {
+   ibase_query *ib_query;
 
-   if (ib_result->out_sqlda == NULL) {
-   _php_ibase_module_error("Trying to get the number of fields from a 
non-select query");
-   RETURN_FALSE;
-   }
+   ZEND_FETCH_RESOURCE(ib_query, ibase_query *, result, -1, "InterBase 
query", le_query);
+   sqlda = ib_query->out_sqlda;
+   } else {
+   ibase_result *ib_result;
+   
+   ZEND_FETCH_RESOURCE(ib_result, ibase_result *, result, -1, "InterBase 
result", le_result);
+   sqlda = ib_result->out_sqlda;
+   }   

[PHP-CVS] cvs: php-src /ext/interbase interbase.c

2003-08-14 Thread Ard Biesheuvel
abies   Mon Aug 11 22:16:40 2003 EDT

  Modified files:  
/php-src/ext/interbase  interbase.c 
  Log:
  Fix for failed tests except 005
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.129 php-src/ext/interbase/interbase.c:1.130
--- php-src/ext/interbase/interbase.c:1.129 Mon Aug 11 22:11:41 2003
+++ php-src/ext/interbase/interbase.c   Mon Aug 11 22:16:40 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: interbase.c,v 1.129 2003/08/12 02:11:41 sniper Exp $ */
+/* $Id: interbase.c,v 1.130 2003/08/12 02:16:40 abies Exp $ */
 
 
 /* TODO: Arrays, roles?
@@ -687,7 +687,7 @@
 
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
-   php_info_print_table_row(2, "Revision", "$Revision: 1.129 $");
+   php_info_print_table_row(2, "Revision", "$Revision: 1.130 $");
 #ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -1906,12 +1906,12 @@
 static void _php_ibase_do_fetch(ibase_result *ib_result TSRMLS_DC)
 {
if (ib_result->has_more_rows) {
-   if (isc_dsql_fetch(IB_STATUS, &ib_result->stmt, 1, 
ib_result->out_sqlda) == 100L) {
+   if (isc_dsql_fetch(IB_STATUS, &ib_result->stmt, 1, 
ib_result->out_sqlda)) {
+
ib_result->has_more_rows = 0;
-   }
-   
-   if (IB_STATUS[0] && IB_STATUS[1]) { /* error in fetch */
-   _php_ibase_error(TSRMLS_C);
+   if (IB_STATUS[0] && IB_STATUS[1]) { /* error in fetch */
+   _php_ibase_error(TSRMLS_C);
+   }
}
}
 }  
@@ -3528,7 +3528,7 @@
unsigned short b;
ibase_blob_handle ib_blob;
ibase_db_link *ib_link;
-   ibase_trans *trans;
+   ibase_trans *trans = NULL;
char bl_data[IBASE_BLOB_SEG]; /* FIXME? blob_seg_size parameter? */
php_stream *stream;
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



  1   2   >