cvs: php4 /ext/db db.c
| From: | Marcus B�rger | Date: | Tue, 22 Oct 2002 18:39:06 +0000 |
| Subject: | cvs: php4 /ext/db db.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-15155@lists.php.net to get a copy of this message | ||
helly Tue Oct 22 14:39:06 2002 EDT
Modified files:
/php4/ext/db db.c
Log:
Fix this extension.
#The problem was that the extension suspected the hash list to be a
#straight forward list with no closed elements.
Index: php4/ext/db/db.c
diff -u php4/ext/db/db.c:1.77 php4/ext/db/db.c:1.78
--- php4/ext/db/db.c:1.77 Mon Aug 26 20:44:57 2002
+++ php4/ext/db/db.c Tue Oct 22 14:39:05 2002
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: db.c,v 1.77 2002/08/27 00:44:57 helly Exp $ */
+/* $Id: db.c,v 1.78 2002/10/22 18:39:05 helly Exp $ */
#define IS_EXT_MODULE
#ifdef HAVE_CONFIG_H
@@ -166,8 +166,8 @@
int info_type;
if (Z_TYPE_P(id) == IS_STRING) {
- numitems = zend_hash_num_elements(&EG(regular_list));
- for (i=1; i<=numitems; i++) {
+ numitems = zend_hash_next_free_element(&EG(regular_list));
+ for (i=1; i<numitems; i++) {
if (zend_hash_index_find(&EG(regular_list), i, (void **) &le)==FAILURE) {
continue;
}
@@ -189,6 +189,39 @@
}
/* }}} */
+/* {{{ proto array dblist(void)
+ Return an associative array id->filename */
+#if 0_HELLY
+/* New function not needed yet */
+PHP_FUNCTION(db_id_list)
+{
+ ulong numitems, i;
+ zend_rsrc_list_entry *le;
+ dbm_info *info;
+
+ if (ZEND_NUM_ARGS()!=0) {
+ ZEND_WRONG_PARAM_COUNT();
+ RETURN_FALSE;
+ }
+
+ if (array_init(return_value) == FAILURE) {
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to initialize array");
+ RETURN_FALSE;
+ }
+ numitems = zend_hash_next_free_element(&EG(regular_list));
+ for (i=1; i<numitems; i++) {
+ if (zend_hash_index_find(&EG(regular_list), i, (void **) &le)==FAILURE) {
+ continue;
+ }
+ if (Z_TYPE_P(le) == le_db) {
+ info = (dbm_info *)(le->ptr);
+ add_next_index_string(return_value, info->filename, 1);
+ }
+ }
+}
+/* }}} */
+#endif
+
/* {{{ php_get_info_db
*/
static char *php_get_info_db(void)
@@ -369,7 +402,7 @@
if (dbf) {
info = (dbm_info *)emalloc(sizeof(dbm_info));
if (!info) {
- php_error_docref1(NULL TSRMLS_CC, filename, E_ERROR, "Oroblem allocating memory!");
+ php_error_docref1(NULL TSRMLS_CC, filename, E_ERROR, "Problem allocating memory!");
return NULL;
}
@@ -1150,6 +1183,9 @@
PHP_FE(dbmdelete, NULL)
PHP_FE(dbmfirstkey, NULL)
PHP_FE(dbmnextkey, NULL)
+#if 0_HELLY
+ PHP_FE(db_id_list, NULL)
+#endif
{NULL, NULL, NULL}
};
/* }}} */